1 #include <cppunit/NotEqualException.h>
2
3 namespace CppUnit {
4
5
6 using std::string;
7
NotEqualException(string expected,string actual,SourceLine sourceLine,string additionalMessage)8 NotEqualException::NotEqualException( string expected,
9 string actual,
10 SourceLine sourceLine ,
11 string additionalMessage ) :
12 Exception( "Expected: " + expected +
13 ", but was: " + actual +
14 "." + additionalMessage ,
15 sourceLine),
16 m_expected( expected ),
17 m_actual( actual ),
18 m_additionalMessage( additionalMessage )
19 {
20 }
21
22
23 #ifdef CPPUNIT_ENABLE_SOURCELINE_DEPRECATED
24 /*!
25 * \deprecated Use other constructor instead.
26 */
NotEqualException(string expected,string actual,long lineNumber,string fileName)27 NotEqualException::NotEqualException( string expected,
28 string actual,
29 long lineNumber,
30 string fileName ) :
31 Exception( "Expected: " + expected + ", but was: " + actual,
32 lineNumber,
33 fileName ),
34 m_expected( expected ),
35 m_actual( actual )
36 {
37 }
38 #endif
39
40
NotEqualException(const NotEqualException & other)41 NotEqualException::NotEqualException( const NotEqualException &other ) :
42 Exception( other ),
43 m_expected( other.m_expected ),
44 m_actual( other.m_actual ),
45 m_additionalMessage( other.m_additionalMessage )
46 {
47 }
48
49
~NotEqualException()50 NotEqualException::~NotEqualException() throw()
51 {
52 }
53
54
55 NotEqualException &
operator =(const NotEqualException & other)56 NotEqualException::operator =( const NotEqualException &other )
57 {
58 Exception::operator =( other );
59
60 if ( &other != this )
61 {
62 m_expected = other.m_expected;
63 m_actual = other.m_actual;
64 m_additionalMessage = other.m_additionalMessage;
65 }
66 return *this;
67 }
68
69
70 Exception *
clone() const71 NotEqualException::clone() const
72 {
73 return new NotEqualException( *this );
74 }
75
76
77 bool
isInstanceOf(const Type & exceptionType) const78 NotEqualException::isInstanceOf( const Type &exceptionType ) const
79 {
80 return exceptionType == type() ||
81 Exception::isInstanceOf( exceptionType );
82 }
83
84
85 Exception::Type
type()86 NotEqualException::type()
87 {
88 return Type( "CppUnit::NotEqualException" );
89 }
90
91
92 string
expectedValue() const93 NotEqualException::expectedValue() const
94 {
95 return m_expected;
96 }
97
98
99 string
actualValue() const100 NotEqualException::actualValue() const
101 {
102 return m_actual;
103 }
104
105
106 string
additionalMessage() const107 NotEqualException::additionalMessage() const
108 {
109 return m_additionalMessage;
110 }
111
112
113 } // namespace CppUnit
114