G+Smo  25.01.0
Geometry + Simulation Modules
 
Loading...
Searching...
No Matches
TestRunner.h
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
14UNITTEST_LINKAGE int RunAllTests();
15
16struct True
17{
18 bool operator()(const Test* const) const
19 {
20 return true;
21 }
22};
23
24class UNITTEST_LINKAGE TestRunner
25{
26public:
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->m_nextTest;
42 }
43
44 return Finish();
45 }
46
47 TestResults* GetTestResults();
48
49private:
50 TestReporter* m_reporter;
51 TestResults* m_result;
52 Timer* m_timer;
53
54 int Finish() const;
55 bool IsTestInSuite(const Test* const curTest, char const* suiteName) const;
56 void RunTest(TestResults* const result, Test* const curTest, int const maxTestTimeInMs) const;
57};
58
59}
60
61#endif