Mercurial > fife-parpg
comparison ext/UnitTest++/src/tests/TestTest.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 "../TestReporter.h" | |
3 #include "../TimeHelpers.h" | |
4 | |
5 using namespace UnitTest; | |
6 | |
7 namespace { | |
8 | |
9 TEST (PassingTestHasNoFailures) | |
10 { | |
11 class PassingTest : public Test | |
12 { | |
13 public: | |
14 PassingTest() : Test("passing") {} | |
15 virtual void RunImpl(TestResults& testResults_) const | |
16 { | |
17 CHECK(true); | |
18 } | |
19 }; | |
20 | |
21 TestResults results; | |
22 PassingTest().Run(results); | |
23 CHECK_EQUAL(0, results.GetFailureCount()); | |
24 } | |
25 | |
26 | |
27 TEST (FailingTestHasFailures) | |
28 { | |
29 class FailingTest : public Test | |
30 { | |
31 public: | |
32 FailingTest() : Test("failing") {} | |
33 virtual void RunImpl(TestResults& testResults_) const | |
34 { | |
35 CHECK(false); | |
36 } | |
37 }; | |
38 | |
39 TestResults results; | |
40 FailingTest().Run(results); | |
41 CHECK_EQUAL(1, results.GetFailureCount()); | |
42 } | |
43 | |
44 | |
45 TEST (ThrowingTestsAreReportedAsFailures) | |
46 { | |
47 class CrashingTest : public Test | |
48 { | |
49 public: | |
50 CrashingTest() : Test("throwing") {} | |
51 virtual void RunImpl(TestResults&) const | |
52 { | |
53 throw "Blah"; | |
54 } | |
55 }; | |
56 | |
57 TestResults results; | |
58 CrashingTest().Run(results); | |
59 CHECK_EQUAL(1, results.GetFailureCount()); | |
60 } | |
61 | |
62 | |
63 #ifndef UNITTEST_MINGW | |
64 TEST (CrashingTestsAreReportedAsFailures) | |
65 { | |
66 class CrashingTest : public Test | |
67 { | |
68 public: | |
69 CrashingTest() : Test("crashing") {} | |
70 virtual void RunImpl(TestResults&) const | |
71 { | |
72 reinterpret_cast< void (*)() >(0)(); | |
73 } | |
74 }; | |
75 | |
76 TestResults results; | |
77 CrashingTest().Run(results); | |
78 CHECK_EQUAL(1, results.GetFailureCount()); | |
79 } | |
80 #endif | |
81 | |
82 TEST (TestWithUnspecifiedSuiteGetsDefaultSuite) | |
83 { | |
84 Test test("test"); | |
85 CHECK(test.m_details.suiteName != NULL); | |
86 CHECK_EQUAL("DefaultSuite", test.m_details.suiteName); | |
87 } | |
88 | |
89 TEST (TestReflectsSpecifiedSuiteName) | |
90 { | |
91 Test test("test", "testSuite"); | |
92 CHECK(test.m_details.suiteName != NULL); | |
93 CHECK_EQUAL("testSuite", test.m_details.suiteName); | |
94 } | |
95 | |
96 | |
97 } |