Specs
Beautiful C++ Test Framework
Loading...
Searching...
No Matches
SpecsCpp::SpecReporterCollection Class Reference

#include <SpecReporterCollection.h>

Inheritance diagram for SpecsCpp::SpecReporterCollection:
SpecsCpp::ISpecReporterCollection

Public Member Functions

void add (const char *name, ISpecReporter *reporter) override
 
bool has (const char *name) const override
 
ISpecReporterget (const char *name) const override
 
void foreach_reporter (ForEachReporterFn *fn) const override
 
void report_start () override
 
void report_test_begin (ISpecGroup *group, ISpec *spec) override
 
void report_setup (ISpecRunResult *result) override
 
void report_test (ISpecRunResult *result) override
 
void report_teardown (ISpecRunResult *result) override
 
void report_test_result (ISpecRunResult *result) override
 
void report_suite_result (ISpecSuiteRunResult *result) override
 
- Public Member Functions inherited from SpecsCpp::ISpecReporterCollection
virtual ~ISpecReporterCollection ()=default
 
virtual void add (const char *, ISpecReporter *)=0
 
virtual bool has (const char *name) const =0
 
virtual ISpecReporterget (const char *name) const =0
 
virtual void foreach_reporter (ForEachReporterFn *) const =0
 
void foreach (std::function< void(const char *, ISpecReporter *)> fn) const
 
virtual void report_start ()=0
 
virtual void report_test_begin (ISpecGroup *, ISpec *)=0
 
virtual void report_setup (ISpecRunResult *)=0
 
virtual void report_test (ISpecRunResult *)=0
 
virtual void report_teardown (ISpecRunResult *)=0
 
virtual void report_test_result (ISpecRunResult *)=0
 
virtual void report_suite_result (ISpecSuiteRunResult *)=0
 

Additional Inherited Members

- Public Types inherited from SpecsCpp::ISpecReporterCollection
using ForEachReporterFn = IFunctionPointer< void(const char *, ISpecReporter *)>
 

Detailed Description

Definition at line 10 of file SpecReporterCollection.h.

Member Function Documentation

◆ add()

void SpecsCpp::SpecReporterCollection::add ( const char *  name,
ISpecReporter reporter 
)
inlineoverridevirtual

Implements SpecsCpp::ISpecReporterCollection.

Definition at line 14 of file SpecReporterCollection.h.

14 {
15 _reporters[name] = reporter;
16 }

Referenced by SpecsCpp::Entrypoint::main().

◆ foreach_reporter()

void SpecsCpp::SpecReporterCollection::foreach_reporter ( ForEachReporterFn fn) const
inlineoverridevirtual

Implements SpecsCpp::ISpecReporterCollection.

Definition at line 29 of file SpecReporterCollection.h.

29 {
30 for (const auto& [name, reporter] : _reporters) fn->invoke(name.c_str(), reporter);
31 }

◆ get()

ISpecReporter * SpecsCpp::SpecReporterCollection::get ( const char *  name) const
inlineoverridevirtual

Implements SpecsCpp::ISpecReporterCollection.

Definition at line 23 of file SpecReporterCollection.h.

23 {
24 auto found = _reporters.find(name);
25 if (found != _reporters.end()) return found->second;
26 return nullptr;
27 }

◆ has()

bool SpecsCpp::SpecReporterCollection::has ( const char *  name) const
inlineoverridevirtual

Implements SpecsCpp::ISpecReporterCollection.

Definition at line 18 of file SpecReporterCollection.h.

18 {
19 auto found = _reporters.find(name);
20 return found != _reporters.end();
21 }

◆ report_setup()

void SpecsCpp::SpecReporterCollection::report_setup ( ISpecRunResult result)
inlineoverridevirtual

Implements SpecsCpp::ISpecReporterCollection.

Definition at line 42 of file SpecReporterCollection.h.

42 {
43 for (const auto& [name, reporter] : _reporters) reporter->report_setup(result);
44 }
void report_setup(ISpecRunResult *result) override

◆ report_start()

void SpecsCpp::SpecReporterCollection::report_start ( )
inlineoverridevirtual

Implements SpecsCpp::ISpecReporterCollection.

Definition at line 33 of file SpecReporterCollection.h.

33 {
34 for (const auto& [name, reporter] : _reporters) reporter->report_start();
35 }

◆ report_suite_result()

void SpecsCpp::SpecReporterCollection::report_suite_result ( ISpecSuiteRunResult result)
inlineoverridevirtual

Implements SpecsCpp::ISpecReporterCollection.

Definition at line 58 of file SpecReporterCollection.h.

58 {
59 for (const auto& [name, reporter] : _reporters) reporter->report_suite_result(result);
60 }
void report_suite_result(ISpecSuiteRunResult *result) override

◆ report_teardown()

void SpecsCpp::SpecReporterCollection::report_teardown ( ISpecRunResult result)
inlineoverridevirtual

Implements SpecsCpp::ISpecReporterCollection.

Definition at line 50 of file SpecReporterCollection.h.

50 {
51 for (const auto& [name, reporter] : _reporters) reporter->report_teardown(result);
52 }
void report_teardown(ISpecRunResult *result) override

◆ report_test()

void SpecsCpp::SpecReporterCollection::report_test ( ISpecRunResult result)
inlineoverridevirtual

Implements SpecsCpp::ISpecReporterCollection.

Definition at line 46 of file SpecReporterCollection.h.

46 {
47 for (const auto& [name, reporter] : _reporters) reporter->report_test(result);
48 }
void report_test(ISpecRunResult *result) override

◆ report_test_begin()

void SpecsCpp::SpecReporterCollection::report_test_begin ( ISpecGroup group,
ISpec spec 
)
inlineoverridevirtual

Implements SpecsCpp::ISpecReporterCollection.

Definition at line 37 of file SpecReporterCollection.h.

37 {
38 for (const auto& [name, reporter] : _reporters)
39 reporter->report_test_begin(group, spec);
40 }
void report_test_begin(ISpecGroup *group, ISpec *spec) override
void spec(std::string_view description, std::function< void()> body)
Definition spec.h:12

◆ report_test_result()

void SpecsCpp::SpecReporterCollection::report_test_result ( ISpecRunResult result)
inlineoverridevirtual

Implements SpecsCpp::ISpecReporterCollection.

Definition at line 54 of file SpecReporterCollection.h.

54 {
55 for (const auto& [name, reporter] : _reporters) reporter->report_test_result(result);
56 }
void report_test_result(ISpecRunResult *result) override

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