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

Assertion context. More...

#include <assertcontext.h>

Inheritance diagram for OTest2::AssertContext:
Inheritance graph
[legend]

Public Member Functions

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

Protected Member Functions

 ~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

Assertion context.

This is a helper class used for creation of assertion objects. The class keeps a context needed by the implementations of the assertions.

Definition at line 37 of file assertcontext.h.

Constructor & Destructor Documentation

◆ AssertContext() [1/2]

OTest2::AssertContext::AssertContext ( const AssertContext )
delete

◆ AssertContext() [2/2]

OTest2::AssertContext::AssertContext ( const Context context_,
const std::string &  file_,
int  lineno_,
std::initializer_list< const char * >  parameters_ 
)
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.

◆ ~AssertContext()

OTest2::AssertContext::~AssertContext ( )
protecteddefault

Dtor.

Member Function Documentation

◆ enterAssertion()

AssertStream OTest2::AssertContext::enterAssertion ( bool  result_)
protected

Enter an assertion.

Parameters
result_Result of the assertion (the checked condition)
Returns
An assertion stream. This object allows to print more descriptive description why the assertion has failed including some text attributes like color or style. The object correctly closes the assertion by its destruction.

Definition at line 45 of file assertcontext.cpp.

◆ operator=()

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

◆ otest2Context()

const Context & OTest2::AssertContext::otest2Context ( ) const
protected

Get the OTest2 context.

Definition at line 78 of file assertcontext.cpp.

◆ simpleAssertionImpl()

bool OTest2::AssertContext::simpleAssertionImpl ( bool  condition_,
const std::string &  message_,
bool  print_expression_ 
)
protected

Implementation of a simple assertion.

This method implements a simple assertion which doesn't report additive messages.

Parameters
condition_The checked condition
message_The assertion message (it may be empty)
print_expression_If it's true, the first assertion parameter is printed with the assertion message.
Returns
the condition

Definition at line 58 of file assertcontext.cpp.


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