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