1 #include "CoreSuite.h"
2 #include "TestFailureTest.h"
3 #include <cppunit/TestFailure.h>
4 #include <cppunit/Exception.h>
5
6
7 CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( TestFailureTest,
8 coreSuiteName() );
9
10
TestFailureTest()11 TestFailureTest::TestFailureTest()
12 {
13 }
14
15
~TestFailureTest()16 TestFailureTest::~TestFailureTest()
17 {
18 }
19
20
21 void
setUp()22 TestFailureTest::setUp()
23 {
24 m_exceptionDestroyed = false;
25 }
26
27
28 void
tearDown()29 TestFailureTest::tearDown()
30 {
31 }
32
33
34 void
testConstructorAndGetters()35 TestFailureTest::testConstructorAndGetters()
36 {
37 CPPUNIT_NS::TestCase test;
38 CPPUNIT_NS::Exception *error = new ObservedException( this );
39 checkTestFailure( &test, error, false );
40 CPPUNIT_ASSERT( m_exceptionDestroyed );
41 }
42
43
44 void
testConstructorAndGettersForError()45 TestFailureTest::testConstructorAndGettersForError()
46 {
47 CPPUNIT_NS::TestCase test;
48 CPPUNIT_NS::Exception *error = new ObservedException( this );
49 checkTestFailure( &test, error, true );
50 CPPUNIT_ASSERT( m_exceptionDestroyed );
51 }
52
53
54 void
exceptionDestroyed()55 TestFailureTest::exceptionDestroyed()
56 {
57 m_exceptionDestroyed = true;
58 }
59
60
61 void
checkTestFailure(CPPUNIT_NS::Test * test,CPPUNIT_NS::Exception * error,bool isError)62 TestFailureTest::checkTestFailure( CPPUNIT_NS::Test *test,
63 CPPUNIT_NS::Exception *error,
64 bool isError )
65 {
66 CPPUNIT_NS::TestFailure failure( test, error, isError );
67 CPPUNIT_ASSERT_EQUAL( test, failure.failedTest() );
68 CPPUNIT_ASSERT_EQUAL( error, failure.thrownException() );
69 CPPUNIT_ASSERT_EQUAL( isError, failure.isError() );
70 }
71