Revision 737, 1.1 kB
(checked in by mido, 15 years ago)
|
ASTYLER RUN OVER THE WHOLE LIBRARY, JUPEE
|
-
Property svn:eol-style set to
native
|
Rev | Line | |
---|
[418] | 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 | |
---|
[477] | 16 | struct True { |
---|
| 17 | bool operator() ( const Test* const ) const { |
---|
| 18 | return true; |
---|
[418] | 19 | } |
---|
| 20 | }; |
---|
| 21 | |
---|
[477] | 22 | class TestRunner { |
---|
[418] | 23 | public: |
---|
[477] | 24 | explicit TestRunner ( TestReporter& reporter ); |
---|
[418] | 25 | ~TestRunner(); |
---|
| 26 | |
---|
| 27 | template <class Predicate> |
---|
[477] | 28 | int RunTestsIf ( TestList const& list, char const* suiteName, |
---|
| 29 | const Predicate& predicate, int maxTestTimeInMs ) const { |
---|
| 30 | Test* curTest = list.GetHead(); |
---|
[418] | 31 | |
---|
[477] | 32 | while ( curTest != 0 ) { |
---|
[737] | 33 | if ( IsTestInSuite ( curTest, suiteName ) && predicate ( curTest ) ) { |
---|
[736] | 34 | ClearEnvironment(); |
---|
[477] | 35 | RunTest ( m_result, curTest, maxTestTimeInMs ); |
---|
[736] | 36 | } |
---|
[418] | 37 | |
---|
[736] | 38 | |
---|
[418] | 39 | curTest = curTest->next; |
---|
[477] | 40 | } |
---|
[418] | 41 | |
---|
[477] | 42 | return Finish(); |
---|
| 43 | } |
---|
[418] | 44 | |
---|
| 45 | private: |
---|
| 46 | TestReporter* m_reporter; |
---|
| 47 | TestResults* m_result; |
---|
| 48 | Timer* m_timer; |
---|
| 49 | |
---|
| 50 | int Finish() const; |
---|
[477] | 51 | bool IsTestInSuite ( const Test* const curTest, char const* suiteName ) const; |
---|
[737] | 52 | void RunTest ( TestResults* const result, Test* const curTest, int const maxTestTimeInMs ) const; |
---|
[736] | 53 | void ClearEnvironment() const; |
---|
[418] | 54 | }; |
---|
| 55 | |
---|
| 56 | } |
---|
| 57 | |
---|
| 58 | #endif |
---|