Classes | Macros
Test.h File Reference
#include <cmath>
#include <boost/lexical_cast.hpp>
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__, 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)
 

Macro Definition Documentation

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

Definition at line 132 of file Test.h.

#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))); \
return; } \
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))); \
return; } }
if n return

Definition at line 119 of file Test.h.

#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__, \
boost::lexical_cast<std::string>((double)expectedTemp), boost::lexical_cast<std::string>((double)actualTemp))); return; } }
Matrix expected
Definition: testMatrix.cpp:974
if((m *x).isApprox(y))
#define isfinite(X)
Definition: main.h:74
Real fabs(const Real &a)

Definition at line 142 of file Test.h.

#define EQUALITY (   expected,
  actual 
)
Value:
{ if (!assert_equal(expected,actual)) \
result_.addFailure(Failure(name_, __FILE__, __LINE__, #expected, #actual)); }
Matrix expected
Definition: testMatrix.cpp:974
bool assert_equal(const Matrix &expected, const Matrix &actual, double tol)
Definition: Matrix.cpp:42

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; \
double expectedTemp = expected; \
if (!std::isfinite(actualTemp) || !std::isfinite(expectedTemp) || fabs ((expectedTemp)-(actualTemp)) > threshold) \
{ result_.addFailure (Failure (name_, __FILE__, __LINE__, \
boost::lexical_cast<std::string>((double)expectedTemp), boost::lexical_cast<std::string>((double)actualTemp))); } }
Matrix expected
Definition: testMatrix.cpp:974
if((m *x).isApprox(y))
#define isfinite(X)
Definition: main.h:74
Real fabs(const Real &a)

Definition at line 162 of file Test.h.

#define EXPECT_LONGS_EQUAL (   expected,
  actual 
)
Value:
{ long actualTemp = actual; \
long expectedTemp = expected; \
if ((expectedTemp) != (actualTemp)) \
{ result_.addFailure (Failure (name_, __FILE__, __LINE__, boost::lexical_cast<std::string>(expectedTemp), \
boost::lexical_cast<std::string>(actualTemp))); } }
Matrix expected
Definition: testMatrix.cpp:974
if((m *x).isApprox(y))

Definition at line 155 of file Test.h.

#define FAIL (   text)    { result_.addFailure (Failure (name_, __FILE__, __LINE__,(text))); return; }

Definition at line 170 of file Test.h.

#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; \
long expectedTemp = expected; \
if ((expectedTemp) != (actualTemp)) \
{ result_.addFailure (Failure (name_, __FILE__, __LINE__, boost::lexical_cast<std::string>(expectedTemp), \
boost::lexical_cast<std::string>(actualTemp))); return; } }
Matrix expected
Definition: testMatrix.cpp:974
if((m *x).isApprox(y))

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 () {};\
void run (TestResult& result_) override;} \
testGroup##testName##Instance; \
void testGroup##testName##Test::run (TestResult& result_)
Definition: Test.h:30
virtual void run(TestResult &result)=0
Test(const std::string &testName)
Definition: Test.cpp:20

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 () {};\
void run (TestResult& result_) override;} \
testGroup##testName##Instance; \
void testGroup##testName##Test::run (TestResult& result_)
Definition: Test.h:30
virtual void run(TestResult &result)=0
Test(const std::string &testName)
Definition: Test.cpp:20

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))); \
return; } \
catch (...) {} }
if n return

Definition at line 113 of file Test.h.



gtsam
Author(s):
autogenerated on Sat May 8 2021 02:51:40