1 #if HAVE_CMATH
2 # include <cmath>
3 #else
4 # include <math.h>
5 #endif
6
7 #include <cppunit/TestAssert.h>
8 #include <cppunit/NotEqualException.h>
9
10
11 namespace CppUnit {
12
13
14 #ifdef CPPUNIT_ENABLE_SOURCELINE_DEPRECATED
15 /// Check for a failed general assertion
16 void
assertImplementation(bool condition,string conditionExpression,long lineNumber,string fileName)17 TestAssert::assertImplementation( bool condition,
18 string conditionExpression,
19 long lineNumber,
20 string fileName )
21 {
22 Asserter::failIf( condition,
23 conditionExpression,
24 SourceLine( fileName, lineNumber ) );
25 }
26
27
28 /// Reports failed equality
29 void
assertNotEqualImplementation(string expected,string actual,long lineNumber,string fileName)30 TestAssert::assertNotEqualImplementation( string expected,
31 string actual,
32 long lineNumber,
33 string fileName )
34 {
35 Asserter::failNotEqual( expected,
36 actual,
37 SouceLine( fileName, lineNumber ), "" );
38 }
39
40
41 /// Check for a failed equality assertion
42 void
assertEquals(double expected,double actual,double delta,long lineNumber,string fileName)43 TestAssert::assertEquals( double expected,
44 double actual,
45 double delta,
46 long lineNumber,
47 string fileName )
48 {
49 if (fabs (expected - actual) > delta)
50 assertNotEqualImplementation( assertion_traits<double>::toString(expected),
51 assertion_traits<double>::toString(actual),
52 lineNumber,
53 fileName );
54 }
55
56 #else // CPPUNIT_ENABLE_SOURCELINE_DEPRECATED
57
58 void
59 TestAssert::assertDoubleEquals( double expected,
60 double actual,
61 double delta,
62 SourceLine sourceLine )
63 {
64 Asserter::failNotEqualIf( fabs( expected - actual ) > delta,
65 assertion_traits<double>::toString(expected),
66 assertion_traits<double>::toString(actual),
67 sourceLine );
68 }
69
70
71 #endif
72
73
74 }
75