Mercurial > fife-parpg
comparison ext/UnitTest++/src/Test.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 "Config.h" | |
2 #include "Test.h" | |
3 #include "TestList.h" | |
4 #include "TestResults.h" | |
5 #include "AssertException.h" | |
6 #include "MemoryOutStream.h" | |
7 | |
8 #ifdef UNITTEST_POSIX | |
9 #include "Posix/SignalTranslator.h" | |
10 #endif | |
11 | |
12 namespace UnitTest { | |
13 | |
14 TestList& Test::GetTestList() | |
15 { | |
16 static TestList s_list; | |
17 return s_list; | |
18 } | |
19 | |
20 Test::Test(char const* testName, char const* suiteName, char const* filename, int const lineNumber) | |
21 : m_details(testName, suiteName, filename, lineNumber) | |
22 , next(0) | |
23 , m_timeConstraintExempt(false) | |
24 { | |
25 } | |
26 | |
27 Test::~Test() | |
28 { | |
29 } | |
30 | |
31 void Test::Run(TestResults& testResults) const | |
32 { | |
33 try | |
34 { | |
35 #ifdef UNITTEST_POSIX | |
36 UNITTEST_THROW_SIGNALS | |
37 #endif | |
38 RunImpl(testResults); | |
39 } | |
40 catch (AssertException const& e) | |
41 { | |
42 testResults.OnTestFailure( TestDetails(m_details.testName, m_details.suiteName, e.Filename(), e.LineNumber()), e.what()); | |
43 } | |
44 catch (std::exception const& e) | |
45 { | |
46 MemoryOutStream stream; | |
47 stream << "Unhandled exception: " << e.what(); | |
48 testResults.OnTestFailure(m_details, stream.GetText()); | |
49 } | |
50 catch (...) | |
51 { | |
52 testResults.OnTestFailure(m_details, "Unhandled exception: Crash!"); | |
53 } | |
54 } | |
55 | |
56 | |
57 void Test::RunImpl(TestResults&) const | |
58 { | |
59 } | |
60 | |
61 | |
62 } |