16 #ifndef CPPUNIT_BASE_H 
   17 #define CPPUNIT_BASE_H 
   18 #if __cplusplus >= 201103L || defined(DOXYGEN) 
   22 #include <type_traits> 
   23 #ifndef CPPUNIT_SUITE_CNT 
   27 #define CPPUNIT_SUITE_CNT (10) 
   52     virtual bool run() = 0;
 
   86     std::array<test*, CPPUNIT_SUITE_CNT> 
tests{}; 
 
  115         printf(
"Suite %s completed: %s\n----\n", 
get_name(), 
suc ? 
"SUCCESS" : 
"FAILURE");
 
  136 #define RUN_SUITE(name) test_suite_##name.run(); 
  144 #define TEST_SUITE_F(suite, name)                                              \ 
  145     static_assert(sizeof(#suite) > 1, "test fixture class must not be empty"); \
 
  146     static_assert(sizeof(#name) > 1, "test_suite name must not be empty");     \
 
  147     class test_suite_##name : public suite {                                   \
 
  148         const char* get_name() const override {                                \
 
  152     test_suite_##name test_suite_##name;
 
  159 #define TEST_SUITE(name) TEST_SUITE_F(::riot::testing::test_suite, name) 
  168 #define TEST(suite, name)                                                      \ 
  169     class Test_##name : public ::riot::testing::test {                         \ 
  175             test_suite_##suite.addTest(this);                                  \ 
  178             test_suite_##suite.set_up();                                       \ 
  179             printf("Running test " #name "...\n");                             \
 
  181             printf("Test " #name ": %s\n", success() ? "SUCCESS" : "FAILURE"); \
 
  182             test_suite_##suite.tear_down();                                    \
 
  186     void Test_##name::test_body()
 
  188 #error This library needs C++11 and newer 
void addTest(test *test)
Run all tests in the suite.
 
virtual void tear_down()
method to run after each test
 
virtual void run()
Run all tests in the suite.
 
std::array< test *, CPPUNIT_SUITE_CNT > tests
array of tests to run
 
virtual const char * get_name() const
get the name of the test suite
 
bool suc
Indicates success of all tests after running the suite.
 
virtual void set_up()
method to run before each test
 
bool success() const
Check whether the test completed successfully.
 
void fail()
Indicate failure during test run.
 
virtual bool run()=0
Run the test.
 
#define printf(...)
A wrapper for the printf() function that passes arguments through unmodified, but fails to compile if...
 
#define CPPUNIT_SUITE_CNT
Maximum amount of tests in one test suite.