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