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
71
72
73
74
75
76
77
78
|
#ifndef CPPUNIT_TESTASSERT_H
#define CPPUNIT_TESTASSERT_H
#include <string>
#include <cppunit/Exception.h>
namespace CppUnit {
/*! \brief This class represents
*/
class TestAssert
{
public:
virtual ~TestAssert() {}
static void assertImplementation(
bool condition,
std::string conditionExpression = "",
long lineNumber = Exception::UNKNOWNLINENUMBER,
std::string fileName = Exception::UNKNOWNFILENAME);
static void assertEquals (long expected,
long actual,
long lineNumber = Exception::UNKNOWNLINENUMBER,
std::string fileName = Exception::UNKNOWNFILENAME);
static void assertEquals (double expected,
double actual,
double delta,
long lineNumber = Exception::UNKNOWNLINENUMBER,
std::string fileName = Exception::UNKNOWNFILENAME);
static std::string notEqualsMessage (long expected,
long actual);
static std::string notEqualsMessage (double expected,
double actual);
};
/** A set of macros which allow us to get the line number
* and file name at the point of an error.
* Just goes to show that preprocessors do have some
* redeeming qualities.
*/
#define CPPUNIT_SOURCEANNOTATION
#ifdef CPPUNIT_SOURCEANNOTATION
#undef assert
#define assert(condition)\
(CppUnit::TestAssert::assertImplementation ((condition),(#condition),\
__LINE__, __FILE__))
#else
#undef assert
#define assert(condition)\
(CppUnit::TestAssert::assertImplementation ((condition),"",\
__LINE__, __FILE__))
#endif
/// Macro for primitive value comparisons
#define assertDoublesEqual(expected,actual,delta)\
(CppUnit::TestAssert::assertEquals ((expected),\
(actual),(delta),__LINE__,__FILE__))
/// Macro for primitive value comparisons
#define assertLongsEqual(expected,actual)\
(CppUnit::TestAssert::assertEquals ((expected),\
(actual),__LINE__,__FILE__))
} // namespace CppUnit
#endif // CPPUNIT_TESTASSERT_H
|