OTest2
A C++ testing framework
assertbuffer.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_ASSERTBUFFER_H_
21 #define OTest2_INCLUDE_OTEST2_ASSERTBUFFER_H_
22 
23 #include <streambuf>
24 #include <otest2/assertbufferptr.h>
26 
27 namespace OTest2 {
28 
29 class Context;
30 
34 class AssertBuffer : public std::streambuf {
35  public:
36  /* -- avoid copying */
38  const AssertBuffer&) = delete;
40  const AssertBuffer&) = delete;
41 
45  AssertBuffer();
46 
50  virtual ~AssertBuffer();
51 
57  virtual void setForeground(
58  Color color_) = 0;
59 
65  virtual void setBackground(
66  Color color_) = 0;
67 
73  virtual void setTextStyle(
74  Style style_) = 0;
75 
79  virtual void resetAttributes() = 0;
80 
86  virtual void commitMessage(
87  const Context& context_) = 0;
88 
94  virtual void commitAssertion(
95  const Context& context_) = 0;
96 };
97 
98 } /* -- namespace OTest2 */
99 
100 #endif /* -- OTest2_INCLUDE_OTEST2_ASSERTBUFFER_H_ */
OTest2::Style
Style
Style of shown text.
Definition: reporterattributes.h:44
OTest2::AssertBuffer::commitMessage
virtual void commitMessage(const Context &context_)=0
Commit (flush) current assertion message.
OTest2::AssertBuffer::resetAttributes
virtual void resetAttributes()=0
Reset currently set text attributes.
OTest2::AssertBuffer::setTextStyle
virtual void setTextStyle(Style style_)=0
Set style of the shown text.
OTest2::AssertBuffer::setBackground
virtual void setBackground(Color color_)=0
Set background color.
OTest2::AssertBuffer::~AssertBuffer
virtual ~AssertBuffer()
Dtor.
OTest2::Color
Color
List of colors supported by the reporters.
Definition: reporterattributes.h:30
OTest2
Definition: assertbean.h:25
OTest2::AssertBuffer
Streambuffer interface used in the assertion API.
Definition: assertbuffer.h:34
reporterattributes.h
OTest2::AssertBuffer::operator=
AssertBuffer & operator=(const AssertBuffer &)=delete
OTest2::AssertBuffer::setForeground
virtual void setForeground(Color color_)=0
Set foreground color.
OTest2::AssertBuffer::commitAssertion
virtual void commitAssertion(const Context &context_)=0
Finish current assertion.
OTest2::Context
OTest2 runtime context.
Definition: context.h:38
OTest2::AssertBuffer::AssertBuffer
AssertBuffer()
Ctor.
assertbufferptr.h