1 #include "TestReporterStdout.h" 2 #include <cstdio> 3 4 #include "TestDetails.h" 5 6 #ifdef _XBOX_ONE 7 #include <windows.h> 8 #include <assert.h> 9 #endif 10 11 // cstdio doesn't pull in namespace std on VC6, so we do it here. 12 #if defined(UNITTEST_WIN32) && (_MSC_VER == 1200) 13 namespace std {} 14 #endif 15 16 namespace UnitTest { 17 18 void TestReporterStdout::ReportFailure(TestDetails const& details, char const* failure) 19 { 20 #ifdef _XBOX_ONE 21 details; 22 failure; 23 OutputDebugStringA("Failed "); 24 OutputDebugStringA(failure); 25 OutputDebugStringA("\n"); 26 //assert(false); 27 #else 28 29 using namespace std; 30 #if defined(__APPLE__) || defined(__GNUG__) 31 char const* const errorFormat = "%s:%d:%d: error: Failure in %s: %s\n"; 32 fprintf(stderr, errorFormat, details.filename, details.lineNumber, 1, details.testName, failure); 33 #else 34 char const* const errorFormat = "%s(%d): error: Failure in %s: %s\n"; 35 fprintf(stderr, errorFormat, details.filename, details.lineNumber, details.testName, failure); 36 #endif 37 #endif 38 } 39 40 void TestReporterStdout::ReportTestStart(TestDetails const& details/*test*/) 41 { 42 #ifdef _XBOX_ONE 43 OutputDebugStringA("\n=> Test: "); 44 OutputDebugStringA(details.testName); 45 OutputDebugStringA("\n"); 46 #else 47 printf("\n=> Test: %s\n", details.testName); 48 #endif 49 } 50 51 void TestReporterStdout::ReportTestFinish(TestDetails const& /*test*/, float delta) 52 { 53 #ifdef _XBOX_ONE 54 delta; 55 OutputDebugStringA("=> Finished\n"); 56 #else 57 printf("=> Finished in %3.2f sec\n", delta); 58 #endif 59 } 60 61 void TestReporterStdout::ReportSummary(int const totalTestCount, int const failedTestCount, 62 int const failureCount, float const secondsElapsed) 63 { 64 using namespace std; 65 66 if (failureCount > 0) 67 printf("FAILURE: %d out of %d tests failed (%d failures).\n", failedTestCount, totalTestCount, failureCount); 68 else 69 printf("Success: %d tests passed.\n", totalTestCount); 70 71 printf("Test time: %.2f seconds.\n", secondsElapsed); 72 } 73 74 } 75