root/library/tests/unittest-cpp/TestRunner.h @ 736

Revision 736, 1.1 kB (checked in by mido, 14 years ago)

a small improvement of TestRunner?, now cleaning enviroment for each test - but it did not help, merger_2d_stress (and others) is stil running improperly

  • 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
8namespace UnitTest {
9
10class TestReporter;
11class TestResults;
12class Timer;
13
14int RunAllTests();
15
16struct True {
17        bool operator() ( const Test* const ) const {
18                return true;
19        }
20};
21
22class TestRunner {
23public:
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                        {
35                                ClearEnvironment();
36                                RunTest ( m_result, curTest, maxTestTimeInMs );
37                        }
38
39
40                        curTest = curTest->next;
41                }
42
43                return Finish();
44        }
45
46private:
47        TestReporter* m_reporter;
48        TestResults* m_result;
49        Timer* m_timer;
50
51        int Finish() const;
52        bool IsTestInSuite ( const Test* const curTest, char const* suiteName ) const;
53        void RunTest ( TestResults* const result, Test* const curTest, int const maxTestTimeInMs ) const;       
54        void ClearEnvironment() const;
55};
56
57}
58
59#endif
Note: See TracBrowser for help on using the browser.