OTest2
A C++ testing framework
|
Implementation class of the generic assertions. More...
#include <assertions.h>
Public Member Functions | |
GenericAssertion (const GenericAssertion &)=delete | |
GenericAssertion & | operator= (const GenericAssertion &)=delete |
bool | testAssert (bool condition_) |
bool | testAssert (const AssertBean &bean_) |
template<typename Compare_ , typename A_ , typename B_ > | |
bool | reportAssertion (Compare_ &&cmp_, A_ &&a_, B_ &&b_, bool condition_) |
template<template< typename, typename > class Compare_, typename A_ , typename B_ > | |
bool | testAssertCompare (A_ &&a_, B_ &&b_) |
template<template< typename, typename, typename > class Compare_, typename A_ , typename B_ , typename Precision_ = long double> | |
bool | testAssertCompareFP (A_ a_, B_ b_, Precision_ precision_=DEFAULT_FLOAT_PRECISION) |
bool | testException (std::function< bool()> ftor_) |
AssertContext (const AssertContext &)=delete | |
AssertContext (const Context &context_, const std::string &file_, int lineno_, std::initializer_list< const char * > parameters_) | |
Ctor. More... | |
![]() | |
AssertContext (const AssertContext &)=delete | |
AssertContext & | operator= (const AssertContext &)=delete |
AssertContext (const Context &context_, const std::string &file_, int lineno_, std::initializer_list< const char * > parameters_) | |
Ctor. More... | |
Additional Inherited Members | |
![]() | |
~AssertContext () | |
Dtor. More... | |
AssertStream | enterAssertion (bool result_) |
Enter an assertion. More... | |
bool | simpleAssertionImpl (bool condition_, const std::string &message_, bool print_expression_) |
Implementation of a simple assertion. More... | |
const Context & | otest2Context () const |
Get the OTest2 context. More... | |
Implementation class of the generic assertions.
Implementation notes
An assertion is implemented by two items: a declaration and an implementation class. The declaration is a function specifying assertion's parameters. There is no definition of the function - it's needed only by IDEs and the OTest2 parser.
The declaration class must inherit from the AssertContext class, it must inherit the parent's constructor and an assertion method with exactly the same parameters as the asssertion's declaration function. The declaration function must be connected to the implementation class and its method by the annotation.
The OTest2 preprocessor replaces the invocation of the assertion by instantiation of the implementation class and invocation of the assertion method.
Definition at line 56 of file assertions.h.
|
delete |
|
delete |
|
explicit |
Ctor.
context_ | The OTest2 context |
file_ | filename which the assertion is located in |
lineno_ | line number of the assertion |
parameters_ | Array of strings representing the parameters of the assertion. The initializer list is valid just inside one expression as well as the instance of the assertion context is. |
Definition at line 31 of file assertcontext.cpp.
|
delete |
bool OTest2::GenericAssertion::reportAssertion | ( | Compare_ && | cmp_, |
A_ && | a_, | ||
B_ && | b_, | ||
bool | condition_ | ||
) |
Definition at line 35 of file assertionsimpl.h.
bool OTest2::GenericAssertion::testAssert | ( | bool | condition_ | ) |
Definition at line 30 of file assertions.cpp.
bool OTest2::GenericAssertion::testAssert | ( | const AssertBean & | bean_ | ) |
Definition at line 38 of file assertions.cpp.
bool OTest2::GenericAssertion::testAssertCompare | ( | A_ && | a_, |
B_ && | b_ | ||
) |
Definition at line 74 of file assertionsimpl.h.
bool OTest2::GenericAssertion::testAssertCompareFP | ( | A_ | a_, |
B_ | b_, | ||
Precision_ | precision_ = DEFAULT_FLOAT_PRECISION |
||
) |
Definition at line 88 of file assertionsimpl.h.
bool OTest2::GenericAssertion::testException | ( | std::function< bool()> | ftor_ | ) |
Definition at line 46 of file assertions.cpp.