aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/libraries/ode-0.9/tests/CppTestHarness/Test.cpp
blob: 44b2dd8c2d5d90f9640b8ed0130ed7f45693e2c7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#include "Test.h"
#include "TestResults.h"

#ifdef TRANSLATE_POSIX_SIGNALS
	#include "SignalTranslator.h"
#endif

namespace CppTestHarness
{

Test::Test(std::string const testName, std::string const filename, int const lineNumber)
	: m_testName(testName)
	, m_filename(filename)
	, m_lineNumber(lineNumber)
{
}

Test::~Test()
{
}

void Test::Run(TestResults& testResults)
{
	try
	{
#ifdef TRANSLATE_POSIX_SIGNALS
		//add any signals you want translated into system exceptions here
		SignalTranslator<SIGSEGV> sigSEGV;
		SignalTranslator<SIGFPE> sigFPE;
		SignalTranslator<SIGBUS> sigBUS;
#endif
		RunImpl(testResults);
	}
	catch (std::exception const& e)
	{
		std::string msg = "Unhandled exception: ";
		msg += e.what();
		testResults.ReportFailure(m_filename.c_str(), m_lineNumber, msg);
	}
	catch (...)
	{
		testResults.ReportFailure(m_filename.c_str(), m_lineNumber, "Unhandled exception: crash!");
	}


	testResults.ReportDone(m_testName);
}
}