summaryrefslogtreecommitdiff
path: root/examples/cppunittest/TestFailureTest.cpp
blob: c6b5736f3a6177c5ef1f099d9209e5b577e9ec03 (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
50
51
52
53
54
55
56
#include "TestFailureTest.h"
#include <cppunit/TestFailure.h>
#include <cppunit/Exception.h>


CPPUNIT_TEST_SUITE_REGISTRATION( TestFailureTest );


TestFailureTest::TestFailureTest()
{
}


TestFailureTest::~TestFailureTest()
{
}


void 
TestFailureTest::setUp()
{
  m_exceptionDestroyed = false;
}


void 
TestFailureTest::tearDown()
{
}


void 
TestFailureTest::testConstructorAndGetters()
{
  CppUnit::TestCase test;
  CppUnit::Exception *error = new ObservedException( this );
  checkTestFailure( &test, error );
  CPPUNIT_ASSERT( m_exceptionDestroyed );
}


void 
TestFailureTest::exceptionDestroyed()
{
  m_exceptionDestroyed = true;
}


void 
TestFailureTest::checkTestFailure( CppUnit::Test *test, 
                                   CppUnit::Exception *error )
{
  CppUnit::TestFailure failure( test, error );
  CPPUNIT_ASSERT_EQUAL( test, failure.failedTest() );
  CPPUNIT_ASSERT_EQUAL( error, failure.thrownException() );
}