#include <cmath>
#include <boost/lexical_cast.hpp>
Go to the source code of this file.
|
#define | CHECK(condition) |
|
#define | CHECK_EQUAL(expected, actual) { if ((expected) == (actual)) return; result_.addFailure(Failure(name_, __FILE__, __LINE__, boost::lexical_cast<std::string>(expected), boost::lexical_cast<std::string>(actual))); } |
|
#define | CHECK_EXCEPTION(condition, exception_name) |
|
#define | DOUBLES_EQUAL(expected, actual, threshold) |
|
#define | EQUALITY(expected, actual) |
|
#define | EXPECT(condition) |
|
#define | EXPECT_DOUBLES_EQUAL(expected, actual, threshold) |
|
#define | EXPECT_LONGS_EQUAL(expected, actual) |
|
#define | FAIL(text) { result_.addFailure (Failure (name_, __FILE__, __LINE__,(text))); return; } |
|
#define | FRIEND_TEST(testGroup, testName) friend class testGroup##testName##Test; |
|
#define | LONGS_EQUAL(expected, actual) |
|
#define | TEST(testGroup, testName) |
|
#define | TEST_DISABLED(testGroup, testName) void testGroup##testName##Test(TestResult& result_, const std::string& name_) |
|
#define | TEST_UNSAFE(testGroup, testName) |
|
#define | THROWS_EXCEPTION(condition) |
|
#define CHECK |
( |
|
condition | ) |
|
Value:{ if (!(condition)) \
{ result_.addFailure (
Failure (name_, __FILE__,__LINE__, #condition));
return; } }
Definition at line 109 of file Test.h.
#define CHECK_EQUAL |
( |
|
expected, |
|
|
|
actual |
|
) |
| { if ((expected) == (actual)) return; result_.addFailure(Failure(name_, __FILE__, __LINE__, boost::lexical_cast<std::string>(expected), boost::lexical_cast<std::string>(actual))); } |
#define CHECK_EXCEPTION |
( |
|
condition, |
|
|
|
exception_name |
|
) |
| |
Value:{ try { condition; \
result_.addFailure (
Failure (name_, __FILE__,__LINE__, std::string(
"Didn't throw: ") + boost::lexical_cast<std::string>(#condition)));
\ catch (exception_name&) {} \
catch (...) { \
result_.addFailure (
Failure (name_, __FILE__,__LINE__, std::string(
"Wrong exception: ") + boost::lexical_cast<std::string>(#condition) + boost::lexical_cast<std::string>(
", expected: ") + boost::lexical_cast<std::string>(#exception_name)));
\
Definition at line 119 of file Test.h.
#define DOUBLES_EQUAL |
( |
|
expected, |
|
|
|
actual, |
|
|
|
threshold |
|
) |
| |
Value:{ double actualTemp = actual; \
{ result_.addFailure (
Failure (name_, __FILE__, __LINE__, \
boost::lexical_cast<std::string>((double)expectedTemp), boost::lexical_cast<std::string>((double)actualTemp))); return; } }
Definition at line 142 of file Test.h.
#define EQUALITY |
( |
|
expected, |
|
|
|
actual |
|
) |
| |
Value: result_.addFailure(
Failure(name_, __FILE__, __LINE__, #
expected, #actual)); }
bool assert_equal(const Matrix &expected, const Matrix &actual, double tol)
Definition at line 128 of file Test.h.
#define EXPECT |
( |
|
condition | ) |
|
Value:{ if (!(condition)) \
{ result_.addFailure (
Failure (name_, __FILE__,__LINE__, #condition)); } }
Definition at line 151 of file Test.h.
#define EXPECT_DOUBLES_EQUAL |
( |
|
expected, |
|
|
|
actual, |
|
|
|
threshold |
|
) |
| |
Value:{ double actualTemp = actual; \
{ result_.addFailure (
Failure (name_, __FILE__, __LINE__, \
boost::lexical_cast<std::string>((double)expectedTemp), boost::lexical_cast<std::string>((double)actualTemp))); } }
Definition at line 162 of file Test.h.
#define EXPECT_LONGS_EQUAL |
( |
|
expected, |
|
|
|
actual |
|
) |
| |
Value:{ long actualTemp = actual; \
if ((expectedTemp) != (actualTemp)) \
{ result_.addFailure (
Failure (name_, __FILE__, __LINE__, boost::lexical_cast<std::string>(expectedTemp), \
boost::lexical_cast<std::string>(actualTemp))); } }
Definition at line 155 of file Test.h.
#define FAIL |
( |
|
text | ) |
{ result_.addFailure (Failure (name_, __FILE__, __LINE__,(text))); return; } |
#define FRIEND_TEST |
( |
|
testGroup, |
|
|
|
testName |
|
) |
| friend class testGroup##testName##Test; |
Declare friend in a class to test its private methods
Definition at line 74 of file Test.h.
#define LONGS_EQUAL |
( |
|
expected, |
|
|
|
actual |
|
) |
| |
Value:{ long actualTemp = actual; \
if ((expectedTemp) != (actualTemp)) \
{ result_.addFailure (
Failure (name_, __FILE__, __LINE__, boost::lexical_cast<std::string>(expectedTemp), \
boost::lexical_cast<std::string>(actualTemp))); return; } }
Definition at line 135 of file Test.h.
#define TEST |
( |
|
testGroup, |
|
|
|
testName |
|
) |
| |
Value:class testGroup##testName##
Test :
public Test \
{
public: testGroup##testName##
Test () : Test (#testName
"Test", __FILE__, __LINE__, true) {} \
virtual ~testGroup##testName##
Test () {};\
testGroup##testName##Instance; \
virtual void run(TestResult &result)=0
Test(const std::string &testName)
Normal test will wrap execution in a try/catch block to catch exceptions more effectively
Definition at line 63 of file Test.h.
#define TEST_DISABLED |
( |
|
testGroup, |
|
|
|
testName |
|
) |
| void testGroup##testName##Test(TestResult& result_, const std::string& name_) |
Use this to disable unwanted tests without commenting them out.
Definition at line 92 of file Test.h.
#define TEST_UNSAFE |
( |
|
testGroup, |
|
|
|
testName |
|
) |
| |
Value:class testGroup##testName##
Test :
public Test \
{
public: testGroup##testName##
Test () : Test (#testName
"Test", __FILE__, __LINE__, false) {} \
virtual ~testGroup##testName##
Test () {};\
testGroup##testName##Instance; \
virtual void run(TestResult &result)=0
Test(const std::string &testName)
For debugging only: use TEST_UNSAFE to allow debuggers to have access to exceptions, as this will not wrap execution with a try/catch block
Definition at line 81 of file Test.h.
#define THROWS_EXCEPTION |
( |
|
condition | ) |
|
Value:{ try { condition; \
result_.addFailure (
Failure (name_, __FILE__,__LINE__, std::string(
"Didn't throw: ") + boost::lexical_cast<std::string>(#condition)));
\ catch (...) {} }
Definition at line 113 of file Test.h.