OTest2
A C++ testing framework
testmarkstring.cpp
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 #include <testmarkstring.h>
20 
21 #include <assert.h>
22 #include <iostream>
23 #include <utility>
24 
25 #include <testmarkhash.h>
26 #include <testmarkin.h>
27 #include <testmarkout.h>
28 
29 namespace OTest2 {
30 
31 namespace {
32 
33 const char SERIALIZE_TYPE_MARK[] = "ot2:string";
34 
35 } /* -- namespace */
36 
38  const std::string& value_) :
39  value(value_) {
40 
41 }
42 
44  const CtorMark*) :
45  value() {
46 
47 }
48 
50 
51 }
52 
53 const char* TestMarkString::typeMark() {
54  return SERIALIZE_TYPE_MARK;
55 }
56 
57 TestMarkHashCode TestMarkString::doGetHashCode() const noexcept {
58  return TestMarkHash::hashBasicType(SERIALIZE_TYPE_MARK, value);
59 }
60 
61 bool TestMarkString::doIsEqual(
62  const TestMark& other_,
63  long double precision_) const {
64  return value == static_cast<const TestMarkString*>(&other_)->value;
65 }
66 
67 bool TestMarkString::doIsEqualValue(
68  const TestMark& other_,
69  long double precision_) const {
70  return doIsEqual(other_, precision_);
71 }
72 
73 void TestMarkString::doDiffArray(
74  int level_,
75  std::vector<LinearizedRecord>& array_) const
76 {
77  /* -- there are no children */
78 }
79 
80 void TestMarkString::doLinearizedMark(
81  int level_,
82  const std::string& label_,
83  std::vector<LinearizedRecord>& array_) const {
84  array_.push_back({level_, this, label_});
85 }
86 
87 void TestMarkString::doPrintOpen(
88  std::ostream& os_,
89  const std::string& prefix_) const {
90  os_ << prefix_ << '"' << value << "\"\n";
91 }
92 
93 void TestMarkString::doPrintClose(
94  std::ostream& os_,
95  const std::string& prefix_) const {
96  /* -- nothing to do */
97 }
98 
99 void TestMarkString::doSerializeMark(
100  TestMarkOut& serializer_) const {
101  serializer_.writeTypeMark(SERIALIZE_TYPE_MARK);
102  serializer_.writeString(value);
103 }
104 
105 void TestMarkString::doDeserializeMark(
106  TestMarkFactory& factory_,
107  TestMarkIn& deserializer_) {
108  value = deserializer_.readString();
109 }
110 
111 } /* namespace OTest2 */
testmarkstring.h
testmarkhash.h
OTest2::TestMarkString::TestMarkString
TestMarkString(const std::string &value_)
Ctor.
Definition: testmarkstring.cpp:37
OTest2::TestMarkHashCode
std::uint64_t TestMarkHashCode
Definition: testmarkhashcode.h:28
OTest2::TestMarkHash::hashBasicType
static TestMarkHashCode hashBasicType(const char *type_name_, Type_ value_)
Definition: testmarkhash.h:122
OTest2
Definition: assertbean.h:25
OTest2::TestMarkString::typeMark
static const char * typeMark()
Get deserialization typemark.
Definition: testmarkstring.cpp:53
testmarkin.h
OTest2::TestMarkString::~TestMarkString
virtual ~TestMarkString()
Dtor.
Definition: testmarkstring.cpp:49
testmarkout.h
value
std::string value
Definition: runnerfiltertags.cpp:503