OTest2
A C++ testing framework
testmarkprefix.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_TESTMARKPREFIX_H_
21 #define OTest2__INCLUDE_OTEST2_TESTMARKPREFIX_H_
22 
23 #include <string>
24 
25 #include <otest2/testmark.h>
26 #include <otest2/testmarkhash.h>
27 
28 namespace OTest2 {
29 
30 struct CtorMark;
31 
35 class TestMarkPrefix : public TestMark {
36  private:
37  const char* serialize_type_mark;
38  std::string prefix;
39 
40  protected:
42 
43  private:
44  /* -- test mark interface */
45  virtual TestMarkHashCode doGetHashCode() const noexcept;
46  virtual bool doIsEqual(
47  const TestMark& other_,
48  long double precision_) const;
49  virtual bool doIsEqualValue(
50  const TestMark& other_,
51  long double precision_) const;
52  virtual void doPrintOpen(
53  std::ostream& os_,
54  const std::string& prefix_) const;
55  virtual void doPrintClose(
56  std::ostream& os_,
57  const std::string& prefix_) const;
58  virtual void doSerializeMark(
59  TestMarkOut& serializer_) const;
60  virtual void doDeserializeMark(
61  TestMarkFactory& factory_,
62  TestMarkIn& deserializer_);
63 
71  virtual bool doIsEqualPrefixed(
72  const TestMark& other_,
73  long double precision_) const = 0;
74 
81  virtual const char* getParenthesis() const = 0;
82 
88  virtual void serializeItems(
89  TestMarkOut& serializer_) const = 0;
90 
97  virtual void deserializeItems(
98  TestMarkFactory& factory_,
99  TestMarkIn& deserializer_) = 0;
100 
101  protected:
109  explicit TestMarkPrefix(
110  const char* serialize_type_mark_,
111  const std::string& prefix_);
112 
116  explicit TestMarkPrefix(
117  const CtorMark*,
118  const char* serialize_type_mark_);
119 
123  virtual ~TestMarkPrefix();
124 
125  public:
126  /* -- avoid copying */
128  const TestMarkPrefix&) = delete;
129  TestMarkPrefix& operator =(
130  const TestMarkPrefix&) = delete;
131 };
132 
133 } /* namespace OTest2 */
134 
135 #endif /* OTest2__INCLUDE_OTEST2_TESTMARKPREFIX_H_ */
testmarkhash.h
OTest2::TestMarkIn
A generic interface of a testmark deserializer.
Definition: testmarkin.h:35
OTest2::TestMarkPrefix
A generic test mark with string prefix.
Definition: testmarkprefix.h:35
OTest2::TestMarkHashCode
std::uint64_t TestMarkHashCode
Definition: testmarkhashcode.h:28
OTest2::TestMarkPrefix::hash
TestMarkHash hash
Definition: testmarkprefix.h:41
OTest2::TestMarkOut
A generic interface of a serializer of test marks.
Definition: testmarkout.h:31
OTest2
Definition: assertbean.h:25
testmark.h
OTest2::TestMarkHash
A simple generator of a testmark hash.
Definition: testmarkhash.h:40
OTest2::TestMark
Generic interface of a test mark node.
Definition: testmark.h:41
OTest2::TestMarkFactory
A factory of testmark objects used for deserialization.
Definition: testmarkfactory.h:45