Specs
Beautiful C++ Test Framework
Loading...
Searching...
No Matches
SpecReporterCollection.h
Go to the documentation of this file.
1#pragma once
2
3#include <Specs/API.h>
4#include <collections.h>
5
6#include <string>
7
8namespace SpecsCpp {
9
11 collections_map<std::string, ISpecReporter*> _reporters;
12
13 public:
14 void add(const char* name, ISpecReporter* reporter) override {
15 _reporters[name] = reporter;
16 }
17
18 bool has(const char* name) const override {
19 auto found = _reporters.find(name);
20 return found != _reporters.end();
21 }
22
23 ISpecReporter* get(const char* name) const override {
24 auto found = _reporters.find(name);
25 if (found != _reporters.end()) return found->second;
26 return nullptr;
27 }
28
29 void foreach_reporter(ForEachReporterFn* fn) const override {
30 for (const auto& [name, reporter] : _reporters) fn->invoke(name.c_str(), reporter);
31 }
32
33 void report_start() override {
34 for (const auto& [name, reporter] : _reporters) reporter->report_start();
35 }
36
37 void report_test_begin(ISpecGroup* group, ISpec* spec) override {
38 for (const auto& [name, reporter] : _reporters)
39 reporter->report_test_begin(group, spec);
40 }
41
42 void report_setup(ISpecRunResult* result) override {
43 for (const auto& [name, reporter] : _reporters) reporter->report_setup(result);
44 }
45
46 void report_test(ISpecRunResult* result) override {
47 for (const auto& [name, reporter] : _reporters) reporter->report_test(result);
48 }
49
50 void report_teardown(ISpecRunResult* result) override {
51 for (const auto& [name, reporter] : _reporters) reporter->report_teardown(result);
52 }
53
54 void report_test_result(ISpecRunResult* result) override {
55 for (const auto& [name, reporter] : _reporters) reporter->report_test_result(result);
56 }
57
59 for (const auto& [name, reporter] : _reporters) reporter->report_suite_result(result);
60 }
61 };
62}
void report_teardown(ISpecRunResult *result) override
bool has(const char *name) const override
ISpecReporter * get(const char *name) const override
void report_setup(ISpecRunResult *result) override
void report_test_result(ISpecRunResult *result) override
void report_test(ISpecRunResult *result) override
void report_suite_result(ISpecSuiteRunResult *result) override
void add(const char *name, ISpecReporter *reporter) override
void report_test_begin(ISpecGroup *group, ISpec *spec) override
void foreach_reporter(ForEachReporterFn *fn) const override
Definition API.h:3
IFunctionPointer< void(const char *, ISpecReporter *)> ForEachReporterFn
Definition API.h:427