?login_element?

Subversion Repositories NedoOS

Rev

Blame | Last modification | View Log | Download

  1. #ifndef UNITTEST_RECORDINGREPORTER_H
  2. #define UNITTEST_RECORDINGREPORTER_H
  3.  
  4. #include "UnitTest++/TestReporter.h"
  5. #include <cstring>
  6.  
  7. #include "UnitTest++/TestDetails.h"
  8.  
  9. struct RecordingReporter : public UnitTest::TestReporter
  10. {
  11. private:
  12.    enum { kMaxStringLength = 256 };
  13.  
  14. public:
  15.    RecordingReporter()
  16.       : testRunCount(0)
  17.       , testFailedCount(0)
  18.       , lastFailedLine(0)
  19.       , testFinishedCount(0)
  20.       , lastFinishedTestTime(0)
  21.       , summaryTotalTestCount(0)
  22.       , summaryFailedTestCount(0)
  23.       , summaryFailureCount(0)
  24.       , summarySecondsElapsed(0)
  25.    {
  26.       lastStartedSuite[0] = '\0';
  27.       lastStartedTest[0] = '\0';
  28.       lastFailedFile[0] = '\0';
  29.       lastFailedSuite[0] = '\0';
  30.       lastFailedTest[0] = '\0';
  31.       lastFailedMessage[0] = '\0';
  32.       lastFinishedSuite[0] = '\0';
  33.       lastFinishedTest[0] = '\0';
  34.    }
  35.  
  36.    virtual void ReportTestStart(UnitTest::TestDetails const& test)
  37.    {
  38.       using namespace std;
  39.  
  40.       ++testRunCount;
  41.       strcpy(lastStartedSuite, test.suiteName);
  42.       strcpy(lastStartedTest, test.testName);
  43.    }
  44.  
  45.    virtual void ReportFailure(UnitTest::TestDetails const& test, char const* failure)
  46.    {
  47.       using namespace std;
  48.  
  49.       ++testFailedCount;
  50.       strcpy(lastFailedFile, test.filename);
  51.       lastFailedLine = test.lineNumber;
  52.       strcpy(lastFailedSuite, test.suiteName);
  53.       strcpy(lastFailedTest, test.testName);
  54.       strcpy(lastFailedMessage, failure);
  55.    }
  56.  
  57.    virtual void ReportTestFinish(UnitTest::TestDetails const& test, float testDuration)
  58.    {
  59.       using namespace std;
  60.  
  61.       ++testFinishedCount;
  62.       strcpy(lastFinishedSuite, test.suiteName);
  63.       strcpy(lastFinishedTest, test.testName);
  64.       lastFinishedTestTime = testDuration;
  65.    }
  66.  
  67.    virtual void ReportSummary(int totalTestCount, int failedTestCount, int failureCount, float secondsElapsed)
  68.    {
  69.       summaryTotalTestCount = totalTestCount;
  70.       summaryFailedTestCount = failedTestCount;
  71.       summaryFailureCount = failureCount;
  72.       summarySecondsElapsed = secondsElapsed;
  73.    }
  74.  
  75.    int testRunCount;
  76.    char lastStartedSuite[kMaxStringLength];
  77.    char lastStartedTest[kMaxStringLength];
  78.  
  79.    int testFailedCount;
  80.    char lastFailedFile[kMaxStringLength];
  81.    int lastFailedLine;
  82.    char lastFailedSuite[kMaxStringLength];
  83.    char lastFailedTest[kMaxStringLength];
  84.    char lastFailedMessage[kMaxStringLength];
  85.  
  86.    int testFinishedCount;
  87.    char lastFinishedSuite[kMaxStringLength];
  88.    char lastFinishedTest[kMaxStringLength];
  89.    float lastFinishedTestTime;
  90.  
  91.    int summaryTotalTestCount;
  92.    int summaryFailedTestCount;
  93.    int summaryFailureCount;
  94.    float summarySecondsElapsed;
  95. };
  96.  
  97.  
  98. #endif
  99.