Classes | Macros
Test.h File Reference
#include <cmath>
#include <string>
Include dependency graph for Test.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  Test
 

Macros

#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)
 

Macro Definition Documentation

◆ 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))); }

Definition at line 131 of file Test.h.

◆ 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; \
double expectedTemp = expected; \
if (!std::isfinite(actualTemp) || !std::isfinite(expectedTemp) || fabs ((expectedTemp)-(actualTemp)) > threshold) \
{ 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:
{ if (!assert_equal(expected,actual)) \
result_.addFailure(Failure(name_, __FILE__, __LINE__, #expected, #actual)); }

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; \
double expectedTemp = expected; \
if (!std::isfinite(actualTemp) || !std::isfinite(expectedTemp) || fabs ((expectedTemp)-(actualTemp)) > threshold) \
{ 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; \
long expectedTemp = expected; \
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; }

Definition at line 169 of file Test.h.

◆ 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; \
long expectedTemp = expected; \
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) {} \
void run (TestResult& result_) override;} \
testGroup##testName##Instance; \
void testGroup##testName##Test::run (TestResult& result_)

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 () {} \
void run (TestResult& result_) override;} \
testGroup##testName##Instance; \
void testGroup##testName##Test::run (TestResult& result_)

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.

boost::multiprecision::fabs
Real fabs(const Real &a)
Definition: boostmultiprec.cpp:119
Failure
Definition: Failure.h:28
cholesky::expected
Matrix expected
Definition: testMatrix.cpp:971
isfinite
#define isfinite(X)
Definition: main.h:95
TestResult
Definition: TestResult.h:26
gtsam::assert_equal
bool assert_equal(const Matrix &expected, const Matrix &actual, double tol)
Definition: Matrix.cpp:40
Test
Definition: Test.h:30
Test::Test
Test(const std::string &testName)
Definition: Test.cpp:18
Test::run
virtual void run(TestResult &result)=0


gtsam
Author(s):
autogenerated on Fri Nov 1 2024 03:43:24