xref: /haiku/src/tools/cppunit/cppunit/Asserter.cpp (revision 58481f0f6ef1a61ba07283f012cafbc2ed874ead)
1 #include <cppunit/Asserter.h>
2 #include <cppunit/NotEqualException.h>
3 
4 
5 using std::string;
6 
7 namespace CppUnit
8 {
9 
10 
11 namespace Asserter
12 {
13 
14 
15 void
fail(string message,SourceLine sourceLine)16 fail( string message,
17       SourceLine sourceLine )
18 {
19   throw Exception( message, sourceLine );
20 }
21 
22 
23 void
failIf(bool shouldFail,string message,SourceLine location)24 failIf( bool shouldFail,
25         string message,
26         SourceLine location )
27 {
28   if ( shouldFail )
29     fail( message, location );
30 }
31 
32 
33 void
failNotEqual(string expected,string actual,SourceLine sourceLine,string additionalMessage)34 failNotEqual( string expected,
35               string actual,
36               SourceLine sourceLine,
37               string additionalMessage )
38 {
39   throw NotEqualException( expected,
40                            actual,
41                            sourceLine,
42                            additionalMessage );
43 }
44 
45 
46 void
failNotEqualIf(bool shouldFail,string expected,string actual,SourceLine sourceLine,string additionalMessage)47 failNotEqualIf( bool shouldFail,
48                 string expected,
49                 string actual,
50                 SourceLine sourceLine,
51                 string additionalMessage )
52 {
53   if ( shouldFail )
54     failNotEqual( expected, actual, sourceLine, additionalMessage );
55 }
56 
57 
58 } // namespace Asserter
59 } // namespace CppUnit
60