|
Revision 418, 1.0 kB
(checked in by vbarta, 16 years ago)
|
|
#27: added UnitTest?++ to bdm sources, changed test_user_data to use it
|
| Line | |
|---|
| 1 | #ifndef UNITTEST_EXECUTE_TEST_H |
|---|
| 2 | #define UNITTEST_EXECUTE_TEST_H |
|---|
| 3 | |
|---|
| 4 | #include "TestDetails.h" |
|---|
| 5 | #include "MemoryOutStream.h" |
|---|
| 6 | #include "AssertException.h" |
|---|
| 7 | #include "CurrentTest.h" |
|---|
| 8 | |
|---|
| 9 | #ifdef UNITTEST_POSIX |
|---|
| 10 | #include "Posix/SignalTranslator.h" |
|---|
| 11 | #endif |
|---|
| 12 | |
|---|
| 13 | namespace UnitTest { |
|---|
| 14 | |
|---|
| 15 | template< typename T > |
|---|
| 16 | void ExecuteTest(T& testObject, TestDetails const& details) |
|---|
| 17 | { |
|---|
| 18 | CurrentTest::Details() = &details; |
|---|
| 19 | |
|---|
| 20 | try |
|---|
| 21 | { |
|---|
| 22 | #ifdef UNITTEST_POSIX |
|---|
| 23 | UNITTEST_THROW_SIGNALS |
|---|
| 24 | #endif |
|---|
| 25 | testObject.RunImpl(); |
|---|
| 26 | } |
|---|
| 27 | catch (AssertException const& e) |
|---|
| 28 | { |
|---|
| 29 | CurrentTest::Results()->OnTestFailure( |
|---|
| 30 | TestDetails(details.testName, details.suiteName, e.Filename(), e.LineNumber()), e.what()); |
|---|
| 31 | } |
|---|
| 32 | catch (std::exception const& e) |
|---|
| 33 | { |
|---|
| 34 | MemoryOutStream stream; |
|---|
| 35 | stream << "Unhandled exception: " << e.what(); |
|---|
| 36 | CurrentTest::Results()->OnTestFailure(details, stream.GetText()); |
|---|
| 37 | } |
|---|
| 38 | catch (...) |
|---|
| 39 | { |
|---|
| 40 | CurrentTest::Results()->OnTestFailure(details, "Unhandled exception: Crash!"); |
|---|
| 41 | } |
|---|
| 42 | } |
|---|
| 43 | |
|---|
| 44 | } |
|---|
| 45 | |
|---|
| 46 | #endif |
|---|