OTest2
A C++ testing framework
reportertee.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2020 Ondrej Starek
3  *
4  * This file is part of OTest2.
5  *
6  * OTest2 is free software: you can redistribute it and/or modify it under
7  * the terms of the GNU Lesser General Public License as published by
8  * the Free Software Foundation, either version 3 of the License,
9  * or (at your option) any later version.
10  *
11  * OTest2 is distributed in the hope that it will be useful, but WITHOUT
12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13  * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
14  * License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public License
17  * along with OTest2. If not, see <http://www.gnu.org/licenses/>.
18  */
19 
20 #ifndef OTest2__INCLUDE_OTEST2_REPORTERTEE_H_
21 #define OTest2__INCLUDE_OTEST2_REPORTERTEE_H_
22 
23 #include <otest2/reporter.h>
24 
25 #include <vector>
26 
27 namespace OTest2 {
28 
32 class ReporterTee : public Reporter {
33  private:
34  std::vector<Reporter*> reporters;
35 
36  public:
40  ReporterTee();
41 
45  virtual ~ReporterTee();
46 
47  /* -- avoid copying */
49  const ReporterTee&) = delete;
51  const ReporterTee&) = delete;
52 
58  void appendReporter(
59  Reporter* reporter_);
60 
61  /* -- reporter interface */
62  virtual void enterTest(
63  const Context& context_,
64  const std::string& name_,
65  const Parameters& params_) override;
66  virtual void enterSuite(
67  const Context& context_,
68  const std::string& name_,
69  const Parameters& params_) override;
70  virtual void enterCase(
71  const Context& context_,
72  const std::string& name_,
73  const Parameters& params_) override;
74  virtual void enterState(
75  const Context& context_,
76  const std::string& name_) override;
78  const Context& context_,
79  bool condition_,
80  const std::string& file_,
81  int lineno_) override;
83  const Context& context_) override;
84  virtual void leaveState(
85  const Context& context_,
86  const std::string& name_,
87  bool result_) override;
88  virtual void leaveCase(
89  const Context& context_,
90  const std::string& name_,
91  const Parameters& params_,
92  bool result_) override;
93  virtual void leaveSuite(
94  const Context& context_,
95  const std::string& name_,
96  const Parameters& params_,
97  bool result_) override;
98  virtual void leaveTest(
99  const Context& context_,
100  const std::string& name_,
101  const Parameters& params_,
102  bool result_) override;
103 };
104 
105 } /* -- namespace OTest2 */
106 
107 #endif /* -- OTest2__INCLUDE_OTEST2_REPORTERTEE_H_ */
OTest2::Reporter
Generic test reporter.
Definition: reporter.h:34
OTest2::ReporterTee::ReporterTee
ReporterTee()
Ctor.
Definition: reportertee.cpp:141
reporter.h
OTest2::ReporterTee::enterSuite
virtual void enterSuite(const Context &context_, const std::string &name_, const Parameters &params_) override
Enter a suite.
Definition: reportertee.cpp:171
OTest2::ReporterTee::leaveState
virtual void leaveState(const Context &context_, const std::string &name_, bool result_) override
Leave a state.
Definition: reportertee.cpp:245
OTest2::ReporterTee::leaveSuite
virtual void leaveSuite(const Context &context_, const std::string &name_, const Parameters &params_, bool result_) override
Leave a suite.
Definition: reportertee.cpp:277
OTest2::ReporterTee::leaveCase
virtual void leaveCase(const Context &context_, const std::string &name_, const Parameters &params_, bool result_) override
Leave a case.
Definition: reportertee.cpp:260
OTest2::ReporterTee::enterTest
virtual void enterTest(const Context &context_, const std::string &name_, const Parameters &params_) override
Enter entire test.
Definition: reportertee.cpp:156
OTest2::ReporterTee::~ReporterTee
virtual ~ReporterTee()
Dtor.
Definition: reportertee.cpp:145
OTest2::ReporterTee::enterCase
virtual void enterCase(const Context &context_, const std::string &name_, const Parameters &params_) override
Enter a case.
Definition: reportertee.cpp:186
OTest2::ReporterTee::enterError
virtual AssertBufferPtr enterError(const Context &context_) override
Enter an error report.
Definition: reportertee.cpp:231
OTest2::Parameters
Generic parameters of a run of an testing object.
Definition: parameters.h:30
OTest2::ReporterTee::leaveTest
virtual void leaveTest(const Context &context_, const std::string &name_, const Parameters &params_, bool result_) override
Leave entire test.
Definition: reportertee.cpp:294
OTest2
Definition: assertbean.h:25
OTest2::ReporterTee::enterState
virtual void enterState(const Context &context_, const std::string &name_) override
Enter a state.
Definition: reportertee.cpp:201
OTest2::ReporterTee
A tee reporter - a composition of several reporters.
Definition: reportertee.h:32
OTest2::Context
OTest2 runtime context.
Definition: context.h:38
OTest2::ReporterTee::appendReporter
void appendReporter(Reporter *reporter_)
Append a reporter.
Definition: reportertee.cpp:149
OTest2::ReporterTee::operator=
ReporterTee & operator=(const ReporterTee &)=delete
OTest2::AssertBufferPtr
std::shared_ptr< AssertBuffer > AssertBufferPtr
Definition: assertbufferptr.h:27
OTest2::ReporterTee::enterAssert
virtual AssertBufferPtr enterAssert(const Context &context_, bool condition_, const std::string &file_, int lineno_) override
Enter an assertion.
Definition: reportertee.cpp:214