1
#include <cppunit/Asserter.h>
2
#include <cppunit/Exception.h>
3
#include <cppunit/Message.h>
10
Asserter::fail( std::string message,
11
const SourceLine &sourceLine )
13
fail( Message( "assertion failed", message ), sourceLine );
18
Asserter::fail( const Message &message,
19
const SourceLine &sourceLine )
21
throw Exception( message, sourceLine );
26
Asserter::failIf( bool shouldFail,
27
const Message &message,
28
const SourceLine &sourceLine )
31
fail( message, sourceLine );
36
Asserter::failIf( bool shouldFail,
38
const SourceLine &sourceLine )
40
failIf( shouldFail, Message( "assertion failed", message ), sourceLine );
45
Asserter::makeExpected( const std::string &expectedValue )
47
return "Expected: " + expectedValue;
52
Asserter::makeActual( const std::string &actualValue )
54
return "Actual : " + actualValue;
59
Asserter::makeNotEqualMessage( const std::string &expectedValue,
60
const std::string &actualValue,
61
const AdditionalMessage &additionalMessage,
62
const std::string &shortDescription )
64
Message message( shortDescription,
65
makeExpected( expectedValue ),
66
makeActual( actualValue ) );
67
message.addDetail( additionalMessage );
74
Asserter::failNotEqual( std::string expected,
76
const SourceLine &sourceLine,
77
const AdditionalMessage &additionalMessage,
78
std::string shortDescription )
80
fail( makeNotEqualMessage( expected,
89
Asserter::failNotEqualIf( bool shouldFail,
92
const SourceLine &sourceLine,
93
const AdditionalMessage &additionalMessage,
94
std::string shortDescription )
97
failNotEqual( expected, actual, sourceLine, additionalMessage, shortDescription );