1 |
|
2 |
|
3 |
#include "CppUnitTest/TestSuite.h" |
4 |
#include "CppUnitTest/TestResult.h" |
5 |
|
6 |
USING_NAMESPACE_CPPUNITTEST |
7 |
|
8 |
// Deletes all tests in the suite. |
9 |
void TestSuite::deleteContents () |
10 |
{ |
11 |
for (std::vector<Test *>::iterator it = m_tests.begin (); |
12 |
it != m_tests.end (); |
13 |
++it) |
14 |
delete *it; |
15 |
|
16 |
} |
17 |
|
18 |
|
19 |
// Runs the tests and collects their result in a TestResult. |
20 |
void TestSuite::run (TestResult *result) |
21 |
{ |
22 |
for (std::vector<Test *>::iterator it = m_tests.begin (); |
23 |
it != m_tests.end (); |
24 |
++it) { |
25 |
if (result->shouldStop ()) |
26 |
break; |
27 |
|
28 |
Test *test = *it; |
29 |
test->setArgs(getArgs()); |
30 |
test->run (result); |
31 |
if(test->hasFailure()) { |
32 |
setFailure(); |
33 |
} |
34 |
} |
35 |
|
36 |
} |
37 |
|
38 |
|
39 |
// Counts the number of test cases that will be run by this test. |
40 |
int TestSuite::countTestCases () |
41 |
{ |
42 |
int count = 0; |
43 |
|
44 |
for (std::vector<Test *>::iterator it = m_tests.begin (); |
45 |
it != m_tests.end (); |
46 |
++it) |
47 |
count += (*it)->countTestCases (); |
48 |
|
49 |
return count; |
50 |
|
51 |
} |
52 |
|
53 |
|