This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | // File: test_dummy.cpp | |
| #include "test_dummy.hpp" | |
| DefineTest(dummy, dummycase){ | |
| // Write your test code here | |
| // ... | |
| } | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | // File: test_main.cpp | |
| #include "test_project.hpp" | |
| int main(){ | |
| RegisterTest(module, test1) | |
| RegisterTest(module, test2) | |
| RunTests() | |
| return 0; | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | // test.hpp | |
| #include "unittest.hpp" | |
| DeclareTest(module, test1) | |
| DeclareTest(module, test2) | |
| ... | |
| //test.cpp | |
| #include "test.hpp" | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | // File: unittest.cpp | |
| void UnitTest::runTests() | |
| { | |
| // variables to count the number of passed and failed tests | |
| static int passed{0}; | |
| static int failed{0}; | |
| if(testList.empty()) | |
| { | |
| std::cout << "No tests registered!!" << std::endl; | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | // File: unittest.hpp | |
| #define RegisterTest(Module, TestName) \ | |
| UnitTest::getInstance().testList.push_back( \ | |
| Test_##Module##_##TestName::getInstance()); | |
| #define RunTests() \ | |
| UnitTest::getInstance().runTests(); | |
| #define ExpectEQ(arg1, arg2) \ | |
| isTrue &= expectEQ(arg1, arg2); | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | // File: unitest.cpp | |
| void UnitTest::runTests() | |
| { | |
| // Variables to track passed and failed tests | |
| int passed{0}; | |
| int failed{0}; | |
| if(testList.empty()) { | |
| std::cout << "No tests registered!!" << std::endl; | |
| return; | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | // File: unittest.hpp | |
| class UnitTest { | |
| protected: | |
| UnitTest() {} | |
| public: | |
| bool isTrue{true}; | |
| static std::list<UnitTest*> testList; | |
| virtual ~UnitTest() {} | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | // File: testcase.cpp | |
| #include "testcase.hpp" | |
| DefineTest(dummy, dummycase){ | |
| // Write your test code here | |
| // ... | |
| } | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | // File: testcase.hpp | |
| #include "unittest.hpp" | |
| DeclareTest(dummy, dummycase) | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | // File: unittest.hpp | |
| #define DeclareTest(Module, TestName) \ | |
| class Test_##Module##_##TestName: public UnitTest \ | |
| { \ | |
| Test_##Module##_##TestName(): UnitTest(){} \ | |
| public: \ | |
| static Test_##Module##_##TestName* getInstance() \ | |
| { \ | |
| static Test_##Module##_##TestName testClass; \ | |
| return &testClass; \ | 
NewerOlder