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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
|
#include "CoreSuite.h"
#include "ExceptionTest.h"
#include <cppunit/portability/SmartPtr.h>
#include <cppunit/Exception.h>
CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( ExceptionTest,
coreSuiteName() );
ExceptionTest::ExceptionTest()
{
}
ExceptionTest::~ExceptionTest()
{
}
void
ExceptionTest::setUp()
{
}
void
ExceptionTest::tearDown()
{
}
void
ExceptionTest::testConstructor()
{
const CPPUNIT_NS::Message message( "a message" );
const CPPUNIT_NS::SourceLine sourceLine( "dir/afile.cpp", 17 );
CPPUNIT_NS::Exception e( message, sourceLine );
CPPUNIT_ASSERT_EQUAL( message.shortDescription(), e.message().shortDescription() );
CPPUNIT_ASSERT( sourceLine == e.sourceLine() );
}
void
ExceptionTest::testDefaultConstructor()
{
CPPUNIT_NS::Exception e;
CPPUNIT_ASSERT( CPPUNIT_NS::Message() == e.message() );
CPPUNIT_ASSERT( !e.sourceLine().isValid() );
}
void
ExceptionTest::testCopyConstructor()
{
CPPUNIT_NS::SourceLine sourceLine( "fileName.cpp", 123 );
CPPUNIT_NS::Exception e( CPPUNIT_NS::Message("message"), sourceLine );
CPPUNIT_NS::Exception other( e );
checkIsSame( e, other );
}
void
ExceptionTest::testAssignment()
{
CPPUNIT_NS::SourceLine sourceLine( "fileName.cpp", 123 );
CPPUNIT_NS::Exception e( CPPUNIT_NS::Message("message"), sourceLine );
CPPUNIT_NS::Exception other;
other = e;
checkIsSame( e, other );
}
void
ExceptionTest::testClone()
{
CPPUNIT_NS::SourceLine sourceLine( "fileName.cpp", 123 );
CPPUNIT_NS::Exception e( CPPUNIT_NS::Message("message"), sourceLine );
CppUnitSmartPtr<CPPUNIT_NS::Exception> other( e.clone() );
checkIsSame( e, *other.get() );
}
void
ExceptionTest::checkIsSame( CPPUNIT_NS::Exception &e,
CPPUNIT_NS::Exception &other )
{
std::string eWhat( e.what() );
std::string otherWhat( other.what() );
CPPUNIT_ASSERT_EQUAL( eWhat, otherWhat );
CPPUNIT_ASSERT( e.sourceLine() == other.sourceLine() );
}
|