OTest2
A C++ testing framework
assertcontext.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2019 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_ASSERTCONTEXT_H_
21 #define OTest2__INCLUDE_OTEST2_ASSERTCONTEXT_H_
22 
23 #include <initializer_list>
24 #include <string>
25 
26 namespace OTest2 {
27 
28 class AssertStream;
29 class Context;
30 
38  private:
39  const Context* context;
40  std::string file;
41  int lineno;
42  std::initializer_list<const char*> parameters;
43 
44  public:
45  /* -- avoid copying */
47  const AssertContext&) = delete;
49  const AssertContext&) = delete;
50 
62  explicit AssertContext(
63  const Context& context_,
64  const std::string& file_,
65  int lineno_,
66  std::initializer_list<const char*> parameters_);
67 
68  protected:
73 
74 
85  bool result_);
86 
100  bool condition_,
101  const std::string& message_,
102  bool print_expression_);
103 
107  const Context& otest2Context() const;
108 };
109 
110 } /* namespace OTest2 */
111 
112 #endif /* OTest2__INCLUDE_OTEST2_ASSERTCONTEXT_H_ */
OTest2::AssertContext::AssertContext
AssertContext(const AssertContext &)=delete
OTest2::AssertContext::~AssertContext
~AssertContext()
Dtor.
OTest2::AssertContext
Assertion context.
Definition: assertcontext.h:37
OTest2::AssertContext::enterAssertion
AssertStream enterAssertion(bool result_)
Enter an assertion.
Definition: assertcontext.cpp:45
OTest2::AssertContext::operator=
AssertContext & operator=(const AssertContext &)=delete
OTest2
Definition: assertbean.h:25
OTest2::AssertContext::simpleAssertionImpl
bool simpleAssertionImpl(bool condition_, const std::string &message_, bool print_expression_)
Implementation of a simple assertion.
Definition: assertcontext.cpp:58
OTest2::Context
OTest2 runtime context.
Definition: context.h:38
OTest2::AssertStream
Assertion stream.
Definition: assertstream.h:40
OTest2::AssertContext::otest2Context
const Context & otest2Context() const
Get the OTest2 context.
Definition: assertcontext.cpp:78