diff options
author | 2015-05-27 15:00:06 +0200 | |
---|---|---|
committer | 2015-05-27 15:00:06 +0200 | |
commit | ee4adf600bdd3aa60cc0e92a39f2111be0a90bc6 (patch) | |
tree | 5ecb86b72eef1c19ad3ab6c7ba8d8b2a964e0cb9 /3rdparty/unittest-cpp/tests/RecordingReporter.h | |
parent | 55fa9840f263361efc73126c3f41be606fea7168 (diff) |
Added library for supporting unit tests (nw)
Diffstat (limited to '3rdparty/unittest-cpp/tests/RecordingReporter.h')
-rw-r--r-- | 3rdparty/unittest-cpp/tests/RecordingReporter.h | 98 |
1 files changed, 98 insertions, 0 deletions
diff --git a/3rdparty/unittest-cpp/tests/RecordingReporter.h b/3rdparty/unittest-cpp/tests/RecordingReporter.h new file mode 100644 index 00000000000..ea899a238ea --- /dev/null +++ b/3rdparty/unittest-cpp/tests/RecordingReporter.h @@ -0,0 +1,98 @@ +#ifndef UNITTEST_RECORDINGREPORTER_H +#define UNITTEST_RECORDINGREPORTER_H + +#include "UnitTest++/TestReporter.h" +#include <cstring> + +#include "UnitTest++/TestDetails.h" + +struct RecordingReporter : public UnitTest::TestReporter +{ +private: + enum { kMaxStringLength = 256 }; + +public: + RecordingReporter() + : testRunCount(0) + , testFailedCount(0) + , lastFailedLine(0) + , testFinishedCount(0) + , lastFinishedTestTime(0) + , summaryTotalTestCount(0) + , summaryFailedTestCount(0) + , summaryFailureCount(0) + , summarySecondsElapsed(0) + { + lastStartedSuite[0] = '\0'; + lastStartedTest[0] = '\0'; + lastFailedFile[0] = '\0'; + lastFailedSuite[0] = '\0'; + lastFailedTest[0] = '\0'; + lastFailedMessage[0] = '\0'; + lastFinishedSuite[0] = '\0'; + lastFinishedTest[0] = '\0'; + } + + virtual void ReportTestStart(UnitTest::TestDetails const& test) + { + using namespace std; + + ++testRunCount; + strcpy(lastStartedSuite, test.suiteName); + strcpy(lastStartedTest, test.testName); + } + + virtual void ReportFailure(UnitTest::TestDetails const& test, char const* failure) + { + using namespace std; + + ++testFailedCount; + strcpy(lastFailedFile, test.filename); + lastFailedLine = test.lineNumber; + strcpy(lastFailedSuite, test.suiteName); + strcpy(lastFailedTest, test.testName); + strcpy(lastFailedMessage, failure); + } + + virtual void ReportTestFinish(UnitTest::TestDetails const& test, float testDuration) + { + using namespace std; + + ++testFinishedCount; + strcpy(lastFinishedSuite, test.suiteName); + strcpy(lastFinishedTest, test.testName); + lastFinishedTestTime = testDuration; + } + + virtual void ReportSummary(int totalTestCount, int failedTestCount, int failureCount, float secondsElapsed) + { + summaryTotalTestCount = totalTestCount; + summaryFailedTestCount = failedTestCount; + summaryFailureCount = failureCount; + summarySecondsElapsed = secondsElapsed; + } + + int testRunCount; + char lastStartedSuite[kMaxStringLength]; + char lastStartedTest[kMaxStringLength]; + + int testFailedCount; + char lastFailedFile[kMaxStringLength]; + int lastFailedLine; + char lastFailedSuite[kMaxStringLength]; + char lastFailedTest[kMaxStringLength]; + char lastFailedMessage[kMaxStringLength]; + + int testFinishedCount; + char lastFinishedSuite[kMaxStringLength]; + char lastFinishedTest[kMaxStringLength]; + float lastFinishedTestTime; + + int summaryTotalTestCount; + int summaryFailedTestCount; + int summaryFailureCount; + float summarySecondsElapsed; +}; + + +#endif |