18#ifndef _CPPUNITMPFR_H_
19#define _CPPUNITMPFR_H_
22# define CPPUNIT_NS CppUnitMini
36 virtual void error(
const char * ,
const char * ,
const char * ,
int ) {}
38 virtual void progress(
const char * ,
const char * ,
bool ,
bool ) {}
58 void setUp() { m_failed =
false; }
59 static int run(
Reporter *in_reporter = 0,
const char *in_testName =
"",
bool invert =
false);
61 static void registerTestCase(
TestCase *in_testCase);
63 virtual void myRun(
const char * ,
bool =
false) {}
65 virtual void error(
const char *in_macroName,
const char *in_macro,
const char *in_file,
int in_line) {
68 m_reporter->error(in_macroName, in_macro, in_file, in_line);
74 m_reporter->message(
msg);
78 bool equalDoubles(
double in_expected,
double in_real,
double in_maxErr) {
79 double diff = in_expected - in_real;
83 return diff < in_maxErr;
86 virtual void progress(
const char *in_className,
const char *in_functionName,
bool ignored,
bool explicitTest) {
89 m_reporter->progress(in_className, in_functionName,
ignored, explicitTest);
93 bool shouldRunThis(
const char *in_desiredTest,
const char *in_className,
const char *in_functionName,
94 bool invert,
bool explicit_test,
bool &do_progress) {
95 if ((in_desiredTest) && (in_desiredTest[0] !=
'\0')) {
97 const char *
ptr =
strstr(in_desiredTest,
"::");
105 bool match = (
strcmp(in_desiredTest, in_className) == 0);
110 return !explicit_test;
134#if !defined (CPPUNIT_MINI_HIDE_UNUSED_VARIABLE)
135# if defined (_MSC_VER)
136# define CPPUNIT_MINI_HIDE_UNUSED_VARIABLE(v) (v);
138# define CPPUNIT_MINI_HIDE_UNUSED_VARIABLE(v)
142#define CPPUNIT_TEST_SUITE(X) \
143 typedef CPPUNIT_NS::TestCase Base; \
144 virtual void myRun(const char *in_name, bool invert = false) { \
145 const char *className = #X; CPPUNIT_MINI_HIDE_UNUSED_VARIABLE(className) \
146 bool ignoring = false; CPPUNIT_MINI_HIDE_UNUSED_VARIABLE(ignoring)
148#if defined CPPUNIT_MINI_USE_EXCEPTIONS
149# define CPPUNIT_TEST_BASE(X, Y) \
152 bool shouldRun = shouldRunThis(in_name, className, #X, invert, Y, do_progress); \
153 if (shouldRun || do_progress) { \
155 progress(className, #X, ignoring || !shouldRun, !ignoring && Y); \
156 if (shouldRun && !ignoring) { \
161 Base::error("Test Failed: An Exception was thrown.", #X, __FILE__, __LINE__); \
168# define CPPUNIT_TEST_BASE(X, Y) \
171 bool shouldRun = shouldRunThis(in_name, className, #X, invert, Y, do_progress); \
172 if (shouldRun || do_progress) { \
174 progress(className, #X, ignoring || !shouldRun, !ignoring && Y); \
175 if (shouldRun && !ignoring) \
182#define CPPUNIT_TEST(X) CPPUNIT_TEST_BASE(X, false)
183#define CPPUNIT_EXPLICIT_TEST(X) CPPUNIT_TEST_BASE(X, true)
185#define CPPUNIT_IGNORE \
188#define CPPUNIT_STOP_IGNORE \
191#define CPPUNIT_TEST_SUITE_END() }
193#define CPPUNIT_TEST_SUITE_REGISTRATION(X) static X local
195#define CPPUNIT_CHECK(X) \
197 Base::error("CPPUNIT_CHECK", #X, __FILE__, __LINE__); \
200#define CPPUNIT_ASSERT(X) \
202 Base::error("CPPUNIT_ASSERT", #X, __FILE__, __LINE__); \
206#define CPPUNIT_FAIL { \
207 Base::error("CPPUNIT_FAIL", "", __FILE__, __LINE__); \
211#define CPPUNIT_ASSERT_EQUAL(X, Y) \
213 Base::error("CPPUNIT_ASSERT_EQUAL", #X","#Y, __FILE__, __LINE__); \
217#define CPPUNIT_ASSERT_DOUBLES_EQUAL(X, Y, Z) \
218 if (!equalDoubles((X), (Y), (Z))) { \
219 Base::error("CPPUNIT_ASSERT_DOUBLES_EQUAL", #X","#Y","#Z, __FILE__, __LINE__); \
223#define CPPUNIT_MESSAGE(m) CPPUNIT_NS::TestCase::message(m)
int strcmp(const char *String1, const char *String2)
char * strstr(char *String1, char *String2)
ACPI_SIZE strlen(const char *String)
int strncmp(const char *String1, const char *String2, ACPI_SIZE Count)
virtual void error(const char *, const char *, const char *, int)
virtual void printSummary()
virtual void message(const char *)
virtual void progress(const char *, const char *, bool, bool)
static void message(const char *msg)
bool equalDoubles(double in_expected, double in_real, double in_maxErr)
static Reporter * m_reporter
virtual void error(const char *in_macroName, const char *in_macro, const char *in_file, int in_line)
void setUp()
Set up context before running a test.
virtual void progress(const char *in_className, const char *in_functionName, bool ignored, bool explicitTest)
bool shouldRunThis(const char *in_desiredTest, const char *in_className, const char *in_functionName, bool invert, bool explicit_test, bool &do_progress)
void tearDown()
Clean up after the test run.
virtual void myRun(const char *, bool=false)
virtual void setUp()
Set up context before running a test.
virtual void tearDown()
Clean up after the test run.