?login_element?

Subversion Repositories NedoOS

Rev

Blame | Last modification | View Log | Download

  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(UNITTEST_WIN32) && (_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.       using namespace std;
  16. #if defined(__APPLE__) || defined(__GNUG__)
  17.       char const* const errorFormat = "%s:%d:%d: error: Failure in %s: %s\n";
  18.       fprintf(stderr, errorFormat, details.filename, details.lineNumber, 1, details.testName, failure);
  19. #else
  20.       char const* const errorFormat = "%s(%d): error: Failure in %s: %s\n";
  21.       fprintf(stderr, errorFormat, details.filename, details.lineNumber, details.testName, failure);
  22. #endif
  23.    }
  24.  
  25.    void TestReporterStdout::ReportTestStart(TestDetails const& /*test*/)
  26.    {}
  27.  
  28.    void TestReporterStdout::ReportTestFinish(TestDetails const& /*test*/, float)
  29.    {}
  30.  
  31.    void TestReporterStdout::ReportSummary(int const totalTestCount, int const failedTestCount,
  32.                                           int const failureCount, float const secondsElapsed)
  33.    {
  34.       using namespace std;
  35.  
  36.       if (failureCount > 0)
  37.          printf("FAILURE: %d out of %d tests failed (%d failures).\n", failedTestCount, totalTestCount, failureCount);
  38.       else
  39.          printf("Success: %d tests passed.\n", totalTestCount);
  40.  
  41.       printf("Test time: %.2f seconds.\n", secondsElapsed);
  42.    }
  43.  
  44. }
  45.