tfel
Loading...
Searching...
No Matches
TestCase.hxx File Reference
#include <string>
#include <stdexcept>
#include <string_view>
#include "TFEL/Config/TFELConfig.hxx"
#include "TFEL/Raise.hxx"
#include "TFEL/Macros.hxx"
#include "TFEL/Tests/Test.hxx"
#include "TFEL/Tests/TestResult.hxx"

Classes

struct  tfel::tests::TestAssertionFailure
 exception thrown by TFEL_TESTS_ASSERT when an assertion fails. It holds the results registered by the test before the failure. More...
struct  tfel::tests::TestCase
 class used to describe an single test More...

Namespaces

namespace  tfel
 the namespace tfel encloses all the TFEL project. This namespace is empty.

Macros

#define TFEL_TESTS_STATIC_ASSERT(X)
 an helper macro to ease the use of TestCase::registerResult
#define TFEL_TESTS_ASSERT(X)
 an helper macro to ease the use of TestCase::registerResult
#define TFEL_TESTS_CHECK_THROW(X, Y)
 an helper macro to ease the use of TestCase::registerResult
#define TFEL_TESTS_CALLMETHOD(X)
 an helper macro to ease the use of TestCase::registerResult
#define TFEL_TESTS_CHECK(X)
 an helper macro to ease the use of TestCase::registerResult
#define TFEL_TESTS_CHECK_EQUAL(X, Y)
 an helper macro to ease the use of TestCase::registerResult
#define TFEL_TESTS_CHECK_GT(X, Y)
 an helper macro to ease the use of TestCase::registerResult
#define TFEL_TESTS_CHECK_GE(X, Y)
 an helper macro to ease the use of TestCase::registerResult
#define TFEL_TESTS_CHECK_LT(X, Y)
 an helper macro to ease the use of TestCase::registerResult
#define TFEL_TESTS_CHECK_LE(X, Y)
 an helper macro to ease the use of TestCase::registerResult

Detailed Description

Author
Thomas Helfer
Date
11/04/2010

Macro Definition Documentation

◆ TFEL_TESTS_ASSERT

