Mercurial > fife-parpg
annotate ext/UnitTest++/src/TestReporterStdout.cpp @ 37:0d325e9d5953
added unittest++ files into ext. Not hooked into build scripts yet
author | jasoka@33b003aa-7bff-0310-803a-e67f0ece8222 |
---|---|
date | Sat, 12 Jul 2008 12:00:57 +0000 |
parents | |
children |
rev | line source |
---|---|
37
0d325e9d5953
added unittest++ files into ext. Not hooked into build scripts yet
jasoka@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
1 #include "TestReporterStdout.h" |
0d325e9d5953
added unittest++ files into ext. Not hooked into build scripts yet
jasoka@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
2 #include <cstdio> |
0d325e9d5953
added unittest++ files into ext. Not hooked into build scripts yet
jasoka@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
3 |
0d325e9d5953
added unittest++ files into ext. Not hooked into build scripts yet
jasoka@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
4 #include "TestDetails.h" |
0d325e9d5953
added unittest++ files into ext. Not hooked into build scripts yet
jasoka@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
5 |
0d325e9d5953
added unittest++ files into ext. Not hooked into build scripts yet
jasoka@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
6 namespace UnitTest { |
0d325e9d5953
added unittest++ files into ext. Not hooked into build scripts yet
jasoka@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
7 |
0d325e9d5953
added unittest++ files into ext. Not hooked into build scripts yet
jasoka@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
8 void TestReporterStdout::ReportFailure(TestDetails const& details, char const* failure) |
0d325e9d5953
added unittest++ files into ext. Not hooked into build scripts yet
jasoka@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
9 { |
0d325e9d5953
added unittest++ files into ext. Not hooked into build scripts yet
jasoka@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
10 #ifdef __APPLE__ |
0d325e9d5953
added unittest++ files into ext. Not hooked into build scripts yet
jasoka@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
11 char const* const errorFormat = "%s:%d: error: Failure in %s: %s\n"; |
0d325e9d5953
added unittest++ files into ext. Not hooked into build scripts yet
jasoka@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
12 #else |
0d325e9d5953
added unittest++ files into ext. Not hooked into build scripts yet
jasoka@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
13 char const* const errorFormat = "%s(%d): error: Failure in %s: %s\n"; |
0d325e9d5953
added unittest++ files into ext. Not hooked into build scripts yet
jasoka@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
14 #endif |
0d325e9d5953
added unittest++ files into ext. Not hooked into build scripts yet
jasoka@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
15 std::printf(errorFormat, details.filename, details.lineNumber, details.testName, failure); |
0d325e9d5953
added unittest++ files into ext. Not hooked into build scripts yet
jasoka@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
16 } |
0d325e9d5953
added unittest++ files into ext. Not hooked into build scripts yet
jasoka@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
17 |
0d325e9d5953
added unittest++ files into ext. Not hooked into build scripts yet
jasoka@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
18 void TestReporterStdout::ReportTestStart(TestDetails const& /*test*/) |
0d325e9d5953
added unittest++ files into ext. Not hooked into build scripts yet
jasoka@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
19 { |
0d325e9d5953
added unittest++ files into ext. Not hooked into build scripts yet
jasoka@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
20 } |
0d325e9d5953
added unittest++ files into ext. Not hooked into build scripts yet
jasoka@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
21 |
0d325e9d5953
added unittest++ files into ext. Not hooked into build scripts yet
jasoka@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
22 void TestReporterStdout::ReportTestFinish(TestDetails const& /*test*/, float) |
0d325e9d5953
added unittest++ files into ext. Not hooked into build scripts yet
jasoka@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
23 { |
0d325e9d5953
added unittest++ files into ext. Not hooked into build scripts yet
jasoka@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
24 } |
0d325e9d5953
added unittest++ files into ext. Not hooked into build scripts yet
jasoka@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
25 |
0d325e9d5953
added unittest++ files into ext. Not hooked into build scripts yet
jasoka@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
26 void TestReporterStdout::ReportSummary(int const totalTestCount, int const failedTestCount, |
0d325e9d5953
added unittest++ files into ext. Not hooked into build scripts yet
jasoka@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
27 int const failureCount, float secondsElapsed) |
0d325e9d5953
added unittest++ files into ext. Not hooked into build scripts yet
jasoka@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
28 { |
0d325e9d5953
added unittest++ files into ext. Not hooked into build scripts yet
jasoka@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
29 if (failureCount > 0) |
0d325e9d5953
added unittest++ files into ext. Not hooked into build scripts yet
jasoka@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
30 std::printf("FAILURE: %d out of %d tests failed (%d failures).\n", failedTestCount, totalTestCount, failureCount); |
0d325e9d5953
added unittest++ files into ext. Not hooked into build scripts yet
jasoka@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
31 else |
0d325e9d5953
added unittest++ files into ext. Not hooked into build scripts yet
jasoka@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
32 std::printf("Success: %d tests passed.\n", totalTestCount); |
0d325e9d5953
added unittest++ files into ext. Not hooked into build scripts yet
jasoka@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
33 std::printf("Test time: %.2f seconds.\n", secondsElapsed); |
0d325e9d5953
added unittest++ files into ext. Not hooked into build scripts yet
jasoka@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
34 } |
0d325e9d5953
added unittest++ files into ext. Not hooked into build scripts yet
jasoka@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
35 |
0d325e9d5953
added unittest++ files into ext. Not hooked into build scripts yet
jasoka@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
36 } |