1 |
#ifndef CPPUNIT_TESTFAILURE_H |
2 |
#define CPPUNIT_TESTFAILURE_H |
3 |
|
4 |
#include "CppUnitTest/Guards.h" |
5 |
#include "CppUnitTest/CppUnitException.h" |
6 |
#include "CppUnitTest/Test.h" |
7 |
|
8 |
#include "CppUnitTest/CppUnitTestNamespace.h" |
9 |
BEGIN_NAMESPACE_CPPUNITTEST |
10 |
|
11 |
/* |
12 |
* A TestFailure collects a failed test together with |
13 |
* the caught exception. |
14 |
* |
15 |
* TestFailure assumes lifetime control for any exception |
16 |
* passed to it. The lifetime of tests is handled by |
17 |
* their TestSuite (if they have been added to one) or |
18 |
* whomever creates them. |
19 |
* |
20 |
* see TestResult |
21 |
* see TestSuite |
22 |
* |
23 |
*/ |
24 |
|
25 |
class TestFailure |
26 |
{ |
27 |
REFERENCEOBJECT (TestFailure) |
28 |
|
29 |
public: |
30 |
TestFailure (Test *failedTest, CppUnitException *thrownException); |
31 |
~TestFailure (); |
32 |
|
33 |
Test *failedTest (); |
34 |
CppUnitException *thrownException (); |
35 |
std::string toString (); |
36 |
|
37 |
protected: |
38 |
Test *m_failedTest; |
39 |
CppUnitException *m_thrownException; |
40 |
|
41 |
}; |
42 |
|
43 |
|
44 |
// Constructs a TestFailure with the given test and exception. |
45 |
inline TestFailure::TestFailure (Test *failedTest, CppUnitException *thrownException) |
46 |
: m_failedTest (failedTest), m_thrownException (thrownException) |
47 |
{} |
48 |
|
49 |
|
50 |
// Deletes the owned exception. |
51 |
inline TestFailure::~TestFailure () |
52 |
{ delete m_thrownException; } |
53 |
|
54 |
|
55 |
// Gets the failed test. |
56 |
inline Test *TestFailure::failedTest () |
57 |
{ return m_failedTest; } |
58 |
|
59 |
|
60 |
// Gets the thrown exception. |
61 |
inline CppUnitException *TestFailure::thrownException () |
62 |
{ return m_thrownException; } |
63 |
|
64 |
END_NAMESPACE_CPPUNITTEST |
65 |
|
66 |
#endif |
67 |
|
68 |
|