GCC Code Coverage Report | |||||||||||||||||||||
|
|||||||||||||||||||||
Line | Branch | Exec | Source |
1 |
#include <array> |
||
2 |
|||
3 |
#include "gtest/gtest.h" |
||
4 |
|||
5 |
#include "zserio/SerializeUtil.h" |
||
6 |
#include "zserio/Enums.h" |
||
7 |
#include "zserio/pmr/PolymorphicAllocator.h" |
||
8 |
|||
9 |
#include "test_object/std_allocator/SerializeEnum.h" |
||
10 |
#include "test_object/std_allocator/SerializeNested.h" |
||
11 |
#include "test_object/std_allocator/SerializeObject.h" |
||
12 |
#include "test_object/polymorphic_allocator/SerializeEnum.h" |
||
13 |
#include "test_object/polymorphic_allocator/SerializeNested.h" |
||
14 |
#include "test_object/polymorphic_allocator/SerializeObject.h" |
||
15 |
|||
16 |
namespace zserio |
||
17 |
{ |
||
18 |
|||
19 |
✓✗✓✗ ✓✗✗✓ |
802 |
TEST(SerializeUtilTest, serializeEnum) |
20 |
{ |
||
21 |
// without allocator |
||
22 |
{ |
||
23 |
const test_object::std_allocator::SerializeEnum serializeEnum = |
||
24 |
1 |
test_object::std_allocator::SerializeEnum::VALUE3; |
|
25 |
✓✗ | 2 |
const BitBuffer bitBuffer = serialize(serializeEnum); |
26 |
✓✗✗✓ ✗✗✗✗ ✗✗✓✗ |
1 |
ASSERT_EQ(8, bitBuffer.getBitSize()); |
27 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ ✓✗✓✗ |
1 |
ASSERT_EQ(0x02, bitBuffer.getData()[0]); |
28 |
} |
||
29 |
|||
30 |
// with std allocator |
||
31 |
{ |
||
32 |
2 |
const std::allocator<uint8_t> allocator; |
|
33 |
const test_object::std_allocator::SerializeEnum serializeEnum = |
||
34 |
1 |
test_object::std_allocator::SerializeEnum::VALUE3; |
|
35 |
✓✗✓✗ |
2 |
const BitBuffer bitBuffer = serialize(serializeEnum, allocator); |
36 |
✓✗✗✓ ✗✗✗✗ ✗✗✓✗ |
1 |
ASSERT_EQ(8, bitBuffer.getBitSize()); |
37 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ ✓✗✓✗ |
1 |
ASSERT_EQ(0x02, bitBuffer.getData()[0]); |
38 |
} |
||
39 |
|||
40 |
// with polymorphic allocator |
||
41 |
{ |
||
42 |
1 |
const pmr::PropagatingPolymorphicAllocator<> allocator; |
|
43 |
const test_object::polymorphic_allocator::SerializeEnum serializeEnum = |
||
44 |
1 |
test_object::polymorphic_allocator::SerializeEnum::VALUE3; |
|
45 |
const BasicBitBuffer<pmr::PropagatingPolymorphicAllocator<>> bitBuffer = |
||
46 |
✓✗ | 2 |
serialize(serializeEnum, allocator); |
47 |
✓✗✗✓ ✗✗✗✗ ✗✗✓✗ |
1 |
ASSERT_EQ(8, bitBuffer.getBitSize()); |
48 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ ✓✗✓✗ |
1 |
ASSERT_EQ(0x02, bitBuffer.getData()[0]); |
49 |
} |
||
50 |
} |
||
51 |
|||
52 |
✓✗✓✗ ✓✗✗✓ |
802 |
TEST(SerializeUtilTest, serializeParameterizedObject) |
53 |
{ |
||
54 |
1 |
const int8_t param = 0x12; |
|
55 |
1 |
const uint8_t offset = 0; |
|
56 |
1 |
const uint32_t optionalValue = 0xDEADCAFE; |
|
57 |
{ |
||
58 |
// without allocator |
||
59 |
✓✗ | 2 |
test_object::std_allocator::SerializeNested serializeNested(offset, optionalValue); |
60 |
✓✗✓✗ |
2 |
const BitBuffer bitBuffer = serialize(serializeNested, param); |
61 |
✓✗✗✓ ✗✗✗✗ ✗✗✓✗ |
1 |
ASSERT_EQ(40, bitBuffer.getBitSize()); |
62 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ ✓✗ |
1 |
ASSERT_EQ(0x01, bitBuffer.getData()[0]); |
63 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ ✓✗ |
1 |
ASSERT_EQ(0xDE, bitBuffer.getData()[1]); |
64 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ ✓✗ |
1 |
ASSERT_EQ(0xAD, bitBuffer.getData()[2]); |
65 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ ✓✗ |
1 |
ASSERT_EQ(0xCA, bitBuffer.getData()[3]); |
66 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ ✓✗✓✗ |
1 |
ASSERT_EQ(0xFE, bitBuffer.getData()[4]); |
67 |
} |
||
68 |
|||
69 |
{ |
||
70 |
// with std allocator |
||
71 |
2 |
const std::allocator<uint8_t> allocator; |
|
72 |
✓✗✓✗ |
2 |
test_object::std_allocator::SerializeNested serializeNested(offset, optionalValue, allocator); |
73 |
✓✗✓✗ |
2 |
const BitBuffer bitBuffer = serialize(serializeNested, allocator, param); |
74 |
✓✗✗✓ ✗✗✗✗ ✗✗✓✗ |
1 |
ASSERT_EQ(40, bitBuffer.getBitSize()); |
75 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ ✓✗ |
1 |
ASSERT_EQ(0x01, bitBuffer.getData()[0]); |
76 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ ✓✗ |
1 |
ASSERT_EQ(0xDE, bitBuffer.getData()[1]); |
77 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ ✓✗ |
1 |
ASSERT_EQ(0xAD, bitBuffer.getData()[2]); |
78 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ ✓✗ |
1 |
ASSERT_EQ(0xCA, bitBuffer.getData()[3]); |
79 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ ✓✗✓✗ |
1 |
ASSERT_EQ(0xFE, bitBuffer.getData()[4]); |
80 |
} |
||
81 |
|||
82 |
{ |
||
83 |
// with polymorphic allocator |
||
84 |
1 |
const pmr::PropagatingPolymorphicAllocator<> allocator; |
|
85 |
✓✗ | 2 |
test_object::polymorphic_allocator::SerializeNested serializeNested(offset, optionalValue, allocator); |
86 |
const BasicBitBuffer<pmr::PropagatingPolymorphicAllocator<>> bitBuffer = |
||
87 |
✓✗✓✗ |
2 |
serialize(serializeNested, allocator, param); |
88 |
✓✗✗✓ ✗✗✗✗ ✗✗✓✗ |
1 |
ASSERT_EQ(40, bitBuffer.getBitSize()); |
89 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ ✓✗ |
1 |
ASSERT_EQ(0x01, bitBuffer.getData()[0]); |
90 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ ✓✗ |
1 |
ASSERT_EQ(0xDE, bitBuffer.getData()[1]); |
91 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ ✓✗ |
1 |
ASSERT_EQ(0xAD, bitBuffer.getData()[2]); |
92 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ ✓✗ |
1 |
ASSERT_EQ(0xCA, bitBuffer.getData()[3]); |
93 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ ✓✗✓✗ |
1 |
ASSERT_EQ(0xFE, bitBuffer.getData()[4]); |
94 |
} |
||
95 |
} |
||
96 |
|||
97 |
✓✗✓✗ ✓✗✗✓ |
802 |
TEST(SerializeUtilTest, serializeObject) |
98 |
{ |
||
99 |
1 |
const int8_t param = 0x12; |
|
100 |
1 |
const uint8_t offset = 0; |
|
101 |
1 |
const uint32_t optionalValue = 0xDEADCAFE; |
|
102 |
{ |
||
103 |
// without allocator |
||
104 |
✓✗ | 2 |
test_object::std_allocator::SerializeNested serializeNested(offset, optionalValue); |
105 |
✓✗✓✗ |
2 |
test_object::std_allocator::SerializeObject serializeObject(param, serializeNested); |
106 |
✓✗✓✗ |
2 |
const BitBuffer bitBuffer = serialize(serializeObject); |
107 |
✓✗✗✓ ✗✗✗✗ ✗✗✓✗ |
1 |
ASSERT_EQ(48, bitBuffer.getBitSize()); |
108 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ ✓✗ |
1 |
ASSERT_EQ(0x12, bitBuffer.getData()[0]); |
109 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ ✓✗ |
1 |
ASSERT_EQ(0x02, bitBuffer.getData()[1]); |
110 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ ✓✗ |
1 |
ASSERT_EQ(0xDE, bitBuffer.getData()[2]); |
111 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ ✓✗ |
1 |
ASSERT_EQ(0xAD, bitBuffer.getData()[3]); |
112 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ ✓✗ |
1 |
ASSERT_EQ(0xCA, bitBuffer.getData()[4]); |
113 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ ✓✗✓✗ |
1 |
ASSERT_EQ(0xFE, bitBuffer.getData()[5]); |
114 |
} |
||
115 |
|||
116 |
{ |
||
117 |
// with std allocator |
||
118 |
2 |
const std::allocator<uint8_t> allocator; |
|
119 |
✓✗✓✗ |
2 |
test_object::std_allocator::SerializeNested serializeNested(offset, optionalValue, allocator); |
120 |
✓✗✓✗ |
2 |
test_object::std_allocator::SerializeObject serializeObject(param, serializeNested, allocator); |
121 |
✓✗✓✗ |
2 |
const BitBuffer bitBuffer = serialize(serializeObject, allocator); |
122 |
✓✗✗✓ ✗✗✗✗ ✗✗✓✗ |
1 |
ASSERT_EQ(48, bitBuffer.getBitSize()); |
123 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ ✓✗ |
1 |
ASSERT_EQ(0x12, bitBuffer.getData()[0]); |
124 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ ✓✗ |
1 |
ASSERT_EQ(0x02, bitBuffer.getData()[1]); |
125 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ ✓✗ |
1 |
ASSERT_EQ(0xDE, bitBuffer.getData()[2]); |
126 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ ✓✗ |
1 |
ASSERT_EQ(0xAD, bitBuffer.getData()[3]); |
127 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ ✓✗ |
1 |
ASSERT_EQ(0xCA, bitBuffer.getData()[4]); |
128 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ ✓✗✓✗ |
1 |
ASSERT_EQ(0xFE, bitBuffer.getData()[5]); |
129 |
} |
||
130 |
|||
131 |
{ |
||
132 |
// with polymorphic allocator |
||
133 |
1 |
const pmr::PropagatingPolymorphicAllocator<> allocator; |
|
134 |
✓✗ | 2 |
test_object::polymorphic_allocator::SerializeNested serializeNested(offset, optionalValue, allocator); |
135 |
✓✗✓✗ |
2 |
test_object::polymorphic_allocator::SerializeObject serializeObject(param, serializeNested, allocator); |
136 |
const BasicBitBuffer<pmr::PropagatingPolymorphicAllocator<>> bitBuffer = |
||
137 |
✓✗✓✗ |
2 |
serialize(serializeObject, allocator); |
138 |
✓✗✗✓ ✗✗✗✗ ✗✗✓✗ |
1 |
ASSERT_EQ(48, bitBuffer.getBitSize()); |
139 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ ✓✗ |
1 |
ASSERT_EQ(0x12, bitBuffer.getData()[0]); |
140 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ ✓✗ |
1 |
ASSERT_EQ(0x02, bitBuffer.getData()[1]); |
141 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ ✓✗ |
1 |
ASSERT_EQ(0xDE, bitBuffer.getData()[2]); |
142 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ ✓✗ |
1 |
ASSERT_EQ(0xAD, bitBuffer.getData()[3]); |
143 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ ✓✗ |
1 |
ASSERT_EQ(0xCA, bitBuffer.getData()[4]); |
144 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ ✓✗✓✗ |
1 |
ASSERT_EQ(0xFE, bitBuffer.getData()[5]); |
145 |
} |
||
146 |
} |
||
147 |
|||
148 |
✓✗✓✗ ✓✗✗✓ |
802 |
TEST(SerializeUtilTest, deserializeEnum) |
149 |
{ |
||
150 |
1 |
const std::array<uint8_t, 1> buffer = {0x02}; |
|
151 |
// without allocator |
||
152 |
{ |
||
153 |
✓✗ | 2 |
const BitBuffer bitBuffer(buffer.data(), buffer.size() * 8); |
154 |
const test_object::std_allocator::SerializeEnum serializeEnum = |
||
155 |
✓✗ | 1 |
deserialize<test_object::std_allocator::SerializeEnum>(bitBuffer); |
156 |
✓✗✗✓ ✗✗✗✗ ✗✗✓✗ ✓✗ |
1 |
ASSERT_EQ(test_object::std_allocator::SerializeEnum::VALUE3, serializeEnum); |
157 |
} |
||
158 |
|||
159 |
// with std allocator |
||
160 |
{ |
||
161 |
2 |
const std::allocator<uint8_t> allocator; |
|
162 |
✓✗✓✗ |
2 |
const BitBuffer bitBuffer(buffer.data(), buffer.size() * 8, allocator); |
163 |
const test_object::std_allocator::SerializeEnum serializeEnum = |
||
164 |
✓✗ | 1 |
deserialize<test_object::std_allocator::SerializeEnum>(bitBuffer); |
165 |
✓✗✗✓ ✗✗✗✗ ✗✗✓✗ ✓✗ |
1 |
ASSERT_EQ(test_object::std_allocator::SerializeEnum::VALUE3, serializeEnum); |
166 |
} |
||
167 |
|||
168 |
// with polymorphic allocator |
||
169 |
{ |
||
170 |
1 |
const pmr::PropagatingPolymorphicAllocator<> allocator; |
|
171 |
1 |
const BasicBitBuffer<pmr::PropagatingPolymorphicAllocator<>> bitBuffer(buffer.data(), buffer.size() * 8, |
|
172 |
✓✗ | 2 |
allocator); |
173 |
const test_object::polymorphic_allocator::SerializeEnum serializeEnum = |
||
174 |
✓✗ | 1 |
deserialize<test_object::polymorphic_allocator::SerializeEnum>(bitBuffer); |
175 |
✓✗✗✓ ✗✗✗✗ ✗✗✓✗ ✓✗ |
1 |
ASSERT_EQ(test_object::polymorphic_allocator::SerializeEnum::VALUE3, serializeEnum); |
176 |
} |
||
177 |
} |
||
178 |
|||
179 |
✓✗✓✗ ✓✗✗✓ |
802 |
TEST(SerializeUtilTest, deserializeNestedObject) |
180 |
{ |
||
181 |
1 |
const std::array<uint8_t, 5> buffer = {0x01, 0xDE, 0xAD, 0xCA, 0xFE}; |
|
182 |
1 |
const int8_t param = 0x12; |
|
183 |
// without allocator |
||
184 |
{ |
||
185 |
✓✗ | 2 |
const BitBuffer bitBuffer(buffer.data(), buffer.size() * 8); |
186 |
const test_object::std_allocator::SerializeNested serializeNested = |
||
187 |
✓✗✓✗ |
2 |
deserialize<test_object::std_allocator::SerializeNested>(bitBuffer, param); |
188 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ ✓✗ |
1 |
ASSERT_EQ(param, serializeNested.getParam()); |
189 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ ✓✗ |
1 |
ASSERT_EQ(0x01, serializeNested.getOffset()); |
190 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ ✓✗ |
1 |
ASSERT_EQ(0xDEADCAFE, serializeNested.getOptionalValue()); |
191 |
|||
192 |
✓✗✓✗ ✓✗✗ |
2 |
const BitBuffer wrongBitBuffer(buffer.data(), buffer.size() * 8 - 1); |
193 |
✓✗✓✗ ✓✗✗✓ ✗✓✗✗ ✗✗✗✗ ✗✗✓✗ ✓✗✓✗ ✗✗✗✗ ✗✗✗✗ ✗✗✗✗ ✗✗✗✗ |
2 |
ASSERT_THROW(deserialize<test_object::std_allocator::SerializeNested>(wrongBitBuffer, param), |
194 |
CppRuntimeException); |
||
195 |
} |
||
196 |
|||
197 |
// with std allocator |
||
198 |
{ |
||
199 |
2 |
const std::allocator<uint8_t> allocator; |
|
200 |
✓✗✓✗ |
2 |
const BitBuffer bitBuffer(buffer.data(), buffer.size() * 8, allocator); |
201 |
const test_object::std_allocator::SerializeNested serializeNested = |
||
202 |
✓✗✓✗ |
2 |
deserialize<test_object::std_allocator::SerializeNested>(bitBuffer, param, allocator); |
203 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ ✓✗ |
1 |
ASSERT_EQ(param, serializeNested.getParam()); |
204 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ ✓✗ |
1 |
ASSERT_EQ(0x01, serializeNested.getOffset()); |
205 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ ✓✗✓✗ ✗ |
1 |
ASSERT_EQ(0xDEADCAFE, serializeNested.getOptionalValue()); |
206 |
|||
207 |
✓✗✓✗ |
2 |
const BitBuffer wrongBitBuffer(buffer.data(), buffer.size() * 8 - 1, allocator); |
208 |
✓✗✓✗ ✓✗✗✓ ✗✓✗✗ ✗✗✗✗ ✗✗✓✗ ✓✗✓✗ ✗✗✗✗ ✗✗✗✗ ✗✗✗✗ ✗✗✗✗ |
2 |
ASSERT_THROW(deserialize<test_object::std_allocator::SerializeNested>(wrongBitBuffer, param, allocator), |
209 |
CppRuntimeException); |
||
210 |
} |
||
211 |
|||
212 |
// with polymorphic allocator |
||
213 |
{ |
||
214 |
1 |
const pmr::PropagatingPolymorphicAllocator<> allocator; |
|
215 |
1 |
const BasicBitBuffer<pmr::PropagatingPolymorphicAllocator<>> bitBuffer(buffer.data(), buffer.size() * 8, |
|
216 |
✓✗ | 2 |
allocator); |
217 |
const test_object::polymorphic_allocator::SerializeNested serializeNested = |
||
218 |
✓✗✓✗ |
2 |
deserialize<test_object::polymorphic_allocator::SerializeNested>(bitBuffer, param, allocator); |
219 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ ✓✗ |
1 |
ASSERT_EQ(param, serializeNested.getParam()); |
220 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ ✓✗ |
1 |
ASSERT_EQ(0x01, serializeNested.getOffset()); |
221 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ ✓✗✓✗ ✗ |
1 |
ASSERT_EQ(0xDEADCAFE, serializeNested.getOptionalValue()); |
222 |
|||
223 |
const BasicBitBuffer<pmr::PropagatingPolymorphicAllocator<>> wrongBitBuffer(buffer.data(), |
||
224 |
✓✗✓✗ |
2 |
buffer.size() * 8 - 1, allocator); |
225 |
✓✗✓✗ ✓✗✗✓ ✗✓✗✗ ✗✗✗✗ ✗✗✓✗ ✓✗✓✗ ✗✗✗✗ ✗✗✗✗ ✗✗✗✗ ✗✗✗✗ |
2 |
ASSERT_THROW(deserialize<test_object::polymorphic_allocator::SerializeNested>(wrongBitBuffer, |
226 |
param, allocator), CppRuntimeException); |
||
227 |
} |
||
228 |
} |
||
229 |
|||
230 |
✓✗✓✗ ✓✗✗✓ |
802 |
TEST(SerializeUtilTest, deserializeObject) |
231 |
{ |
||
232 |
1 |
const std::array<uint8_t, 6> buffer = {0x12, 0x02, 0xDE, 0xAD, 0xCA, 0xFE}; |
|
233 |
// without allocator |
||
234 |
{ |
||
235 |
✓✗ | 2 |
const BitBuffer bitBuffer(buffer.data(), buffer.size() * 8); |
236 |
const test_object::std_allocator::SerializeObject serializeObject = |
||
237 |
✓✗✓✗ |
2 |
deserialize<test_object::std_allocator::SerializeObject>(bitBuffer); |
238 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ ✓✗ |
1 |
ASSERT_EQ(0x12, serializeObject.getParam()); |
239 |
✓✗ | 1 |
const test_object::std_allocator::SerializeNested& serializeNested = serializeObject.getNested(); |
240 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ ✓✗ |
1 |
ASSERT_EQ(0x12, serializeNested.getParam()); |
241 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ ✓✗ |
1 |
ASSERT_EQ(0x02, serializeNested.getOffset()); |
242 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ ✓✗✓✗ |
1 |
ASSERT_EQ(0xDEADCAFE, serializeNested.getOptionalValue()); |
243 |
} |
||
244 |
|||
245 |
// with std allocator |
||
246 |
{ |
||
247 |
2 |
const std::allocator<uint8_t> allocator; |
|
248 |
✓✗✓✗ |
2 |
const BitBuffer bitBuffer(buffer.data(), buffer.size() * 8, allocator); |
249 |
const test_object::std_allocator::SerializeObject serializeObject = |
||
250 |
✓✗✓✗ |
2 |
deserialize<test_object::std_allocator::SerializeObject>(bitBuffer, allocator); |
251 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ ✓✗ |
1 |
ASSERT_EQ(0x12, serializeObject.getParam()); |
252 |
✓✗ | 1 |
const test_object::std_allocator::SerializeNested& serializeNested = serializeObject.getNested(); |
253 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ ✓✗ |
1 |
ASSERT_EQ(0x12, serializeNested.getParam()); |
254 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ ✓✗ |
1 |
ASSERT_EQ(0x02, serializeNested.getOffset()); |
255 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ ✓✗✓✗ |
1 |
ASSERT_EQ(0xDEADCAFE, serializeNested.getOptionalValue()); |
256 |
} |
||
257 |
|||
258 |
// with polymorphic allocator |
||
259 |
{ |
||
260 |
1 |
const pmr::PropagatingPolymorphicAllocator<> allocator; |
|
261 |
1 |
const BasicBitBuffer<pmr::PropagatingPolymorphicAllocator<>> bitBuffer(buffer.data(), buffer.size() * 8, |
|
262 |
✓✗ | 2 |
allocator); |
263 |
const test_object::polymorphic_allocator::SerializeObject serializeObject = |
||
264 |
✓✗✓✗ |
2 |
deserialize<test_object::polymorphic_allocator::SerializeObject>(bitBuffer, allocator); |
265 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ ✓✗ |
1 |
ASSERT_EQ(0x12, serializeObject.getParam()); |
266 |
const test_object::polymorphic_allocator::SerializeNested& serializeNested = |
||
267 |
✓✗ | 1 |
serializeObject.getNested(); |
268 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ ✓✗ |
1 |
ASSERT_EQ(0x12, serializeNested.getParam()); |
269 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ ✓✗ |
1 |
ASSERT_EQ(0x02, serializeNested.getOffset()); |
270 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ ✓✗✓✗ |
1 |
ASSERT_EQ(0xDEADCAFE, serializeNested.getOptionalValue()); |
271 |
} |
||
272 |
} |
||
273 |
|||
274 |
✓✗✓✗ ✓✗✗✓ |
802 |
TEST(SerializeUtilTest, serializeEnumToBytes) |
275 |
{ |
||
276 |
// without allocator |
||
277 |
{ |
||
278 |
const test_object::std_allocator::SerializeEnum serializeEnum = |
||
279 |
1 |
test_object::std_allocator::SerializeEnum::VALUE3; |
|
280 |
✓✗ | 2 |
const vector<uint8_t> buffer = serializeToBytes(serializeEnum); |
281 |
✓✗✗✓ ✗✗✗✗ ✗✗✓✗ |
1 |
ASSERT_EQ(1, buffer.size()); |
282 |
✓✗✗✓ ✗✗✗✗ ✗✗✓✗ ✓✗ |
1 |
ASSERT_EQ(0x02, buffer[0]); |
283 |
} |
||
284 |
|||
285 |
// with std allocator |
||
286 |
{ |
||
287 |
2 |
const std::allocator<uint8_t> allocator; |
|
288 |
const test_object::std_allocator::SerializeEnum serializeEnum = |
||
289 |
1 |
test_object::std_allocator::SerializeEnum::VALUE3; |
|
290 |
✓✗✓✗ |
2 |
const vector<uint8_t> buffer = serializeToBytes(serializeEnum, allocator); |
291 |
✓✗✗✓ ✗✗✗✗ ✗✗✓✗ |
1 |
ASSERT_EQ(1, buffer.size()); |
292 |
✓✗✗✓ ✗✗✗✗ ✗✗✓✗ ✓✗ |
1 |
ASSERT_EQ(0x02, buffer[0]); |
293 |
} |
||
294 |
|||
295 |
// with polymorphic allocator |
||
296 |
{ |
||
297 |
1 |
const pmr::PropagatingPolymorphicAllocator<> allocator; |
|
298 |
const test_object::polymorphic_allocator::SerializeEnum serializeEnum = |
||
299 |
1 |
test_object::polymorphic_allocator::SerializeEnum::VALUE3; |
|
300 |
const vector<uint8_t, pmr::PropagatingPolymorphicAllocator<>> buffer = |
||
301 |
✓✗ | 2 |
serializeToBytes(serializeEnum, allocator); |
302 |
✓✗✗✓ ✗✗✗✗ ✗✗✓✗ |
1 |
ASSERT_EQ(1, buffer.size()); |
303 |
✓✗✗✓ ✗✗✗✗ ✗✗✓✗ ✓✗ |
1 |
ASSERT_EQ(0x02, buffer[0]); |
304 |
} |
||
305 |
} |
||
306 |
|||
307 |
✓✗✓✗ ✓✗✗✓ |
802 |
TEST(SerializeUtilTest, serializeParameterizedObjectToBytes) |
308 |
{ |
||
309 |
1 |
const int8_t param = 0x12; |
|
310 |
1 |
const uint8_t offset = 0; |
|
311 |
1 |
const uint32_t optionalValue = 0xDEADCAFE; |
|
312 |
{ |
||
313 |
// without allocator |
||
314 |
✓✗ | 2 |
test_object::std_allocator::SerializeNested serializeNested(offset, optionalValue); |
315 |
✓✗✓✗ |
2 |
const vector<uint8_t> buffer = serializeToBytes(serializeNested, param); |
316 |
✓✗✗✓ ✗✗✗✗ ✗✗✓✗ |
1 |
ASSERT_EQ(5, buffer.size()); |
317 |
✓✗✗✓ ✗✗✗✗ ✗✗✓✗ |
1 |
ASSERT_EQ(0x01, buffer[0]); |
318 |
✓✗✗✓ ✗✗✗✗ ✗✗✓✗ |
1 |
ASSERT_EQ(0xDE, buffer[1]); |
319 |
✓✗✗✓ ✗✗✗✗ ✗✗✓✗ |
1 |
ASSERT_EQ(0xAD, buffer[2]); |
320 |
✓✗✗✓ ✗✗✗✗ ✗✗✓✗ |
1 |
ASSERT_EQ(0xCA, buffer[3]); |
321 |
✓✗✗✓ ✗✗✗✗ ✗✗✓✗ ✓✗ |
1 |
ASSERT_EQ(0xFE, buffer[4]); |
322 |
} |
||
323 |
|||
324 |
{ |
||
325 |
// with std allocator |
||
326 |
2 |
const std::allocator<uint8_t> allocator; |
|
327 |
✓✗✓✗ |
2 |
test_object::std_allocator::SerializeNested serializeNested(offset, optionalValue, allocator); |
328 |
✓✗✓✗ |
2 |
const vector<uint8_t> buffer = serializeToBytes(serializeNested, allocator, param); |
329 |
✓✗✗✓ ✗✗✗✗ ✗✗✓✗ |
1 |
ASSERT_EQ(5, buffer.size()); |
330 |
✓✗✗✓ ✗✗✗✗ ✗✗✓✗ |
1 |
ASSERT_EQ(0x01, buffer[0]); |
331 |
✓✗✗✓ ✗✗✗✗ ✗✗✓✗ |
1 |
ASSERT_EQ(0xDE, buffer[1]); |
332 |
✓✗✗✓ ✗✗✗✗ ✗✗✓✗ |
1 |
ASSERT_EQ(0xAD, buffer[2]); |
333 |
✓✗✗✓ ✗✗✗✗ ✗✗✓✗ |
1 |
ASSERT_EQ(0xCA, buffer[3]); |
334 |
✓✗✗✓ ✗✗✗✗ ✗✗✓✗ ✓✗ |
1 |
ASSERT_EQ(0xFE, buffer[4]); |
335 |
} |
||
336 |
|||
337 |
{ |
||
338 |
// with polymorphic allocator |
||
339 |
1 |
const pmr::PropagatingPolymorphicAllocator<> allocator; |
|
340 |
✓✗ | 2 |
test_object::polymorphic_allocator::SerializeNested serializeNested(offset, optionalValue, allocator); |
341 |
const vector<uint8_t, pmr::PropagatingPolymorphicAllocator<>> buffer = |
||
342 |
✓✗✓✗ |
2 |
serializeToBytes(serializeNested, allocator, param); |
343 |
✓✗✗✓ ✗✗✗✗ ✗✗✓✗ |
1 |
ASSERT_EQ(5, buffer.size()); |
344 |
✓✗✗✓ ✗✗✗✗ ✗✗✓✗ |
1 |
ASSERT_EQ(0x01, buffer[0]); |
345 |
✓✗✗✓ ✗✗✗✗ ✗✗✓✗ |
1 |
ASSERT_EQ(0xDE, buffer[1]); |
346 |
✓✗✗✓ ✗✗✗✗ ✗✗✓✗ |
1 |
ASSERT_EQ(0xAD, buffer[2]); |
347 |
✓✗✗✓ ✗✗✗✗ ✗✗✓✗ |
1 |
ASSERT_EQ(0xCA, buffer[3]); |
348 |
✓✗✗✓ ✗✗✗✗ ✗✗✓✗ ✓✗ |
1 |
ASSERT_EQ(0xFE, buffer[4]); |
349 |
} |
||
350 |
} |
||
351 |
|||
352 |
✓✗✓✗ ✓✗✗✓ |
802 |
TEST(SerializeUtilTest, serializeObjectToBytes) |
353 |
{ |
||
354 |
1 |
const int8_t param = 0x12; |
|
355 |
1 |
const uint8_t offset = 0; |
|
356 |
1 |
const uint32_t optionalValue = 0xDEADCAFE; |
|
357 |
{ |
||
358 |
// without allocator |
||
359 |
✓✗ | 2 |
test_object::std_allocator::SerializeNested serializeNested(offset, optionalValue); |
360 |
✓✗✓✗ |
2 |
test_object::std_allocator::SerializeObject serializeObject(param, serializeNested); |
361 |
✓✗✓✗ |
2 |
const vector<uint8_t> buffer = serializeToBytes(serializeObject); |
362 |
✓✗✗✓ ✗✗✗✗ ✗✗✓✗ |
1 |
ASSERT_EQ(6, buffer.size()); |
363 |
✓✗✗✓ ✗✗✗✗ ✗✗✓✗ |
1 |
ASSERT_EQ(0x12, buffer[0]); |
364 |
✓✗✗✓ ✗✗✗✗ ✗✗✓✗ |
1 |
ASSERT_EQ(0x02, buffer[1]); |
365 |
✓✗✗✓ ✗✗✗✗ ✗✗✓✗ |
1 |
ASSERT_EQ(0xDE, buffer[2]); |
366 |
✓✗✗✓ ✗✗✗✗ ✗✗✓✗ |
1 |
ASSERT_EQ(0xAD, buffer[3]); |
367 |
✓✗✗✓ ✗✗✗✗ ✗✗✓✗ |
1 |
ASSERT_EQ(0xCA, buffer[4]); |
368 |
✓✗✗✓ ✗✗✗✗ ✗✗✓✗ ✓✗ |
1 |
ASSERT_EQ(0xFE, buffer[5]); |
369 |
} |
||
370 |
|||
371 |
{ |
||
372 |
// with std allocator |
||
373 |
2 |
const std::allocator<uint8_t> allocator; |
|
374 |
✓✗✓✗ |
2 |
test_object::std_allocator::SerializeNested serializeNested(offset, optionalValue, allocator); |
375 |
✓✗✓✗ |
2 |
test_object::std_allocator::SerializeObject serializeObject(param, serializeNested, allocator); |
376 |
✓✗✓✗ |
2 |
const vector<uint8_t> buffer = serializeToBytes(serializeObject, allocator); |
377 |
✓✗✗✓ ✗✗✗✗ ✗✗✓✗ |
1 |
ASSERT_EQ(6, buffer.size()); |
378 |
✓✗✗✓ ✗✗✗✗ ✗✗✓✗ |
1 |
ASSERT_EQ(0x12, buffer[0]); |
379 |
✓✗✗✓ ✗✗✗✗ ✗✗✓✗ |
1 |
ASSERT_EQ(0x02, buffer[1]); |
380 |
✓✗✗✓ ✗✗✗✗ ✗✗✓✗ |
1 |
ASSERT_EQ(0xDE, buffer[2]); |
381 |
✓✗✗✓ ✗✗✗✗ ✗✗✓✗ |
1 |
ASSERT_EQ(0xAD, buffer[3]); |
382 |
✓✗✗✓ ✗✗✗✗ ✗✗✓✗ |
1 |
ASSERT_EQ(0xCA, buffer[4]); |
383 |
✓✗✗✓ ✗✗✗✗ ✗✗✓✗ ✓✗ |
1 |
ASSERT_EQ(0xFE, buffer[5]); |
384 |
} |
||
385 |
|||
386 |
{ |
||
387 |
// with polymorphic allocator |
||
388 |
1 |
const pmr::PropagatingPolymorphicAllocator<> allocator; |
|
389 |
✓✗ | 2 |
test_object::polymorphic_allocator::SerializeNested serializeNested(offset, optionalValue, allocator); |
390 |
✓✗✓✗ |
2 |
test_object::polymorphic_allocator::SerializeObject serializeObject(param, serializeNested, allocator); |
391 |
const vector<uint8_t, pmr::PropagatingPolymorphicAllocator<>> buffer = |
||
392 |
✓✗✓✗ |
2 |
serializeToBytes(serializeObject, allocator); |
393 |
✓✗✗✓ ✗✗✗✗ ✗✗✓✗ |
1 |
ASSERT_EQ(6, buffer.size()); |
394 |
✓✗✗✓ ✗✗✗✗ ✗✗✓✗ |
1 |
ASSERT_EQ(0x12, buffer[0]); |
395 |
✓✗✗✓ ✗✗✗✗ ✗✗✓✗ |
1 |
ASSERT_EQ(0x02, buffer[1]); |
396 |
✓✗✗✓ ✗✗✗✗ ✗✗✓✗ |
1 |
ASSERT_EQ(0xDE, buffer[2]); |
397 |
✓✗✗✓ ✗✗✗✗ ✗✗✓✗ |
1 |
ASSERT_EQ(0xAD, buffer[3]); |
398 |
✓✗✗✓ ✗✗✗✗ ✗✗✓✗ |
1 |
ASSERT_EQ(0xCA, buffer[4]); |
399 |
✓✗✗✓ ✗✗✗✗ ✗✗✓✗ ✓✗ |
1 |
ASSERT_EQ(0xFE, buffer[5]); |
400 |
} |
||
401 |
} |
||
402 |
|||
403 |
✓✗✓✗ ✓✗✗✓ |
802 |
TEST(SerializeUtilTest, deserializeEnumFromBytes) |
404 |
{ |
||
405 |
// without allocator |
||
406 |
{ |
||
407 |
✓✗ | 2 |
const vector<uint8_t> buffer({0x02}); |
408 |
const test_object::std_allocator::SerializeEnum serializeEnum = |
||
409 |
✓✗✓✗ |
1 |
deserializeFromBytes<test_object::std_allocator::SerializeEnum>(buffer); |
410 |
✓✗✗✓ ✗✗✗✗ ✗✗✓✗ ✓✗ |
1 |
ASSERT_EQ(test_object::std_allocator::SerializeEnum::VALUE3, serializeEnum); |
411 |
} |
||
412 |
|||
413 |
// with std allocator |
||
414 |
{ |
||
415 |
2 |
const std::allocator<uint8_t> allocator; |
|
416 |
✓✗✓✗ |
2 |
const vector<uint8_t> buffer({0x02}, allocator); |
417 |
const test_object::std_allocator::SerializeEnum serializeEnum = |
||
418 |
✓✗✓✗ |
1 |
deserializeFromBytes<test_object::std_allocator::SerializeEnum>(buffer); |
419 |
✓✗✗✓ ✗✗✗✗ ✗✗✓✗ ✓✗ |
1 |
ASSERT_EQ(test_object::std_allocator::SerializeEnum::VALUE3, serializeEnum); |
420 |
} |
||
421 |
|||
422 |
// with polymorphic allocator |
||
423 |
{ |
||
424 |
1 |
const pmr::PropagatingPolymorphicAllocator<> allocator; |
|
425 |
✓✗ | 2 |
const vector<uint8_t, pmr::PropagatingPolymorphicAllocator<>> buffer({0x02}, allocator); |
426 |
const test_object::polymorphic_allocator::SerializeEnum serializeEnum = |
||
427 |
✓✗✓✗ |
1 |
deserializeFromBytes<test_object::polymorphic_allocator::SerializeEnum>(buffer); |
428 |
✓✗✗✓ ✗✗✗✗ ✗✗✓✗ ✓✗ |
1 |
ASSERT_EQ(test_object::polymorphic_allocator::SerializeEnum::VALUE3, serializeEnum); |
429 |
} |
||
430 |
} |
||
431 |
|||
432 |
✓✗✓✗ ✓✗✗✓ |
802 |
TEST(SerializeUtilTest, deserializeNestedObjectFromBytes) |
433 |
{ |
||
434 |
1 |
const int8_t param = 0x12; |
|
435 |
// without allocator |
||
436 |
{ |
||
437 |
✓✗ | 2 |
const vector<uint8_t> buffer({0x01, 0xDE, 0xAD, 0xCA, 0xFE}); |
438 |
const test_object::std_allocator::SerializeNested serializeNested = |
||
439 |
✓✗✓✗ ✓✗ |
2 |
deserializeFromBytes<test_object::std_allocator::SerializeNested>(buffer, param); |
440 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ ✓✗ |
1 |
ASSERT_EQ(param, serializeNested.getParam()); |
441 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ ✓✗ |
1 |
ASSERT_EQ(0x01, serializeNested.getOffset()); |
442 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ ✓✗ |
1 |
ASSERT_EQ(0xDEADCAFE, serializeNested.getOptionalValue()); |
443 |
|||
444 |
✓✗✓✗ |
2 |
const vector<uint8_t> wrongBuffer = {0x00, 0xDE, 0xAD, 0xCA, 0xFE}; |
445 |
✓✗✓✗ ✓✗✓✗ ✗✓✗✓ ✗✗✗✗ ✗✗✗✗ ✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✗✗ ✗✗✗✗ ✗✗✗✗ ✗ |
2 |
ASSERT_THROW(deserializeFromBytes<test_object::std_allocator::SerializeNested>(wrongBuffer, param), |
446 |
CppRuntimeException); |
||
447 |
} |
||
448 |
|||
449 |
// with std allocator |
||
450 |
{ |
||
451 |
2 |
const std::allocator<uint8_t> allocator; |
|
452 |
✓✗✓✗ |
2 |
const vector<uint8_t> buffer({0x01, 0xDE, 0xAD, 0xCA, 0xFE}, allocator); |
453 |
const test_object::std_allocator::SerializeNested serializeNested = |
||
454 |
✓✗✓✗ ✓✗ |
2 |
deserializeFromBytes<test_object::std_allocator::SerializeNested>(buffer, param, allocator); |
455 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ ✓✗ |
1 |
ASSERT_EQ(param, serializeNested.getParam()); |
456 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ ✓✗ |
1 |
ASSERT_EQ(0x01, serializeNested.getOffset()); |
457 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ ✓✗ |
1 |
ASSERT_EQ(0xDEADCAFE, serializeNested.getOptionalValue()); |
458 |
|||
459 |
✓✗✓✗ |
2 |
const vector<uint8_t> wrongBuffer = {0x00, 0xDE, 0xAD, 0xCA, 0xFE}; |
460 |
✓✗✓✗ ✓✗✓✗ ✗✓✗✓ ✗✗✗✗ ✗✗✗✗ ✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✗✗ ✗✗✗✗ ✗✗✗✗ ✗ |
2 |
ASSERT_THROW(deserializeFromBytes<test_object::std_allocator::SerializeNested>(wrongBuffer, param), |
461 |
CppRuntimeException); |
||
462 |
} |
||
463 |
|||
464 |
// with polymorphic allocator |
||
465 |
{ |
||
466 |
1 |
const pmr::PropagatingPolymorphicAllocator<> allocator; |
|
467 |
const vector<uint8_t, pmr::PropagatingPolymorphicAllocator<>> buffer( |
||
468 |
✓✗ | 2 |
{0x01, 0xDE, 0xAD, 0xCA, 0xFE}, allocator); |
469 |
const test_object::polymorphic_allocator::SerializeNested serializeNested = |
||
470 |
deserializeFromBytes<test_object::polymorphic_allocator::SerializeNested>( |
||
471 |
✓✗✓✗ ✓✗ |
2 |
buffer, param, allocator); |
472 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ ✓✗ |
1 |
ASSERT_EQ(param, serializeNested.getParam()); |
473 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ ✓✗ |
1 |
ASSERT_EQ(0x01, serializeNested.getOffset()); |
474 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ ✓✗ |
1 |
ASSERT_EQ(0xDEADCAFE, serializeNested.getOptionalValue()); |
475 |
|||
476 |
✓✗✓✗ |
2 |
const vector<uint8_t> wrongBuffer = {0x00, 0xDE, 0xAD, 0xCA, 0xFE}; |
477 |
✓✗✓✗ ✓✗✓✗ ✗✓✗✓ ✗✗✗✗ ✗✗✗✗ ✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✗✗ ✗✗✗✗ ✗✗✗✗ ✗ |
2 |
ASSERT_THROW(deserializeFromBytes<test_object::polymorphic_allocator::SerializeNested>(wrongBuffer, |
478 |
param), CppRuntimeException); |
||
479 |
} |
||
480 |
} |
||
481 |
|||
482 |
✓✗✓✗ ✓✗✗✓ |
802 |
TEST(SerializeUtilTest, deserializeObjectFromBytes) |
483 |
{ |
||
484 |
// without allocator |
||
485 |
{ |
||
486 |
✓✗ | 2 |
const vector<uint8_t> buffer({0x12, 0x02, 0xDE, 0xAD, 0xCA, 0xFE}); |
487 |
const test_object::std_allocator::SerializeObject serializeObject = |
||
488 |
✓✗✓✗ ✓✗ |
2 |
deserializeFromBytes<test_object::std_allocator::SerializeObject>(buffer); |
489 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ ✓✗ |
1 |
ASSERT_EQ(0x12, serializeObject.getParam()); |
490 |
✓✗ | 1 |
const test_object::std_allocator::SerializeNested& serializeNested = serializeObject.getNested(); |
491 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ ✓✗ |
1 |
ASSERT_EQ(0x12, serializeNested.getParam()); |
492 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ ✓✗ |
1 |
ASSERT_EQ(0x02, serializeNested.getOffset()); |
493 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ ✓✗✓✗ |
1 |
ASSERT_EQ(0xDEADCAFE, serializeNested.getOptionalValue()); |
494 |
} |
||
495 |
|||
496 |
// with std allocator |
||
497 |
{ |
||
498 |
2 |
const std::allocator<uint8_t> allocator; |
|
499 |
✓✗✓✗ |
2 |
const vector<uint8_t> buffer({0x12, 0x02, 0xDE, 0xAD, 0xCA, 0xFE}, allocator); |
500 |
const test_object::std_allocator::SerializeObject serializeObject = |
||
501 |
✓✗✓✗ ✓✗ |
2 |
deserializeFromBytes<test_object::std_allocator::SerializeObject>(buffer, allocator); |
502 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ ✓✗ |
1 |
ASSERT_EQ(0x12, serializeObject.getParam()); |
503 |
✓✗ | 1 |
const test_object::std_allocator::SerializeNested& serializeNested = serializeObject.getNested(); |
504 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ ✓✗ |
1 |
ASSERT_EQ(0x12, serializeNested.getParam()); |
505 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ ✓✗ |
1 |
ASSERT_EQ(0x02, serializeNested.getOffset()); |
506 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ ✓✗✓✗ |
1 |
ASSERT_EQ(0xDEADCAFE, serializeNested.getOptionalValue()); |
507 |
} |
||
508 |
|||
509 |
// with polymorphic allocator |
||
510 |
{ |
||
511 |
1 |
const pmr::PropagatingPolymorphicAllocator<> allocator; |
|
512 |
const vector<uint8_t, pmr::PropagatingPolymorphicAllocator<>> buffer( |
||
513 |
✓✗ | 2 |
{0x12, 0x02, 0xDE, 0xAD, 0xCA, 0xFE}, allocator); |
514 |
const test_object::polymorphic_allocator::SerializeObject serializeObject = |
||
515 |
✓✗✓✗ ✓✗ |
2 |
deserializeFromBytes<test_object::polymorphic_allocator::SerializeObject>(buffer, allocator); |
516 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ ✓✗ |
1 |
ASSERT_EQ(0x12, serializeObject.getParam()); |
517 |
const test_object::polymorphic_allocator::SerializeNested& serializeNested = |
||
518 |
✓✗ | 1 |
serializeObject.getNested(); |
519 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ ✓✗ |
1 |
ASSERT_EQ(0x12, serializeNested.getParam()); |
520 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ ✓✗ |
1 |
ASSERT_EQ(0x02, serializeNested.getOffset()); |
521 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ ✓✗✓✗ |
1 |
ASSERT_EQ(0xDEADCAFE, serializeNested.getOptionalValue()); |
522 |
} |
||
523 |
} |
||
524 |
|||
525 |
✓✗✓✗ ✓✗✗✓ |
802 |
TEST(SerializeUtilTest, serializeToFileFromFile) |
526 |
{ |
||
527 |
1 |
const int8_t param = 0x12; |
|
528 |
1 |
const uint8_t offset = 0; |
|
529 |
1 |
const uint32_t optionalValue = 0xDEADCAFE; |
|
530 |
✓✗ | 2 |
const std::string fileName = "SerializationTest.bin"; |
531 |
{ |
||
532 |
// without allocator |
||
533 |
✓✗ | 2 |
test_object::std_allocator::SerializeNested serializeNested(offset, optionalValue); |
534 |
✓✗✓✗ |
2 |
test_object::std_allocator::SerializeObject serializeObject(param, serializeNested); |
535 |
✓✗ | 1 |
serializeToFile(serializeObject, fileName); |
536 |
const test_object::std_allocator::SerializeObject readSerializeObject = |
||
537 |
✓✗✓✗ |
2 |
deserializeFromFile<test_object::std_allocator::SerializeObject>(fileName); |
538 |
✓✗✗✓ ✗✗✗✗ ✗✗✓✗ ✓✗ |
1 |
ASSERT_EQ(serializeObject, readSerializeObject); |
539 |
} |
||
540 |
|||
541 |
{ |
||
542 |
// with std allocator |
||
543 |
2 |
const std::allocator<uint8_t> allocator; |
|
544 |
✓✗✓✗ |
2 |
test_object::std_allocator::SerializeNested serializeNested(offset, optionalValue, allocator); |
545 |
✓✗✓✗ |
2 |
test_object::std_allocator::SerializeObject serializeObject(param, serializeNested, allocator); |
546 |
✓✗ | 1 |
serializeToFile(serializeObject, fileName); |
547 |
const test_object::std_allocator::SerializeObject readSerializeObject = |
||
548 |
✓✗✓✗ |
2 |
deserializeFromFile<test_object::std_allocator::SerializeObject>(fileName); |
549 |
✓✗✗✓ ✗✗✗✗ ✗✗✓✗ ✓✗ |
1 |
ASSERT_EQ(serializeObject, readSerializeObject); |
550 |
} |
||
551 |
|||
552 |
{ |
||
553 |
// with polymorphic allocator |
||
554 |
1 |
const pmr::PropagatingPolymorphicAllocator<> allocator; |
|
555 |
✓✗✓✗ |
2 |
test_object::polymorphic_allocator::SerializeNested serializeNested(offset, optionalValue, allocator); |
556 |
✓✗✓✗ |
2 |
test_object::polymorphic_allocator::SerializeObject serializeObject(param, serializeNested, allocator); |
557 |
✓✗ | 1 |
serializeToFile(serializeObject, fileName); |
558 |
const test_object::polymorphic_allocator::SerializeObject readSerializeObject = |
||
559 |
✓✗✓✗ |
2 |
deserializeFromFile<test_object::polymorphic_allocator::SerializeObject>(fileName); |
560 |
✓✗✗✓ ✗✗✗✗ ✗✗✓✗ ✓✗ |
1 |
ASSERT_EQ(serializeObject, readSerializeObject); |
561 |
} |
||
562 |
} |
||
563 |
|||
564 |
✓✗✓✗ |
2394 |
} // namespace zserio |
Generated by: GCOVR (Version 4.2) |