OTest2
A C++ testing framework
testmarkformatterios.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2021 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_TESTMARKFORMATTERIOS_H_
21 #define OTest2_INCLUDE_OTEST2_TESTMARKFORMATTERIOS_H_
22 
23 #include <iosfwd>
26 #include <string>
27 
28 namespace OTest2 {
29 
34  private:
35  std::ostream* os;
36  std::string prefix;
37 
38  void printLine(
39  const std::string& prefix_,
40  const std::string& label_,
41  const TestMark* mark_,
42  int indent_,
43  bool open_);
44 
45  virtual void setTextForeground(
46  Color color_);
47  virtual void setTextStyle(
48  Style style_);
49  virtual void resetTextAttributes();
50 
51  public:
52  /* -- avoid copying */
54  const TestMarkFormatterIOS&) = delete;
56  const TestMarkFormatterIOS&) = delete;
57 
64  explicit TestMarkFormatterIOS(
65  std::ostream* os_,
66  const std::string& prefix_);
67 
71  virtual ~TestMarkFormatterIOS();
72 
73  /* -- testmark formatter */
74  virtual void openMark(
75  const std::string& label_,
76  const TestMark* mark_,
77  int indent_) override;
78  virtual void closeMark(
79  const std::string& label_,
80  const TestMark* mark_,
81  int indent_) override;
82  virtual void openDeleted(
83  const std::string& label_,
84  const TestMark* mark_,
85  int indent_) override;
86  virtual void closeDeleted(
87  const std::string& label_,
88  const TestMark* mark_,
89  int indent_) override;
90  virtual void openAdded(
91  const std::string& label_,
92  const TestMark* mark_,
93  int indent_) override;
94  virtual void closeAdded(
95  const std::string& label_,
96  const TestMark* mark_,
97  int indent_) override;
98  virtual void printSeparator() override;
99 };
100 
101 } /* -- namespace OTest2 */
102 
103 #endif /* -- OTest2_INCLUDE_OTEST2_TESTMARKFORMATTERIOS_H_ */
OTest2::TestMarkFormatterIOS::closeAdded
virtual void closeAdded(const std::string &label_, const TestMark *mark_, int indent_) override
Print closing of an added testmark.
Definition: testmarkformatterios.cpp:115
OTest2::Style
Style
Style of shown text.
Definition: reporterattributes.h:44
OTest2::TestMarkFormatterIOS::printSeparator
virtual void printSeparator() override
Print separator (used for unchanged blocks)
Definition: testmarkformatterios.cpp:124
OTest2::TestMarkFormatterIOS::openDeleted
virtual void openDeleted(const std::string &label_, const TestMark *mark_, int indent_) override
Print opening of a deleted testmark.
Definition: testmarkformatterios.cpp:88
OTest2::TestMarkFormatterIOS::openAdded
virtual void openAdded(const std::string &label_, const TestMark *mark_, int indent_) override
Print opening of an added testmark.
Definition: testmarkformatterios.cpp:106
testmarkformatter.h
OTest2::TestMarkFormatterIOS::operator=
TestMarkFormatterIOS & operator=(const TestMarkFormatterIOS &)=delete
OTest2::Color
Color
List of colors supported by the reporters.
Definition: reporterattributes.h:30
OTest2
Definition: assertbean.h:25
OTest2::TestMarkFormatterIOS::closeDeleted
virtual void closeDeleted(const std::string &label_, const TestMark *mark_, int indent_) override
Print closing of a deleted testmark.
Definition: testmarkformatterios.cpp:97
reporterattributes.h
OTest2::TestMarkFormatterIOS::closeMark
virtual void closeMark(const std::string &label_, const TestMark *mark_, int indent_) override
Print closing of a testmark.
Definition: testmarkformatterios.cpp:81
OTest2::TestMarkFormatterIOS::~TestMarkFormatterIOS
virtual ~TestMarkFormatterIOS()
Dtor.
OTest2::TestMarkFormatterIOS::openMark
virtual void openMark(const std::string &label_, const TestMark *mark_, int indent_) override
Print opening of a testmark.
Definition: testmarkformatterios.cpp:74
OTest2::TestMark
Generic interface of a test mark node.
Definition: testmark.h:41
OTest2::TestMarkFormatter
Generic interface of the testmark formatter.
Definition: testmarkformatter.h:32
OTest2::TestMarkFormatterIOS::TestMarkFormatterIOS
TestMarkFormatterIOS(const TestMarkFormatterIOS &)=delete
OTest2::TestMarkFormatterIOS
Implementation of the testmark formatter based on an IO stream.
Definition: testmarkformatterios.h:33