root/library/tests/unittest-cpp/ExecuteTest.h @ 813

Revision 706, 0.9 kB (checked in by smidl, 15 years ago)

eol-native

  • Property svn:eol-style set to native
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
13namespace UnitTest {
14
15template< typename T >
16void ExecuteTest ( T& testObject, TestDetails const& details ) {
17        CurrentTest::Details() = &details;
18
19        try {
20#ifdef UNITTEST_POSIX
21                UNITTEST_THROW_SIGNALS
22#endif
23                testObject.RunImpl();
24        } catch ( AssertException const& e ) {
25                CurrentTest::Results()->OnTestFailure (
26                    TestDetails ( details.testName, details.suiteName, e.Filename(), e.LineNumber() ), e.what() );
27        } catch ( std::exception const& e ) {
28                MemoryOutStream stream;
29                stream << "Unhandled exception: " << e.what();
30                CurrentTest::Results()->OnTestFailure ( details, stream.GetText() );
31        } catch ( ... ) {
32                CurrentTest::Results()->OnTestFailure ( details, "Unhandled exception: Crash!" );
33        }
34}
35
36}
37
38#endif
Note: See TracBrowser for help on using the browser.