root/library/tests/unittest-cpp/TestReporterStdout.cpp @ 1115

Revision 706, 1.4 kB (checked in by smidl, 15 years ago)

eol-native

  • Property svn:eol-style set to native
Line 
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)
8namespace std {}
9#endif
10
11namespace UnitTest {
12
13void TestReporterStdout::ReportFailure ( TestDetails const& details, char const* failure ) {
14#if defined(__APPLE__) || defined(__GNUG__)
15        char const* const errorFormat = "%s:%d: error: Failure in %s: %s\n";
16#else
17        char const* const errorFormat = "%s(%d): error: Failure in %s: %s\n";
18#endif
19
20        using namespace std;
21
22        if ( details.useFilename ) {
23                // standard way
24                printf ( errorFormat, details.filename, details.lineNumber, details.testName, failure );
25        } else {
26                // extended for BDM - the failure string already includes
27                // (custom) test location info
28                printf ( "%s\n", failure );
29        }
30}
31
32void TestReporterStdout::ReportTestStart ( TestDetails const& /*test*/ ) {
33}
34
35void TestReporterStdout::ReportTestFinish ( TestDetails const& /*test*/, float ) {
36}
37
38void TestReporterStdout::ReportSummary ( int const totalTestCount, int const failedTestCount,
39        int const failureCount, float secondsElapsed ) {
40        using namespace std;
41
42        if ( failureCount > 0 )
43                printf ( "FAILURE: %d out of %d tests failed (%d failures).\n", failedTestCount, totalTestCount, failureCount );
44        else
45                printf ( "Success: %d tests passed.\n", totalTestCount );
46
47        printf ( "Test time: %.2f seconds.\n", secondsElapsed );
48}
49
50}
Note: See TracBrowser for help on using the browser.