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
|
#if HAVE_CMATH
# include <cmath>
#else
# include <math.h>
#endif
#include <cppunit/TestAssert.h>
#include <cppunit/NotEqualException.h>
namespace CppUnit {
/// Check for a failed general assertion
void TestAssert::assertImplementation (bool condition,
std::string conditionExpression,
long lineNumber,
std::string fileName)
{
if (!condition)
throw Exception (conditionExpression,
lineNumber,
fileName);
}
/// Reports failed equality
void TestAssert::assertNotEqualImplementation( std::string expected,
std::string actual,
long lineNumber,
std::string fileName )
{
throw NotEqualException( expected, actual, lineNumber, fileName );
}
/// Check for a failed equality assertion
void TestAssert::assertEquals (double expected,
double actual,
double delta,
long lineNumber,
std::string fileName)
{
if (fabs (expected - actual) > delta)
assertNotEqualImplementation( assertion_traits<double>::toString(expected),
assertion_traits<double>::toString(actual),
lineNumber,
fileName );
}
}
|