1 | #include "TestReporterStdout.h" |
---|
2 | #include <cstdio> |
---|
3 | |
---|
4 | #include "TestDetails.h" |
---|
5 | |
---|
6 | // cstdio doesn't pull in namespace std on VC6, so we do it here. |
---|
7 | #if defined(_MSC_VER) && (_MSC_VER == 1200) |
---|
8 | namespace std {} |
---|
9 | #endif |
---|
10 | |
---|
11 | namespace UnitTest { |
---|
12 | |
---|
13 | void TestReporterStdout::ReportFailure(TestDetails const& details, char const* failure) |
---|
14 | { |
---|
15 | #if defined(__APPLE__) || defined(__GNUG__) |
---|
16 | char const* const errorFormat = "%s:%d: error: Failure in %s: %s\n"; |
---|
17 | #else |
---|
18 | char const* const errorFormat = "%s(%d): error: Failure in %s: %s\n"; |
---|
19 | #endif |
---|
20 | |
---|
21 | using namespace std; |
---|
22 | |
---|
23 | if (details.useFilename) { |
---|
24 | // standard way |
---|
25 | printf(errorFormat, details.filename, details.lineNumber, details.testName, failure); |
---|
26 | } else { |
---|
27 | // extended for BDM - the failure string already includes |
---|
28 | // (custom) test location info |
---|
29 | printf("%s\n", failure); |
---|
30 | } |
---|
31 | } |
---|
32 | |
---|
33 | void TestReporterStdout::ReportTestStart(TestDetails const& /*test*/) |
---|
34 | { |
---|
35 | } |
---|
36 | |
---|
37 | void TestReporterStdout::ReportTestFinish(TestDetails const& /*test*/, float) |
---|
38 | { |
---|
39 | } |
---|
40 | |
---|
41 | void TestReporterStdout::ReportSummary(int const totalTestCount, int const failedTestCount, |
---|
42 | int const failureCount, float secondsElapsed) |
---|
43 | { |
---|
44 | using namespace std; |
---|
45 | |
---|
46 | if (failureCount > 0) |
---|
47 | printf("FAILURE: %d out of %d tests failed (%d failures).\n", failedTestCount, totalTestCount, failureCount); |
---|
48 | else |
---|
49 | printf("Success: %d tests passed.\n", totalTestCount); |
---|
50 | |
---|
51 | printf("Test time: %.2f seconds.\n", secondsElapsed); |
---|
52 | } |
---|
53 | |
---|
54 | } |
---|