| Revision 418, 1.1 kB
            (checked in by vbarta, 16 years ago) | 
        
          | 
#27: added UnitTest?++ to bdm sources, changed test_user_data to use it 
 | 
      
      
    | Line |  | 
|---|
| 1 | #ifndef UNITTEST_TESTRUNNER_H | 
|---|
| 2 | #define UNITTEST_TESTRUNNER_H | 
|---|
| 3 |  | 
|---|
| 4 | #include "Test.h" | 
|---|
| 5 | #include "TestList.h" | 
|---|
| 6 | #include "CurrentTest.h" | 
|---|
| 7 |  | 
|---|
| 8 | namespace UnitTest { | 
|---|
| 9 |  | 
|---|
| 10 | class TestReporter; | 
|---|
| 11 | class TestResults; | 
|---|
| 12 | class Timer; | 
|---|
| 13 |  | 
|---|
| 14 | int RunAllTests(); | 
|---|
| 15 |  | 
|---|
| 16 | struct True | 
|---|
| 17 | { | 
|---|
| 18 | bool operator()(const Test* const) const | 
|---|
| 19 | { | 
|---|
| 20 | return true; | 
|---|
| 21 | } | 
|---|
| 22 | }; | 
|---|
| 23 |  | 
|---|
| 24 | class TestRunner | 
|---|
| 25 | { | 
|---|
| 26 | public: | 
|---|
| 27 | explicit TestRunner(TestReporter& reporter); | 
|---|
| 28 | ~TestRunner(); | 
|---|
| 29 |  | 
|---|
| 30 | template <class Predicate> | 
|---|
| 31 | int RunTestsIf(TestList const& list, char const* suiteName, | 
|---|
| 32 | const Predicate& predicate, int maxTestTimeInMs) const | 
|---|
| 33 | { | 
|---|
| 34 | Test* curTest = list.GetHead(); | 
|---|
| 35 |  | 
|---|
| 36 | while (curTest != 0) | 
|---|
| 37 | { | 
|---|
| 38 | if (IsTestInSuite(curTest, suiteName) && predicate(curTest)) | 
|---|
| 39 | RunTest(m_result, curTest, maxTestTimeInMs); | 
|---|
| 40 |  | 
|---|
| 41 | curTest = curTest->next; | 
|---|
| 42 | } | 
|---|
| 43 |  | 
|---|
| 44 | return Finish(); | 
|---|
| 45 | } | 
|---|
| 46 |  | 
|---|
| 47 | private: | 
|---|
| 48 | TestReporter* m_reporter; | 
|---|
| 49 | TestResults* m_result; | 
|---|
| 50 | Timer* m_timer; | 
|---|
| 51 |  | 
|---|
| 52 | int Finish() const; | 
|---|
| 53 | bool IsTestInSuite(const Test* const curTest, char const* suiteName) const; | 
|---|
| 54 | void RunTest(TestResults* const result, Test* const curTest, int const maxTestTimeInMs) const; | 
|---|
| 55 | }; | 
|---|
| 56 |  | 
|---|
| 57 | } | 
|---|
| 58 |  | 
|---|
| 59 | #endif | 
|---|