OTest2
A C++ testing framework
Public Member Functions | List of all members
OTest2::GenericAssertion Class Reference

Implementation class of the generic assertions. More...

#include <assertions.h>

Inheritance diagram for OTest2::GenericAssertion:
Inheritance graph
[legend]
Collaboration diagram for OTest2::GenericAssertion:
Collaboration graph
[legend]

Public Member Functions

 GenericAssertion (const GenericAssertion &)=delete
 
GenericAssertionoperator= (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...
 
- Public Member Functions inherited from OTest2::AssertContext
 AssertContext (const AssertContext &)=delete
 
AssertContextoperator= (const AssertContext &)=delete
 
 AssertContext (const Context &context_, const std::string &file_, int lineno_, std::initializer_list< const char * > parameters_)
 Ctor. More...
 

Additional Inherited Members

- Protected Member Functions inherited from OTest2::AssertContext
 ~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 Contextotest2Context () const
 Get the OTest2 context. More...
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ GenericAssertion()

OTest2::GenericAssertion::GenericAssertion ( const GenericAssertion )
delete

Member Function Documentation

◆ AssertContext() [1/2]

OTest2::AssertContext::AssertContext
delete

◆ AssertContext() [2/2]

OTest2::AssertContext::AssertContext
explicit

Ctor.

Parameters
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.

◆ operator=()

GenericAssertion& OTest2::GenericAssertion::operator= ( const GenericAssertion )
delete

◆ reportAssertion()

template<typename Compare_ , typename A_ , typename B_ >
bool OTest2::GenericAssertion::reportAssertion ( Compare_ &&  cmp_,
A_ &&  a_,
B_ &&  b_,
bool  condition_ 
)

Definition at line 35 of file assertionsimpl.h.

◆ testAssert() [1/2]

bool OTest2::GenericAssertion::testAssert ( bool  condition_)

Definition at line 30 of file assertions.cpp.

◆ testAssert() [2/2]

bool OTest2::GenericAssertion::testAssert ( const AssertBean bean_)

Definition at line 38 of file assertions.cpp.

◆ testAssertCompare()

template<template< typename, typename > class Compare_, typename A_ , typename B_ >
bool OTest2::GenericAssertion::testAssertCompare ( A_ &&  a_,
B_ &&  b_ 
)

Definition at line 74 of file assertionsimpl.h.

◆ testAssertCompareFP()

template<template< typename, typename, typename > class Compare_, typename A_ , typename B_ , typename Precision_ >
bool OTest2::GenericAssertion::testAssertCompareFP ( A_  a_,
B_  b_,
Precision_  precision_ = DEFAULT_FLOAT_PRECISION 
)

Definition at line 88 of file assertionsimpl.h.

◆ testException()

bool OTest2::GenericAssertion::testException ( std::function< bool()>  ftor_)

Definition at line 46 of file assertions.cpp.


The documentation for this class was generated from the following files: