Menu

[r197]: / trunk / cppunit / src / cppunit / TestAssert.cpp  Maximize  Restore  History

Download this file

71 lines (55 with data), 1.8 kB

 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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#if HAVE_CMATH
# include <cmath>
#else
# include <math.h>
#endif
#include <cppunit/TestAssert.h>
#include <cppunit/NotEqualException.h>
namespace CppUnit {
#ifdef CPPUNIT_ENABLE_SOURCELINE_DEPRECATED
/// 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 );
}
#else
void
TestAssert::assertDoubleEquals( double expected,
double actual,
double delta,
SourceLine sourceLine )
{
Asserter::failNotEqualIf( fabs( expected - actual ) > delta,
assertion_traits<double>::toString(expected),
assertion_traits<double>::toString(actual),
sourceLine );
}
#endif
}
MongoDB Logo MongoDB