diff options
Diffstat (limited to 'tests/UnitTest++/src/ExecuteTest.h')
-rw-r--r-- | tests/UnitTest++/src/ExecuteTest.h | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/tests/UnitTest++/src/ExecuteTest.h b/tests/UnitTest++/src/ExecuteTest.h new file mode 100644 index 0000000..a00d4c5 --- /dev/null +++ b/tests/UnitTest++/src/ExecuteTest.h @@ -0,0 +1,46 @@ +#ifndef UNITTEST_EXECUTE_TEST_H +#define UNITTEST_EXECUTE_TEST_H + +#include "TestDetails.h" +#include "MemoryOutStream.h" +#include "AssertException.h" +#include "CurrentTest.h" + +#ifdef UNITTEST_POSIX + #include "Posix/SignalTranslator.h" +#endif + +namespace UnitTest { + +template< typename T > +void ExecuteTest(T& testObject, TestDetails const& details) +{ + CurrentTest::Details() = &details; + + try + { +#ifdef UNITTEST_POSIX + UNITTEST_THROW_SIGNALS +#endif + testObject.RunImpl(); + } + catch (AssertException const& e) + { + CurrentTest::Results()->OnTestFailure( + TestDetails(details.testName, details.suiteName, e.Filename(), e.LineNumber()), e.what()); + } + catch (std::exception const& e) + { + MemoryOutStream stream; + stream << "Unhandled exception: " << e.what(); + CurrentTest::Results()->OnTestFailure(details, stream.GetText()); + } + catch (...) + { + CurrentTest::Results()->OnTestFailure(details, "Unhandled exception: Crash!"); + } +} + +} + +#endif |