Line | |
---|
1 | #include "BDDTest.h"
|
---|
2 | #include "trace.h"
|
---|
3 | #include <sstream>
|
---|
4 | #include <iostream>
|
---|
5 | #include <string>
|
---|
6 | #include <list>
|
---|
7 |
|
---|
8 | int testCount = 0;
|
---|
9 | int testPasses = 0;
|
---|
10 | const char* testDescription;
|
---|
11 |
|
---|
12 | std::list<std::string> failureList;
|
---|
13 |
|
---|
14 | void bddtest_suite(const char* name) {
|
---|
15 | LOG(name << "\n");
|
---|
16 | }
|
---|
17 |
|
---|
18 | int bddtest_test(const char* file, int line, const char* assertion, int result) {
|
---|
19 | if (!result) {
|
---|
20 | LOG("â\n");
|
---|
21 | std::ostringstream os;
|
---|
22 | os << " ! "<<testDescription<<"\n " <<file << ":" <<line<<" : "<<assertion<<" ["<<result<<"]";
|
---|
23 | failureList.push_back(os.str());
|
---|
24 | }
|
---|
25 | return result;
|
---|
26 | }
|
---|
27 |
|
---|
28 | void bddtest_start(const char* description) {
|
---|
29 | LOG(" - "<<description<<" ");
|
---|
30 | testDescription = description;
|
---|
31 | testCount ++;
|
---|
32 | }
|
---|
33 | void bddtest_end() {
|
---|
34 | LOG("â\n");
|
---|
35 | testPasses ++;
|
---|
36 | }
|
---|
37 |
|
---|
38 | int bddtest_summary() {
|
---|
39 | for (std::list<std::string>::iterator it = failureList.begin(); it != failureList.end(); it++) {
|
---|
40 | LOG("\n");
|
---|
41 | LOG(*it);
|
---|
42 | LOG("\n");
|
---|
43 | }
|
---|
44 |
|
---|
45 | LOG(std::dec << testPasses << "/" << testCount << " tests passed\n\n");
|
---|
46 | if (testPasses == testCount) {
|
---|
47 | return 0;
|
---|
48 | }
|
---|
49 | return 1;
|
---|
50 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.