xrpld
Loading...
Searching...
No Matches
beast::unit_test::Recorder Class Reference

A test runner that stores the results. More...

#include <recorder.h>

Inheritance diagram for beast::unit_test::Recorder:
Collaboration diagram for beast::unit_test::Recorder:

Public Member Functions

 Recorder ()=default
Results const & report () const
 Returns a report with the results of all completed suites.
void arg (std::string const &s)
 Set the argument string.
std::string const & arg () const
 Returns the argument string.
template<class = void>
bool run (SuiteInfo const &s)
 Run the specified suite.
template<class FwdIter>
bool run (FwdIter first, FwdIter last)
 Run a sequence of suites.
template<class FwdIter, class Pred>
bool runIf (FwdIter first, FwdIter last, Pred pred=Pred{})
 Conditionally run a sequence of suites.
template<class SequenceContainer>
bool runEach (SequenceContainer const &c)
 Run all suites in a container.
template<class SequenceContainer, class Pred>
bool runEachIf (SequenceContainer const &c, Pred pred=Pred{})
 Conditionally run suites in a container.

Private Member Functions

void onSuiteBegin (SuiteInfo const &info) override
 Called when a new suite starts.
void onSuiteEnd () override
 Called when a suite ends.
void onCaseBegin (std::string const &name) override
 Called when a new case starts.
void onCaseEnd () override
 Called when a new case ends.
void onPass () override
 Called for each passing condition.
void onFail (std::string const &reason) override
 Called for each failing condition.
void onLog (std::string const &s) override
 Called when a test logs output.
template<class = void>
void testcase (std::string const &name)
template<class = void>
void pass ()
template<class = void>
void fail (std::string const &reason)
template<class = void>
void log (std::string const &s)

Private Attributes

Results results_
SuiteResults suite_
CaseResults case_
std::string arg_
bool default_ = false
bool failed_ = false
bool cond_ = false
std::recursive_mutex mutex_

Detailed Description

A test runner that stores the results.

Definition at line 13 of file recorder.h.

Constructor & Destructor Documentation

◆ Recorder()

beast::unit_test::Recorder::Recorder ( )
default

Member Function Documentation

◆ report()

Results const & beast::unit_test::Recorder::report ( ) const
nodiscard

Returns a report with the results of all completed suites.

Definition at line 25 of file recorder.h.

◆ onSuiteBegin()

void beast::unit_test::Recorder::onSuiteBegin ( SuiteInfo const & )
overrideprivatevirtual

Called when a new suite starts.

Reimplemented from beast::unit_test::Runner.

Definition at line 32 of file recorder.h.

◆ onSuiteEnd()

void beast::unit_test::Recorder::onSuiteEnd ( )
overrideprivatevirtual

Called when a suite ends.

Reimplemented from beast::unit_test::Runner.

Definition at line 38 of file recorder.h.

◆ onCaseBegin()

void beast::unit_test::Recorder::onCaseBegin ( std::string const & )
overrideprivatevirtual

Called when a new case starts.

Reimplemented from beast::unit_test::Runner.

Definition at line 44 of file recorder.h.

◆ onCaseEnd()

void beast::unit_test::Recorder::onCaseEnd ( )
overrideprivatevirtual

Called when a new case ends.

Reimplemented from beast::unit_test::Runner.

Definition at line 50 of file recorder.h.

◆ onPass()

void beast::unit_test::Recorder::onPass ( )
overrideprivatevirtual

Called for each passing condition.

Reimplemented from beast::unit_test::Runner.

Definition at line 57 of file recorder.h.

◆ onFail()

void beast::unit_test::Recorder::onFail ( std::string const & )
overrideprivatevirtual

Called for each failing condition.

Reimplemented from beast::unit_test::Runner.

Definition at line 63 of file recorder.h.

◆ onLog()

void beast::unit_test::Recorder::onLog ( std::string const & )
overrideprivatevirtual

Called when a test logs output.

Reimplemented from beast::unit_test::Runner.

Definition at line 69 of file recorder.h.

◆ arg() [1/2]

void beast::unit_test::Runner::arg ( std::string const & s)
inherited

Set the argument string.

The argument string is available to suites and allows for customization of the test. Each suite defines its own syntax for the argument string. The same argument is passed to all suites.

Definition at line 44 of file runner.h.

◆ arg() [2/2]

std::string const & beast::unit_test::Runner::arg ( ) const
nodiscardinherited

Returns the argument string.

Definition at line 51 of file runner.h.

◆ run() [1/2]

template<class>
bool beast::unit_test::Runner::run ( SuiteInfo const & s)
inherited

Run the specified suite.

Returns
true if any conditions failed.

Definition at line 170 of file runner.h.

◆ run() [2/2]

template<class FwdIter>
bool beast::unit_test::Runner::run ( FwdIter first,
FwdIter last )
inherited

Run a sequence of suites.

The expression FwdIter::value_type must be convertible to SuiteInfo.

Returns
true if any conditions failed.

Definition at line 186 of file runner.h.

◆ runIf()

template<class FwdIter, class Pred>
bool beast::unit_test::Runner::runIf ( FwdIter first,
FwdIter last,
Pred pred = Pred{} )
inherited

Conditionally run a sequence of suites.

pred will be called as:

bool pred(SuiteInfo const&);
Associates a unit test type with metadata.
Definition suite_info.h:18
Returns
true if any conditions failed.

Definition at line 196 of file runner.h.

◆ runEach()

template<class SequenceContainer>
bool beast::unit_test::Runner::runEach ( SequenceContainer const & c)
inherited

Run all suites in a container.

Returns
true if any conditions failed.

Definition at line 209 of file runner.h.

◆ runEachIf()

template<class SequenceContainer, class Pred>
bool beast::unit_test::Runner::runEachIf ( SequenceContainer const & c,
Pred pred = Pred{} )
inherited

Conditionally run suites in a container.

pred will be called as:

bool pred(SuiteInfo const&);
Returns
true if any conditions failed.

Definition at line 219 of file runner.h.

◆ testcase()

template<class>
void beast::unit_test::Runner::testcase ( std::string const & name)
privateinherited

Definition at line 232 of file runner.h.

◆ pass()

template<class>
void beast::unit_test::Runner::pass ( )
privateinherited

Definition at line 248 of file runner.h.

◆ fail()

template<class>
void beast::unit_test::Runner::fail ( std::string const & reason)
privateinherited

Definition at line 259 of file runner.h.

◆ log()

template<class>
void beast::unit_test::Runner::log ( std::string const & s)
privateinherited

Definition at line 271 of file runner.h.

Member Data Documentation

◆ results_

Results beast::unit_test::Recorder::results_
private

Definition at line 16 of file recorder.h.

◆ suite_

SuiteResults beast::unit_test::Recorder::suite_
private

Definition at line 17 of file recorder.h.

◆ case_

CaseResults beast::unit_test::Recorder::case_
private

Definition at line 18 of file recorder.h.

◆ arg_

std::string beast::unit_test::Runner::arg_
privateinherited

Definition at line 23 of file runner.h.

◆ default_

bool beast::unit_test::Runner::default_ = false
privateinherited

Definition at line 24 of file runner.h.

◆ failed_

bool beast::unit_test::Runner::failed_ = false
privateinherited

Definition at line 25 of file runner.h.

◆ cond_

bool beast::unit_test::Runner::cond_ = false
privateinherited

Definition at line 26 of file runner.h.

◆ mutex_

std::recursive_mutex beast::unit_test::Runner::mutex_
privateinherited

Definition at line 27 of file runner.h.