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