#define TFEL_TESTS_ASSERT ( X)
Value:
do { \
try { \
TestCase::registerResult("assertion: '" #X "'", \
} catch (std::exception & tfel_test_exception) { \
TestCase::registerResult("assertion: '" #X "'", false, \
tfel_test_exception.what()); \
} catch (...) { \
TestCase::registerResult("assertion: '" #X "'", false); \
} \
tfel::raise<tfel::tests::TestAssertionFailure>( \
"assertion: '" #X "' failed", TestCase::result); \
} \
} while (0)
#define TFEL_TEMPORARY_VARIABLE(X)
macro defining a unique local variable name for a temporary variable that it not meant to be seen by ...
Definition Macros.hxx:59
#define TFEL_TESTS_ASSERT(X)
an helper macro to ease the use of TestCase::registerResult
Definition TestCase.hxx:42

an helper macro to ease the use of TestCase::registerResult

Parameters
Xcode to be evaluated

◆ TFEL_TESTS_CALLMETHOD

#define TFEL_TESTS_CALLMETHOD ( X)
Value:
do { \
try { \
TestCase::registerResult(#X "()", this->X()); \
} catch (std::exception & tfel_test_exception) { \
TestCase::registerResult("assertion: '" #X "'", false, \
tfel_test_exception.what()); \
} catch (...) { \
TestCase::registerResult(#X "()", false); \
} \
} while (0)

an helper macro to ease the use of TestCase::registerResult

Parameters
Xmethod to be called

◆ TFEL_TESTS_CHECK

#define TFEL_TESTS_CHECK ( X)
Value:
do { \
try { \
TestCase::registerResult("check: '" #X "'", X); \
} catch (std::exception & tfel_test_exception) { \
TestCase::registerResult("check: '" #X "'", false, \
tfel_test_exception.what()); \
} catch (...) { \
TestCase::registerResult("check: '" #X "'", false); \
} \
} while (0)

an helper macro to ease the use of TestCase::registerResult

Parameters
Xvalue to be tested

◆ TFEL_TESTS_CHECK_EQUAL

#define TFEL_TESTS_CHECK_EQUAL ( X,
Y )
Value:
do { \
try { \
TestCase::registerResult("egal: '" #X "==" #Y "'", X == Y); \
} catch (std::exception & tfel_test_exception) { \
TestCase::registerResult("assertion: '" #X "'", false, \
tfel_test_exception.what()); \
} catch (...) { \
TestCase::registerResult("egal: '" #X "==" #Y "'", false); \
} \
} while (0)

an helper macro to ease the use of TestCase::registerResult

Parameters
Xvalue to be tested
Yexpected value

◆ TFEL_TESTS_CHECK_GE

#define TFEL_TESTS_CHECK_GE ( X,
Y )
Value:
do { \
try { \
TestCase::registerResult("greater or equal: '" #X ">=" #Y "'", X >= Y); \
} catch (std::exception & tfel_test_exception) { \
TestCase::registerResult("assertion: '" #X "'", false, \
tfel_test_exception.what()); \
} catch (...) { \
TestCase::registerResult("greater or equal: '" #X ">=" #Y "'", false); \
} \
} while (0)

an helper macro to ease the use of TestCase::registerResult

Parameters
Xvalue to be tested
Yexpected value

◆ TFEL_TESTS_CHECK_GT

#define TFEL_TESTS_CHECK_GT ( X,
Y )
Value:
do { \
try { \
TestCase::registerResult("greater: '" #X ">" #Y "'", X > Y); \
} catch (std::exception & tfel_test_exception) { \
TestCase::registerResult("assertion: '" #X "'", false, \
tfel_test_exception.what()); \
} catch (...) { \
TestCase::registerResult("greater: '" #X ">" #Y "'", false); \
} \
} while (0)

an helper macro to ease the use of TestCase::registerResult

Parameters
Xvalue to be tested
Yexpected value

◆ TFEL_TESTS_CHECK_LE

#define TFEL_TESTS_CHECK_LE ( X,
Y )
Value:
do { \
try { \
TestCase::registerResult("lesser or equal: '" #X "<=" #Y "'", X <= Y); \
} catch (std::exception & tfel_test_exception) { \
TestCase::registerResult("assertion: '" #X "'", false, \
tfel_test_exception.what()); \
} catch (...) { \
TestCase::registerResult("lesser or equal: '" #X "<" #Y "'", false); \
} \
} while (0)

an helper macro to ease the use of TestCase::registerResult

Parameters
Xvalue to be tested
Yexpected value

◆ TFEL_TESTS_CHECK_LT

#define TFEL_TESTS_CHECK_LT ( X,
Y )
Value:
do { \
try { \
TestCase::registerResult("lesser: '" #X "<" #Y "'", X < Y); \
} catch (std::exception & tfel_test_exception) { \
TestCase::registerResult("assertion: '" #X "'", false, \
tfel_test_exception.what()); \
} catch (...) { \
TestCase::registerResult("lesser: '" #X "<" #Y "'", false); \
} \
} while (0)

an helper macro to ease the use of TestCase::registerResult

Parameters
Xvalue to be tested
Yexpected value

◆ TFEL_TESTS_CHECK_THROW

#define TFEL_TESTS_CHECK_THROW ( X,
Y )
Value:
do { \
bool tfel_test_has_thrown = false; \
auto tfel_test_details = std::string{}; \
try { \
static_cast<void>(X); \
} catch (Y&) { \
tfel_test_has_thrown = true; \
} catch (...) { \
} \
TestCase::registerResult("check throw: '" #X "'", tfel_test_has_thrown); \
} while (0)

an helper macro to ease the use of TestCase::registerResult

Parameters
Xcode to be evaluated
Yexeception execpted to be thrown

◆ TFEL_TESTS_STATIC_ASSERT

#define TFEL_TESTS_STATIC_ASSERT ( X)
Value:
do { \
static_assert((X), "static assertion: '" #X "'"); \
TestCase::registerResult("static assertion: '" #X "'", (X)); \
} while (0)

an helper macro to ease the use of TestCase::registerResult

Parameters
X: code to be evaluated