#include <cmath>
#include <string>
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__, std::to_string(expected), std::to_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) |
|
◆ CHECK
#define CHECK |
( |
|
condition | ) |
|
Value:{ if (!(condition)) \
{ result_.addFailure (
Failure (name_, __FILE__,__LINE__, #condition));
return; } }
Definition at line 108 of file Test.h.
◆ CHECK_EQUAL
#define CHECK_EQUAL |
( |
|
expected, |
|
|
|
actual |
|
) |
| { if ((expected) == (actual)) return; result_.addFailure(Failure(name_, __FILE__, __LINE__, std::to_string(expected), std::to_string(actual))); } |
◆ CHECK_EXCEPTION
#define CHECK_EXCEPTION |
( |
|
condition, |
|
|
|
exception_name |
|
) |
| |
Value:{ try { condition; \
result_.addFailure (
Failure (name_, __FILE__,__LINE__, std::string(
"Didn't throw: ") + std::string(#condition))); \
return; } \
catch (exception_name&) {} \
catch (...) { \
result_.addFailure (
Failure (name_, __FILE__,__LINE__, std::string(
"Wrong exception: ") + std::string(#condition) + std::string(
", expected: ") + std::string(#exception_name))); \
return; } }
Definition at line 118 of file Test.h.
◆ DOUBLES_EQUAL
#define DOUBLES_EQUAL |
( |
|
expected, |
|
|
|
actual, |
|
|
|
threshold |
|
) |
| |
Value:{ double actualTemp = actual; \
{ result_.addFailure (
Failure (name_, __FILE__, __LINE__, \
std::to_string((double)expectedTemp), std::to_string((double)actualTemp))); return; } }
Definition at line 141 of file Test.h.
◆ EQUALITY
#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 127 of file Test.h.
◆ EXPECT
#define EXPECT |
( |
|
condition | ) |
|
Value:{ if (!(condition)) \
{ result_.addFailure (
Failure (name_, __FILE__,__LINE__, #condition)); } }
Definition at line 150 of file Test.h.
◆ EXPECT_DOUBLES_EQUAL
#define EXPECT_DOUBLES_EQUAL |
( |
|
expected, |
|
|
|
actual, |
|
|
|
threshold |
|
) |
| |
Value:{ double actualTemp = actual; \
{ result_.addFailure (
Failure (name_, __FILE__, __LINE__, \
std::to_string((double)expectedTemp), std::to_string((double)actualTemp))); } }
Definition at line 161 of file Test.h.
◆ EXPECT_LONGS_EQUAL
#define EXPECT_LONGS_EQUAL |
( |
|
expected, |
|
|
|
actual |
|
) |
| |
Value:{ long actualTemp = actual; \
if ((expectedTemp) != (actualTemp)) \
{ result_.addFailure (
Failure (name_, __FILE__, __LINE__, std::to_string(expectedTemp), \
std::to_string(actualTemp))); } }
Definition at line 154 of file Test.h.
◆ FAIL
#define FAIL |
( |
|
text | ) |
{ result_.addFailure (Failure (name_, __FILE__, __LINE__,(text))); return; } |
◆ FRIEND_TEST
#define FRIEND_TEST |
( |
|
testGroup, |
|
|
|
testName |
|
) |
| friend class testGroup##testName##Test; |
Declare friend in a class to test its private methods
Definition at line 73 of file Test.h.
◆ LONGS_EQUAL
#define LONGS_EQUAL |
( |
|
expected, |
|
|
|
actual |
|
) |
| |
Value:{ long actualTemp = actual; \
if ((expectedTemp) != (actualTemp)) \
{ result_.addFailure (
Failure (name_, __FILE__, __LINE__, std::to_string(expectedTemp), \
std::to_string(actualTemp))); return; } }
Definition at line 134 of file Test.h.
◆ TEST
#define TEST |
( |
|
testGroup, |
|
|
|
testName |
|
) |
| |
Value:class testGroup##testName##
Test :
public Test \
{
public: testGroup##testName##
Test () : Test (#testName
"Test", __FILE__, __LINE__, true) {} \
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.
◆ TEST_DISABLED
#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 91 of file Test.h.
◆ TEST_UNSAFE
#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 80 of file Test.h.
◆ THROWS_EXCEPTION
#define THROWS_EXCEPTION |
( |
|
condition | ) |
|
Value:{ try { condition; \
result_.addFailure (
Failure (name_, __FILE__,__LINE__, std::string(
"Didn't throw: ") + std::string(#condition))); \
return; } \
catch (...) {} }
Definition at line 112 of file Test.h.