Mercurial > fife-parpg
comparison ext/UnitTest++/src/tests/TestTestResults.cpp @ 37:0d325e9d5953
added unittest++ files into ext. Not hooked into build scripts yet
author | jasoka@33b003aa-7bff-0310-803a-e67f0ece8222 |
---|---|
date | Sat, 12 Jul 2008 12:00:57 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
36:6f1227f4932b | 37:0d325e9d5953 |
---|---|
1 #include "../UnitTest++.h" | |
2 #include "../TestResults.h" | |
3 #include "RecordingReporter.h" | |
4 | |
5 using namespace UnitTest; | |
6 | |
7 namespace { | |
8 | |
9 TestDetails const details("testname", "suitename", "filename", 123); | |
10 | |
11 | |
12 TEST(StartsWithNoTestsRun) | |
13 { | |
14 TestResults results; | |
15 CHECK_EQUAL (0, results.GetTotalTestCount()); | |
16 } | |
17 | |
18 TEST(RecordsNumbersOfTests) | |
19 { | |
20 TestResults results; | |
21 results.OnTestStart(details); | |
22 results.OnTestStart(details); | |
23 results.OnTestStart(details); | |
24 CHECK_EQUAL(3, results.GetTotalTestCount()); | |
25 } | |
26 | |
27 TEST(StartsWithNoTestsFailing) | |
28 { | |
29 TestResults results; | |
30 CHECK_EQUAL (0, results.GetFailureCount()); | |
31 } | |
32 | |
33 TEST(RecordsNumberOfFailures) | |
34 { | |
35 TestResults results; | |
36 results.OnTestFailure(details, ""); | |
37 results.OnTestFailure(details, ""); | |
38 CHECK_EQUAL(2, results.GetFailureCount()); | |
39 } | |
40 | |
41 TEST(RecordsNumberOfFailedTests) | |
42 { | |
43 TestResults results; | |
44 | |
45 results.OnTestStart(details); | |
46 results.OnTestFailure(details, ""); | |
47 results.OnTestFinish(details, 0); | |
48 | |
49 results.OnTestStart(details); | |
50 results.OnTestFailure(details, ""); | |
51 results.OnTestFailure(details, ""); | |
52 results.OnTestFailure(details, ""); | |
53 results.OnTestFinish(details, 0); | |
54 | |
55 CHECK_EQUAL (2, results.GetFailedTestCount()); | |
56 } | |
57 | |
58 TEST(NotifiesReporterOfTestStartWithCorrectInfo) | |
59 { | |
60 RecordingReporter reporter; | |
61 TestResults results(&reporter); | |
62 results.OnTestStart(details); | |
63 | |
64 CHECK_EQUAL (1, reporter.testRunCount); | |
65 CHECK_EQUAL ("suitename", reporter.lastStartedSuite); | |
66 CHECK_EQUAL ("testname", reporter.lastStartedTest); | |
67 } | |
68 | |
69 TEST(NotifiesReporterOfTestFailureWithCorrectInfo) | |
70 { | |
71 RecordingReporter reporter; | |
72 TestResults results(&reporter); | |
73 | |
74 results.OnTestFailure(details, "failurestring"); | |
75 CHECK_EQUAL (1, reporter.testFailedCount); | |
76 CHECK_EQUAL ("filename", reporter.lastFailedFile); | |
77 CHECK_EQUAL (123, reporter.lastFailedLine); | |
78 CHECK_EQUAL ("suitename", reporter.lastFailedSuite); | |
79 CHECK_EQUAL ("testname", reporter.lastFailedTest); | |
80 CHECK_EQUAL ("failurestring", reporter.lastFailedMessage); | |
81 } | |
82 | |
83 TEST(NotifiesReporterOfCheckFailureWithCorrectInfo) | |
84 { | |
85 RecordingReporter reporter; | |
86 TestResults results(&reporter); | |
87 | |
88 results.OnTestFailure(details, "failurestring"); | |
89 CHECK_EQUAL (1, reporter.testFailedCount); | |
90 | |
91 CHECK_EQUAL ("filename", reporter.lastFailedFile); | |
92 CHECK_EQUAL (123, reporter.lastFailedLine); | |
93 CHECK_EQUAL ("testname", reporter.lastFailedTest); | |
94 CHECK_EQUAL ("suitename", reporter.lastFailedSuite); | |
95 CHECK_EQUAL ("failurestring", reporter.lastFailedMessage); | |
96 } | |
97 | |
98 TEST(NotifiesReporterOfTestEnd) | |
99 { | |
100 RecordingReporter reporter; | |
101 TestResults results(&reporter); | |
102 | |
103 results.OnTestFinish(details, 0.1234f); | |
104 CHECK_EQUAL (1, reporter.testFinishedCount); | |
105 CHECK_EQUAL ("testname", reporter.lastFinishedTest); | |
106 CHECK_EQUAL ("suitename", reporter.lastFinishedSuite); | |
107 CHECK_CLOSE (0.1234f, reporter.lastFinishedTestTime, 0.0001f); | |
108 } | |
109 | |
110 | |
111 } |