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

A reporter writing into a console or file. More...

#include <reporterconsole.h>

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

Classes

struct  Impl
 

Public Member Functions

 ReporterConsole (const ReporterConsole &)=delete
 
ReporterConsoleoperator= (const ReporterConsole &)=delete
 
 ReporterConsole (std::ostream *out_, bool verbose_, bool hide_location_)
 Ctor. More...
 
virtual ~ReporterConsole ()
 Dtor. More...
 
virtual void enterTest (const Context &context_, const std::string &name_, const Parameters &params_) override
 Enter entire test. More...
 
virtual void enterSuite (const Context &context_, const std::string &name_, const Parameters &params_) override
 Enter a suite. More...
 
virtual void enterCase (const Context &context_, const std::string &name_, const Parameters &params_) override
 Enter a case. More...
 
virtual void enterState (const Context &context_, const std::string &name_) override
 Enter a state. More...
 
virtual AssertBufferPtr enterAssert (const Context &context_, bool condition_, const std::string &file_, int lineno_) override
 Enter an assertion. More...
 
virtual AssertBufferPtr enterError (const Context &context_) override
 Enter an error report. More...
 
virtual void leaveState (const Context &context_, const std::string &name_, bool result_) override
 Leave a state. More...
 
virtual void leaveCase (const Context &context_, const std::string &name_, const Parameters &params_, bool result_) override
 Leave a case. More...
 
virtual void leaveSuite (const Context &context_, const std::string &name_, const Parameters &params_, bool result_) override
 Leave a suite. More...
 
virtual void leaveTest (const Context &context_, const std::string &name_, const Parameters &params_, bool result_) override
 Leave entire test. More...
 
- Public Member Functions inherited from OTest2::Reporter
 Reporter (const Reporter &)=delete
 
Reporteroperator= (const Reporter &)=delete
 
 Reporter ()
 Ctor. More...
 
virtual ~Reporter ()
 Dtor. More...
 

Detailed Description

A reporter writing into a console or file.

This reporter writes the test results into a console.

Definition at line 34 of file reporterconsole.h.

Constructor & Destructor Documentation

◆ ReporterConsole() [1/2]

OTest2::ReporterConsole::ReporterConsole ( const ReporterConsole )
delete

◆ ReporterConsole() [2/2]

OTest2::ReporterConsole::ReporterConsole ( std::ostream *  out_,
bool  verbose_,
bool  hide_location_ 
)
explicit

Ctor.

Parameters
out_An output stream. The ownership is not taken.
verbose_If it's true all assertions are printed. If it's false just the failed assertions are printed out.
hide_location_If the flag is true, the assertion locations are hidden (replaced by '...').

Definition at line 401 of file reporterconsole.cpp.

◆ ~ReporterConsole()

OTest2::ReporterConsole::~ReporterConsole ( )
virtual

Dtor.

Definition at line 409 of file reporterconsole.cpp.

Member Function Documentation

◆ enterAssert()

AssertBufferPtr OTest2::ReporterConsole::enterAssert ( const Context context_,
bool  condition_,
const std::string &  file_,
int  lineno_ 
)
overridevirtual

Enter an assertion.

The assertion is opened similarly to states, cases and suites until the AsssertBuffer::commitAssertion() method of the returned assertion buffer is invoked.

Warning
Just one assertion at time may be opened!
Parameters
context_the OTest2 context
condition_result of the assertion (false means failed assertion)
file_name of the source file
lineno_line number in the source file
Returns
An assertion buffer object which is used for formatting the assertion report.

Implements OTest2::Reporter.

Definition at line 452 of file reporterconsole.cpp.

◆ enterCase()

void OTest2::ReporterConsole::enterCase ( const Context context_,
const std::string &  name_,
const Parameters params_ 
)
overridevirtual

Enter a case.

Parameters
context_the OTest2 context
name_Name of the case
params_Parameters of the testing object

Implements OTest2::Reporter.

Definition at line 433 of file reporterconsole.cpp.

◆ enterError()

AssertBufferPtr OTest2::ReporterConsole::enterError ( const Context context_)
overridevirtual

Enter an error report.

This method is used to report errors happened in the testing framework. Errors mean failure of the test. However, they cannot be located in the user code (no filename, no line number). A good example is a not handled exception caught by the framework outside test cases.

The method works as well as the enterAssert() method with failed condition and with no location info. The opened error state is closed by the AssertBuffer::commitAssertion() method of the returned assertion buffer.

Warning
Just one assertion at time may be opened!
Parameters
context_the context
Returns
An assertion buffer object which is used for formatting the assertion report.

Implements OTest2::Reporter.

Definition at line 465 of file reporterconsole.cpp.

◆ enterState()

void OTest2::ReporterConsole::enterState ( const Context context_,
const std::string &  name_ 
)
overridevirtual

Enter a state.

Parameters
context_the OTest2 context
name_Name of the state

Implements OTest2::Reporter.

Definition at line 446 of file reporterconsole.cpp.

◆ enterSuite()

void OTest2::ReporterConsole::enterSuite ( const Context context_,
const std::string &  name_,
const Parameters params_ 
)
overridevirtual

Enter a suite.

Parameters
context_the OTest2 context
name_Name of the suite
params_Parameters of the testing object

Implements OTest2::Reporter.

Definition at line 420 of file reporterconsole.cpp.

◆ enterTest()

void OTest2::ReporterConsole::enterTest ( const Context context_,
const std::string &  name_,
const Parameters params_ 
)
overridevirtual

Enter entire test.

Parameters
context_The OTest2 context
name_Name of the test
params_Parameters of the testing object

Implements OTest2::Reporter.

Definition at line 413 of file reporterconsole.cpp.

◆ leaveCase()

void OTest2::ReporterConsole::leaveCase ( const Context context_,
const std::string &  name_,
const Parameters params_,
bool  result_ 
)
overridevirtual

Leave a case.

Parameters
context_the OTest2 context
name_Name of the case
params_Parameters of the testing object
result_Result of the case

Implements OTest2::Reporter.

Definition at line 482 of file reporterconsole.cpp.

◆ leaveState()

void OTest2::ReporterConsole::leaveState ( const Context context_,
const std::string &  name_,
bool  result_ 
)
overridevirtual

Leave a state.

Parameters
context_the OTest2 context
name_Name of the state
result_Result of the state

Implements OTest2::Reporter.

Definition at line 475 of file reporterconsole.cpp.

◆ leaveSuite()

void OTest2::ReporterConsole::leaveSuite ( const Context context_,
const std::string &  name_,
const Parameters params_,
bool  result_ 
)
overridevirtual

Leave a suite.

Parameters
context_the OTest2 context
name_Name of the suite
params_Parameters of the testing object
result_Result of the suite

Implements OTest2::Reporter.

Definition at line 499 of file reporterconsole.cpp.

◆ leaveTest()

void OTest2::ReporterConsole::leaveTest ( const Context context_,
const std::string &  name_,
const Parameters params_,
bool  result_ 
)
overridevirtual

Leave entire test.

Parameters
context_the OTest2 context
name_Name of the leaving test
params_Parameters of the testing object
result_Result of the test

Implements OTest2::Reporter.

Definition at line 519 of file reporterconsole.cpp.

◆ operator=()

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

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