-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTestSuite.cpp
50 lines (36 loc) · 1.21 KB
/
TestSuite.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#include "TestSuite.h"
#define RULER << endl << "----------------------------------------" << endl
#include "HttpHeaderTest.h"
#include "TestingTests.h"
TestSuite::TestSuite() {
addTest(new TestingTests());
addTest(new HttpHeaderTest());
}
TestSuite::~TestSuite() {
for(deque<Test*>::iterator itTest = _tests.begin(); itTest != _tests.end(); ++itTest) {
delete (*itTest);
}
}
void TestSuite::addTest(Test* test) {
_tests.push_back(test);
}
void TestSuite::run() {
deque<Test*>::iterator itTest;
int failed = 0;
int passed = 0;
cout << "Starting tests:" RULER << endl;
for(itTest = _tests.begin(); itTest != _tests.end(); ++itTest) {
Test* test = (*itTest);
test->run();
failed += test->getFailed();
passed += test->getPassed();
cout << "Test results for " << test->getName() << ":" << endl;
cout << " Passed: " << test->getPassed() << ", failed: " << test->getFailed() << "." << endl;
const string trace = test->getTraceBuffer();
if(!trace.empty()) {
cout << trace;
}
}
cout RULER;
cout << "Final results: passed: " << passed << ", failed: " << failed << "." << endl << endl;
}