GCC Code Coverage Report | |||||||||||||||||||||
|
|||||||||||||||||||||
Line | Branch | Exec | Source |
1 |
#include "gtest/gtest.h" |
||
2 |
|||
3 |
#include "zserio/JsonReader.h" |
||
4 |
#include "zserio/ReflectableUtil.h" |
||
5 |
|||
6 |
#include "test_object/std_allocator/CreatorBitmask.h" |
||
7 |
#include "test_object/std_allocator/CreatorEnum.h" |
||
8 |
#include "test_object/std_allocator/CreatorNested.h" |
||
9 |
#include "test_object/std_allocator/CreatorObject.h" |
||
10 |
|||
11 |
using test_object::std_allocator::CreatorBitmask; |
||
12 |
using test_object::std_allocator::CreatorEnum; |
||
13 |
using test_object::std_allocator::CreatorNested; |
||
14 |
using test_object::std_allocator::CreatorObject; |
||
15 |
|||
16 |
namespace zserio |
||
17 |
{ |
||
18 |
|||
19 |
namespace |
||
20 |
{ |
||
21 |
|||
22 |
2 |
void checkReadStringifiedEnum(const char* stringValue, CreatorEnum expectedValue) |
|
23 |
{ |
||
24 |
✓✗ | 4 |
std::stringstream str; |
25 |
str << |
||
26 |
"{\n" |
||
27 |
" \"nested\": {\n" |
||
28 |
✓✗✓✗ |
2 |
" \"creatorEnum\": \"" << stringValue << "\"\n" |
29 |
" }\n" |
||
30 |
✓✗ | 2 |
"}"; |
31 |
|||
32 |
✓✗✓✗ |
4 |
JsonReader jsonReader(str); |
33 |
✓✗✓✗ ✓✗ |
4 |
auto reflectable = jsonReader.read(CreatorObject::typeInfo()); |
34 |
✓✗✗✓ ✗✗✗✗ ✗✗✗✗ ✓✗ |
2 |
ASSERT_TRUE(reflectable); |
35 |
|||
36 |
✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✓✗ ✓✗ |
2 |
ASSERT_EQ(expectedValue, ReflectableUtil::getValue<CreatorEnum>(reflectable->find("nested.creatorEnum"))); |
37 |
} |
||
38 |
|||
39 |
5 |
void checkReadStringifiedEnumThrows(const char* stringValue, const char* expectedMessage) |
|
40 |
{ |
||
41 |
✓✗ | 10 |
std::stringstream str; |
42 |
str << |
||
43 |
"{\n" |
||
44 |
" \"nested\": {\n" |
||
45 |
✓✗✓✗ |
5 |
" \"creatorEnum\": \"" << stringValue << "\"\n" |
46 |
" }\n" |
||
47 |
✓✗ | 5 |
"}"; |
48 |
|||
49 |
✓✗✓✗ ✗✓ |
10 |
JsonReader jsonReader(str); |
50 |
✓✗✓✗ ✓✗✓✗ ✗✓✗✓ ✗✗✗✗ ✗✗✗✗ ✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✓✗ ✗✗✓✗ ✗✓✗✗ ✗✗✗✗ ✗✗✗✗ ✗✗✗✗ ✗✗✗ |
10 |
ASSERT_THROW({ |
51 |
try |
||
52 |
{ |
||
53 |
jsonReader.read(CreatorObject::typeInfo()); |
||
54 |
} |
||
55 |
catch (const CppRuntimeException& e) |
||
56 |
{ |
||
57 |
ASSERT_STREQ(expectedMessage, e.what()); |
||
58 |
throw; |
||
59 |
} |
||
60 |
}, CppRuntimeException); |
||
61 |
} |
||
62 |
|||
63 |
5 |
void checkReadStringifiedBitmask(const char* stringValue, CreatorBitmask expectedValue) |
|
64 |
{ |
||
65 |
✓✗ | 10 |
std::stringstream str; |
66 |
str << |
||
67 |
"{\n" |
||
68 |
" \"nested\": {\n" |
||
69 |
✓✗✓✗ |
5 |
" \"creatorBitmask\": \"" << stringValue << "\"\n" |
70 |
" }\n" |
||
71 |
✓✗ | 5 |
"}"; |
72 |
|||
73 |
✓✗✓✗ |
10 |
JsonReader jsonReader(str); |
74 |
✓✗✓✗ ✓✗ |
10 |
auto reflectable = jsonReader.read(CreatorObject::typeInfo()); |
75 |
✓✗✗✓ ✗✗✗✗ ✗✗✗✗ ✓✗ |
5 |
ASSERT_TRUE(reflectable); |
76 |
|||
77 |
✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✓✗ ✓✗ |
5 |
ASSERT_EQ(expectedValue, ReflectableUtil::getValue<CreatorBitmask>(reflectable->find("nested.creatorBitmask"))); |
78 |
} |
||
79 |
|||
80 |
6 |
void checkReadStringifiedBitmaskThrows(const char* stringValue, const char* expectedMessage) |
|
81 |
{ |
||
82 |
✓✗ | 12 |
std::stringstream str; |
83 |
str << |
||
84 |
"{\n" |
||
85 |
" \"nested\": {\n" |
||
86 |
✓✗✓✗ ✓✗ |
6 |
" \"creatorBitmask\": \"" << stringValue << "\"\n" << |
87 |
" }\n" |
||
88 |
✓✗ | 6 |
"}"; |
89 |
|||
90 |
✓✗✓✗ ✗✓ |
12 |
JsonReader jsonReader(str); |
91 |
✓✗✓✗ ✓✗✓✗ ✗✓✗✓ ✗✗✗✗ ✗✗✗✗ ✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✓✗ ✗✗✓✗ ✗✓✗✗ ✗✗✗✗ ✗✗✗✗ ✗✗✗✗ ✗✗✗ |
12 |
ASSERT_THROW({ |
92 |
try |
||
93 |
{ |
||
94 |
jsonReader.read(CreatorObject::typeInfo()); |
||
95 |
} |
||
96 |
catch (const CppRuntimeException& e) |
||
97 |
{ |
||
98 |
ASSERT_STREQ(expectedMessage, e.what()); |
||
99 |
throw; |
||
100 |
} |
||
101 |
}, CppRuntimeException); |
||
102 |
} |
||
103 |
|||
104 |
} // namespace |
||
105 |
|||
106 |
✓✗✓✗ ✓✗✗✓ |
802 |
TEST(JsonReaderTest, readObjectWithoutOptional) |
107 |
{ |
||
108 |
std::stringstream str( |
||
109 |
"{\n" |
||
110 |
" \"value\": 13,\n" |
||
111 |
" \"nested\": {\n" |
||
112 |
" \"value\": 10,\n" |
||
113 |
" \"text\": \"nested\",\n" |
||
114 |
" \"externData\": {\n" |
||
115 |
" \"buffer\": [\n" |
||
116 |
" 203,\n" |
||
117 |
" 240\n" |
||
118 |
" ],\n" |
||
119 |
" \"bitSize\": 12\n" |
||
120 |
" },\n" |
||
121 |
" \"bytesData\": {\n" |
||
122 |
" \"buffer\": [\n" |
||
123 |
" 202,\n" |
||
124 |
" 254\n" |
||
125 |
" ]\n" |
||
126 |
" },\n" |
||
127 |
" \"creatorEnum\": 0,\n" |
||
128 |
" \"creatorBitmask\": 1\n" |
||
129 |
" },\n" |
||
130 |
" \"text\": \"test\",\n" |
||
131 |
" \"nestedArray\": [\n" |
||
132 |
" {\n" |
||
133 |
" \"value\": 5,\n" |
||
134 |
" \"text\": \"nestedArray\",\n" |
||
135 |
" \"externData\": {\n" |
||
136 |
" \"buffer\": [\n" |
||
137 |
" 202,\n" |
||
138 |
" 254\n" |
||
139 |
" ]," |
||
140 |
" \"bitSize\": 15\n" |
||
141 |
" },\n" |
||
142 |
" \"bytesData\": {\n" |
||
143 |
" \"buffer\": [\n" |
||
144 |
" 203,\n" |
||
145 |
" 240\n" |
||
146 |
" ]\n" |
||
147 |
" },\n" |
||
148 |
" \"creatorEnum\": 1,\n" |
||
149 |
" \"creatorBitmask\": 2\n" |
||
150 |
" }\n" |
||
151 |
" ],\n" |
||
152 |
" \"textArray\": [\n" |
||
153 |
" \"this\",\n" |
||
154 |
" \"is\",\n" |
||
155 |
" \"text\",\n" |
||
156 |
" \"array\"\n" |
||
157 |
" ],\n" |
||
158 |
" \"externArray\": [\n" |
||
159 |
" {\n" |
||
160 |
" \"buffer\": [\n" |
||
161 |
" 222,\n" |
||
162 |
" 209\n" |
||
163 |
" ]," |
||
164 |
" \"bitSize\": 13\n" |
||
165 |
" }\n" |
||
166 |
" ],\n" |
||
167 |
" \"bytesArray\": [\n" |
||
168 |
" {\n" |
||
169 |
" \"buffer\": [\n" |
||
170 |
" 0\n" |
||
171 |
" ]\n" |
||
172 |
" }\n" |
||
173 |
" ],\n" |
||
174 |
" \"optionalBool\": null\n" |
||
175 |
"}" |
||
176 |
✓✗✓✗ |
2 |
); |
177 |
|||
178 |
✓✗✓✗ |
2 |
JsonReader jsonReader(str); |
179 |
✓✗✓✗ ✓✗ |
2 |
IReflectablePtr reflectable = jsonReader.read(CreatorObject::typeInfo()); |
180 |
✓✗✗✓ ✗✗✗✗ ✗✗✗✗ ✓✗ |
1 |
ASSERT_TRUE(reflectable); |
181 |
|||
182 |
✓✗ | 1 |
reflectable->initializeChildren(); |
183 |
|||
184 |
✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✓✗ |
1 |
ASSERT_EQ(13, reflectable->getField("value")->getUInt32()); |
185 |
✓✗✓✗ ✓✗✓✗ ✗✓✗✗ ✗✗✗✗ ✓✗ |
1 |
ASSERT_EQ(13, reflectable->getField("nested")->getParameter("param")->getUInt32()); |
186 |
✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✓✗ |
1 |
ASSERT_EQ(10, reflectable->find("nested.value")->getUInt32()); |
187 |
✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✓✗ |
1 |
ASSERT_EQ("nested"_sv, reflectable->find("nested.text")->getStringView()); |
188 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✓✗ |
1 |
ASSERT_EQ(BitBuffer({0xCB, 0xF0}, 12), reflectable->find("nested.externData")->getBitBuffer()); |
189 |
✓✗✓✗ |
1 |
const Span<const uint8_t> bytesData = reflectable->find("nested.bytesData")->getBytes(); |
190 |
✓✗✗✓ ✗✗✗✗ ✗✗✓✗ |
1 |
ASSERT_EQ(2, bytesData.size()); |
191 |
✓✗✗✓ ✗✗✗✗ ✗✗✓✗ |
1 |
ASSERT_EQ(0xCA, bytesData[0]); |
192 |
✓✗✗✓ ✗✗✗✗ ✗✗✓✗ |
1 |
ASSERT_EQ(0xFE, bytesData[1]); |
193 |
✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✓✗ |
1 |
ASSERT_EQ(enumToValue(CreatorEnum::ONE), reflectable->find("nested.creatorEnum")->getInt8()); |
194 |
✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✓✗ |
1 |
ASSERT_EQ(CreatorBitmask(CreatorBitmask::Values::READ).getValue(), |
195 |
reflectable->find("nested.creatorBitmask")->getUInt8()); |
||
196 |
✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✓✗ |
1 |
ASSERT_EQ("test"_sv, reflectable->getField("text")->getStringView()); |
197 |
✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✓✗ |
1 |
ASSERT_EQ(1, reflectable->getField("nestedArray")->size()); |
198 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✓✗ |
1 |
ASSERT_EQ(5, reflectable->getField("nestedArray")->at(0)->getField("value")->getUInt32()); |
199 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✓✗ |
1 |
ASSERT_EQ("nestedArray"_sv, reflectable->getField("nestedArray")->at(0)->getField("text")->getStringView()); |
200 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✓✗ |
1 |
ASSERT_EQ(BitBuffer({0xCA, 0xFE}, 15), |
201 |
reflectable->getField("nestedArray")->at(0)->getField("externData")->getBitBuffer()); |
||
202 |
const Span<const uint8_t> nestedBytesData = |
||
203 |
✓✗✓✗ ✓✗✓✗ |
1 |
reflectable->getField("nestedArray")->at(0)->getField("bytesData")->getBytes(); |
204 |
✓✗✗✓ ✗✗✗✗ ✗✗✓✗ |
1 |
ASSERT_EQ(2, nestedBytesData.size()); |
205 |
✓✗✗✓ ✗✗✗✗ ✗✗✓✗ |
1 |
ASSERT_EQ(0xCB, nestedBytesData[0]); |
206 |
✓✗✗✓ ✗✗✗✗ ✗✗✓✗ |
1 |
ASSERT_EQ(0xF0, nestedBytesData[1]); |
207 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✓✗ |
1 |
ASSERT_EQ(enumToValue(CreatorEnum::TWO), |
208 |
reflectable->getField("nestedArray")->at(0)->getField("creatorEnum")->getInt8()); |
||
209 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✓✗ |
1 |
ASSERT_EQ(CreatorBitmask(CreatorBitmask::Values::WRITE).getValue(), |
210 |
reflectable->getField("nestedArray")->at(0)->getField("creatorBitmask")->getUInt8()); |
||
211 |
✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✓✗ |
1 |
ASSERT_EQ(4, reflectable->getField("textArray")->size()); |
212 |
✓✗✓✗ ✓✗✓✗ ✗✓✗✗ ✗✗✗✗ ✓✗ |
1 |
ASSERT_EQ("this"_sv, reflectable->getField("textArray")->at(0)->getStringView()); |
213 |
✓✗✓✗ ✓✗✓✗ ✗✓✗✗ ✗✗✗✗ ✓✗ |
1 |
ASSERT_EQ("is"_sv, reflectable->getField("textArray")->at(1)->getStringView()); |
214 |
✓✗✓✗ ✓✗✓✗ ✗✓✗✗ ✗✗✗✗ ✓✗ |
1 |
ASSERT_EQ("text"_sv, reflectable->getField("textArray")->at(2)->getStringView()); |
215 |
✓✗✓✗ ✓✗✓✗ ✗✓✗✗ ✗✗✗✗ ✓✗ |
1 |
ASSERT_EQ("array"_sv, reflectable->getField("textArray")->at(3)->getStringView()); |
216 |
✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✓✗ |
1 |
ASSERT_EQ(1, reflectable->getField("externArray")->size()); |
217 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✓✗✗ ✗✗✗✗ ✓✗ |
1 |
ASSERT_EQ(BitBuffer({0xDE, 0xD1}, 13), reflectable->getField("externArray")->at(0)->getBitBuffer()); |
218 |
✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✓✗ |
1 |
ASSERT_EQ(1, reflectable->getField("bytesArray")->size()); |
219 |
✓✗✓✗ ✓✗ |
1 |
Span<const uint8_t> bytesElement = reflectable->getField("bytesArray")->at(0)->getBytes(); |
220 |
✓✗✗✓ ✗✗✗✗ ✗✗✓✗ |
1 |
ASSERT_EQ(1, bytesElement.size()); |
221 |
✓✗✗✓ ✗✗✗✗ ✗✗✓✗ |
1 |
ASSERT_EQ(0, bytesElement[0]); |
222 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ ✓✗ |
1 |
ASSERT_EQ(nullptr, reflectable->getField("optionalBool")); |
223 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ ✓✗✓✗ |
1 |
ASSERT_EQ(nullptr, reflectable->getField("optionalNested")); // not present in json |
224 |
} |
||
225 |
|||
226 |
✓✗✓✗ ✓✗✗✓ |
802 |
TEST(JsonReaderTest, readObjectWithOptional) |
227 |
{ |
||
228 |
std::stringstream str( |
||
229 |
"{\n" |
||
230 |
" \"value\": 13,\n" |
||
231 |
" \"nested\": {\n" |
||
232 |
" \"value\": 10,\n" |
||
233 |
" \"text\": \"nested\",\n" |
||
234 |
" \"externData\": {\n" |
||
235 |
" \"buffer\": [\n" |
||
236 |
" 203,\n" |
||
237 |
" 240\n" |
||
238 |
" ],\n" |
||
239 |
" \"bitSize\": 12\n" |
||
240 |
" },\n" |
||
241 |
" \"bytesData\": {\n" |
||
242 |
" \"buffer\": [\n" |
||
243 |
" 202,\n" |
||
244 |
" 254\n" |
||
245 |
" ]\n" |
||
246 |
" },\n" |
||
247 |
" \"creatorEnum\": 0,\n" |
||
248 |
" \"creatorBitmask\": 1\n" |
||
249 |
" },\n" |
||
250 |
" \"text\": \"test\",\n" |
||
251 |
" \"nestedArray\": [\n" |
||
252 |
" {\n" |
||
253 |
" \"value\": 5,\n" |
||
254 |
" \"text\": \"nestedArray\",\n" |
||
255 |
" \"externData\": {\n" |
||
256 |
" \"buffer\": [\n" |
||
257 |
" 202,\n" |
||
258 |
" 254\n" |
||
259 |
" ]," |
||
260 |
" \"bitSize\": 15\n" |
||
261 |
" },\n" |
||
262 |
" \"bytesData\": {\n" |
||
263 |
" \"buffer\": [\n" |
||
264 |
" 203,\n" |
||
265 |
" 240\n" |
||
266 |
" ]\n" |
||
267 |
" },\n" |
||
268 |
" \"creatorEnum\": 1,\n" |
||
269 |
" \"creatorBitmask\": 2\n" |
||
270 |
" }\n" |
||
271 |
" ],\n" |
||
272 |
" \"textArray\": [\n" |
||
273 |
" \"this\",\n" |
||
274 |
" \"is\",\n" |
||
275 |
" \"text\",\n" |
||
276 |
" \"array\"\n" |
||
277 |
" ],\n" |
||
278 |
" \"externArray\": [\n" |
||
279 |
" {\n" |
||
280 |
" \"buffer\": [\n" |
||
281 |
" 222,\n" |
||
282 |
" 209\n" |
||
283 |
" ]," |
||
284 |
" \"bitSize\": 13\n" |
||
285 |
" }\n" |
||
286 |
" ],\n" |
||
287 |
" \"bytesArray\": [\n" |
||
288 |
" {\n" |
||
289 |
" \"buffer\": [\n" |
||
290 |
" 0\n" |
||
291 |
" ]\n" |
||
292 |
" }\n" |
||
293 |
" ],\n" |
||
294 |
" \"optionalBool\": true\n" |
||
295 |
"}" |
||
296 |
✓✗✓✗ |
2 |
); |
297 |
|||
298 |
✓✗✓✗ |
2 |
JsonReader jsonReader(str); |
299 |
✓✗✓✗ ✓✗ |
2 |
IReflectablePtr reflectable = jsonReader.read(CreatorObject::typeInfo()); |
300 |
✓✗✗✓ ✗✗✗✗ ✗✗✗✗ ✓✗ |
1 |
ASSERT_TRUE(reflectable); |
301 |
|||
302 |
✓✗ | 1 |
reflectable->initializeChildren(); |
303 |
|||
304 |
✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✓✗ |
1 |
ASSERT_EQ(13, reflectable->getField("value")->getUInt32()); |
305 |
✓✗✓✗ ✓✗✓✗ ✗✓✗✗ ✗✗✗✗ ✓✗ |
1 |
ASSERT_EQ(13, reflectable->getField("nested")->getParameter("param")->getUInt32()); |
306 |
✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✓✗ |
1 |
ASSERT_EQ(10, reflectable->find("nested.value")->getUInt32()); |
307 |
✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✓✗ |
1 |
ASSERT_EQ("nested"_sv, reflectable->find("nested.text")->getStringView()); |
308 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✓✗ |
1 |
ASSERT_EQ(BitBuffer({0xCB, 0xF0}, 12), reflectable->find("nested.externData")->getBitBuffer()); |
309 |
✓✗✓✗ |
1 |
const Span<const uint8_t> bytesData = reflectable->find("nested.bytesData")->getBytes(); |
310 |
✓✗✗✓ ✗✗✗✗ ✗✗✓✗ |
1 |
ASSERT_EQ(2, bytesData.size()); |
311 |
✓✗✗✓ ✗✗✗✗ ✗✗✓✗ |
1 |
ASSERT_EQ(0xCA, bytesData[0]); |
312 |
✓✗✗✓ ✗✗✗✗ ✗✗✓✗ |
1 |
ASSERT_EQ(0xFE, bytesData[1]); |
313 |
✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✓✗ |
1 |
ASSERT_EQ(enumToValue(CreatorEnum::ONE), reflectable->find("nested.creatorEnum")->getInt8()); |
314 |
✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✓✗ |
1 |
ASSERT_EQ(CreatorBitmask(CreatorBitmask::Values::READ).getValue(), |
315 |
reflectable->find("nested.creatorBitmask")->getUInt8()); |
||
316 |
✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✓✗ |
1 |
ASSERT_EQ("test"_sv, reflectable->getField("text")->getStringView()); |
317 |
✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✓✗ |
1 |
ASSERT_EQ(1, reflectable->getField("nestedArray")->size()); |
318 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✓✗ |
1 |
ASSERT_EQ(5, reflectable->getField("nestedArray")->at(0)->getField("value")->getUInt32()); |
319 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✓✗ |
1 |
ASSERT_EQ("nestedArray"_sv, reflectable->getField("nestedArray")->at(0)->getField("text")->getStringView()); |
320 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✓✗ |
1 |
ASSERT_EQ(BitBuffer({0xCA, 0xFE}, 15), |
321 |
reflectable->getField("nestedArray")->at(0)->getField("externData")->getBitBuffer()); |
||
322 |
const Span<const uint8_t> nestedBytesData = |
||
323 |
✓✗✓✗ ✓✗✓✗ |
1 |
reflectable->getField("nestedArray")->at(0)->getField("bytesData")->getBytes(); |
324 |
✓✗✗✓ ✗✗✗✗ ✗✗✓✗ |
1 |
ASSERT_EQ(2, nestedBytesData.size()); |
325 |
✓✗✗✓ ✗✗✗✗ ✗✗✓✗ |
1 |
ASSERT_EQ(0xCB, nestedBytesData[0]); |
326 |
✓✗✗✓ ✗✗✗✗ ✗✗✓✗ |
1 |
ASSERT_EQ(0xF0, nestedBytesData[1]); |
327 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✓✗ |
1 |
ASSERT_EQ(enumToValue(CreatorEnum::TWO), |
328 |
reflectable->getField("nestedArray")->at(0)->getField("creatorEnum")->getInt8()); |
||
329 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✓✗ |
1 |
ASSERT_EQ(CreatorBitmask(CreatorBitmask::Values::WRITE).getValue(), |
330 |
reflectable->getField("nestedArray")->at(0)->getField("creatorBitmask")->getUInt8()); |
||
331 |
✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✓✗ |
1 |
ASSERT_EQ(4, reflectable->getField("textArray")->size()); |
332 |
✓✗✓✗ ✓✗✓✗ ✗✓✗✗ ✗✗✗✗ ✓✗ |
1 |
ASSERT_EQ("this"_sv, reflectable->getField("textArray")->at(0)->getStringView()); |
333 |
✓✗✓✗ ✓✗✓✗ ✗✓✗✗ ✗✗✗✗ ✓✗ |
1 |
ASSERT_EQ("is"_sv, reflectable->getField("textArray")->at(1)->getStringView()); |
334 |
✓✗✓✗ ✓✗✓✗ ✗✓✗✗ ✗✗✗✗ ✓✗ |
1 |
ASSERT_EQ("text"_sv, reflectable->getField("textArray")->at(2)->getStringView()); |
335 |
✓✗✓✗ ✓✗✓✗ ✗✓✗✗ ✗✗✗✗ ✓✗ |
1 |
ASSERT_EQ("array"_sv, reflectable->getField("textArray")->at(3)->getStringView()); |
336 |
✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✓✗ |
1 |
ASSERT_EQ(1, reflectable->getField("externArray")->size()); |
337 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✓✗✗ ✗✗✗✗ ✓✗ |
1 |
ASSERT_EQ(BitBuffer({0xDE, 0xD1}, 13), reflectable->getField("externArray")->at(0)->getBitBuffer()); |
338 |
✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✓✗ |
1 |
ASSERT_EQ(1, reflectable->getField("bytesArray")->size()); |
339 |
✓✗✓✗ ✓✗ |
1 |
Span<const uint8_t> bytesElement = reflectable->getField("bytesArray")->at(0)->getBytes(); |
340 |
✓✗✗✓ ✗✗✗✗ ✗✗✓✗ |
1 |
ASSERT_EQ(1, bytesElement.size()); |
341 |
✓✗✗✓ ✗✗✗✗ ✗✗✓✗ |
1 |
ASSERT_EQ(0, bytesElement[0]); |
342 |
✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✓✗ |
1 |
ASSERT_EQ(true, reflectable->getField("optionalBool")->getBool()); |
343 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ ✓✗✓✗ |
1 |
ASSERT_EQ(nullptr, reflectable->getField("optionalNested")); // not present in json |
344 |
} |
||
345 |
|||
346 |
✓✗✓✗ ✓✗✗✓ |
802 |
TEST(JsonReaderTest, readTwoObjects) |
347 |
{ |
||
348 |
std::stringstream str( |
||
349 |
"{\"value\": 13}\n" |
||
350 |
"{\"value\": 42, \"text\": \"test\"}\n" |
||
351 |
✓✗✓✗ |
2 |
); |
352 |
|||
353 |
✓✗✓✗ |
2 |
JsonReader jsonReader(str); |
354 |
|||
355 |
✓✗✓✗ ✓✗ |
2 |
auto obj1 = jsonReader.read(CreatorObject::typeInfo()); |
356 |
✓✗✗✓ ✗✗✗✗ ✗✗✗✗ ✓✗ |
1 |
ASSERT_TRUE(obj1); |
357 |
✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✓✗ |
1 |
ASSERT_EQ(13, obj1->getField("value")->getUInt32()); |
358 |
✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✓✗ |
1 |
ASSERT_EQ(""_sv, obj1->getField("text")->getStringView()); |
359 |
|||
360 |
✓✗✓✗ ✓✗ |
2 |
auto obj2 = jsonReader.read(CreatorObject::typeInfo()); |
361 |
✓✗✗✓ ✗✗✗✗ ✗✗✗✗ ✓✗ |
1 |
ASSERT_TRUE(obj2); |
362 |
✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✓✗ |
1 |
ASSERT_EQ(42, obj2->getField("value")->getUInt32()); |
363 |
✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✓✗ ✓✗ |
1 |
ASSERT_EQ("test"_sv, obj2->getField("text")->getStringView()); |
364 |
} |
||
365 |
|||
366 |
✓✗✓✗ ✓✗✗✓ |
802 |
TEST(JsonReaderTest, readParameterizedObject) |
367 |
{ |
||
368 |
std::stringstream str( |
||
369 |
"{\n" |
||
370 |
" \"value\": 10,\n" |
||
371 |
" \"text\": \"nested\",\n" |
||
372 |
" \"externData\": {\n" |
||
373 |
" \"bitSize\": 12,\n" |
||
374 |
" \"buffer\": [\n" |
||
375 |
" 203,\n" |
||
376 |
" 240\n" |
||
377 |
" ]\n" |
||
378 |
" },\n" |
||
379 |
" \"bytesData\": {\n" |
||
380 |
" \"buffer\": [\n" |
||
381 |
" 202,\n" |
||
382 |
" 254\n" |
||
383 |
" ]\n" |
||
384 |
" },\n" |
||
385 |
" \"creatorEnum\": 0,\n" |
||
386 |
" \"creatorBitmask\": 1\n" |
||
387 |
"}\n" |
||
388 |
✓✗✓✗ |
2 |
); |
389 |
|||
390 |
✓✗✓✗ |
2 |
JsonReader jsonReader(str); |
391 |
✓✗✓✗ ✓✗ |
2 |
auto reflectable = jsonReader.read(CreatorNested::typeInfo()); |
392 |
|||
393 |
✓✗✓✗ ✓✗✓✓ ✗✗ |
1 |
reflectable->initialize(vector<AnyHolder<>>{AnyHolder<>{static_cast<uint32_t>(13)}}); |
394 |
|||
395 |
✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✓✗ |
1 |
ASSERT_EQ(13, reflectable->getParameter("param")->getUInt32()); |
396 |
✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✓✗ ✓✗ |
1 |
ASSERT_EQ(10, reflectable->getField("value")->getUInt32()); |
397 |
} |
||
398 |
|||
399 |
✓✗✓✗ ✓✗✗✓ |
802 |
TEST(JsonReaderTest, readUnorderedBitBuffer) |
400 |
{ |
||
401 |
std::stringstream str( |
||
402 |
"{\n" |
||
403 |
" \"value\": 13,\n" |
||
404 |
" \"nested\": {\n" |
||
405 |
" \"value\": 10,\n" |
||
406 |
" \"text\": \"nested\",\n" |
||
407 |
" \"externData\": {\n" |
||
408 |
" \"bitSize\": 12,\n" |
||
409 |
" \"buffer\": [\n" |
||
410 |
" 203,\n" |
||
411 |
" 240\n" |
||
412 |
" ]\n" |
||
413 |
" },\n" |
||
414 |
" \"bytesData\": {\n" |
||
415 |
" \"buffer\": [\n" |
||
416 |
" 202,\n" |
||
417 |
" 254\n" |
||
418 |
" ]\n" |
||
419 |
" },\n" |
||
420 |
" \"creatorEnum\": -1,\n" |
||
421 |
" \"creatorBitmask\": 1\n" |
||
422 |
" }\n" |
||
423 |
"}" |
||
424 |
✓✗✓✗ |
2 |
); |
425 |
|||
426 |
✓✗✓✗ |
2 |
JsonReader jsonReader(str); |
427 |
✓✗✓✗ ✓✗ |
2 |
auto reflectable = jsonReader.read(CreatorObject::typeInfo()); |
428 |
✓✗✗✓ ✗✗✗✗ ✗✗✗✗ ✓✗ |
1 |
ASSERT_TRUE(reflectable); |
429 |
|||
430 |
✓✗ | 1 |
reflectable->initializeChildren(); |
431 |
|||
432 |
✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✓✗ |
1 |
ASSERT_EQ(13, reflectable->getField("value")->getUInt32()); |
433 |
✓✗✓✗ ✓✗✓✗ ✗✓✗✗ ✗✗✗✗ ✓✗ |
1 |
ASSERT_EQ(13, reflectable->getField("nested")->getParameter("param")->getUInt32()); |
434 |
✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✓✗ |
1 |
ASSERT_EQ(10, reflectable->find("nested.value")->getUInt32()); |
435 |
✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✓✗ |
1 |
ASSERT_EQ("nested"_sv, reflectable->find("nested.text")->getStringView()); |
436 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✓✗ |
1 |
ASSERT_EQ(BitBuffer({0xCB, 0xF0}, 12), reflectable->find("nested.externData")->getBitBuffer()); |
437 |
✓✗✓✗ |
1 |
const Span<const uint8_t> bytesData = reflectable->find("nested.bytesData")->getBytes(); |
438 |
✓✗✗✓ ✗✗✗✗ ✗✗✓✗ |
1 |
ASSERT_EQ(2, bytesData.size()); |
439 |
✓✗✗✓ ✗✗✗✗ ✗✗✓✗ |
1 |
ASSERT_EQ(0xCA, bytesData[0]); |
440 |
✓✗✗✓ ✗✗✗✗ ✗✗✓✗ |
1 |
ASSERT_EQ(0xFE, bytesData[1]); |
441 |
✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✓✗ |
1 |
ASSERT_EQ(enumToValue(CreatorEnum::MinusOne), reflectable->find("nested.creatorEnum")->getInt8()); |
442 |
✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✓✗ ✓✗ |
1 |
ASSERT_EQ(CreatorBitmask(CreatorBitmask::Values::READ).getValue(), |
443 |
reflectable->find("nested.creatorBitmask")->getUInt8()); |
||
444 |
} |
||
445 |
|||
446 |
✓✗✓✗ ✓✗✗✓ |
802 |
TEST(JsonReaderTest, readStringifiedEnum) |
447 |
{ |
||
448 |
1 |
checkReadStringifiedEnum("ONE", CreatorEnum::ONE); |
|
449 |
1 |
checkReadStringifiedEnum("MinusOne", CreatorEnum::MinusOne); |
|
450 |
checkReadStringifiedEnumThrows("NONEXISTING", |
||
451 |
"ZserioTreeCreator: Cannot create enum 'test_object.std_allocator.CreatorEnum' " |
||
452 |
1 |
"from string value 'NONEXISTING'! (JsonParser:3:24)"); |
|
453 |
checkReadStringifiedEnumThrows("***", |
||
454 |
"ZserioTreeCreator: Cannot create enum 'test_object.std_allocator.CreatorEnum' " |
||
455 |
1 |
"from string value '***'! (JsonParser:3:24)"); |
|
456 |
checkReadStringifiedEnumThrows("10 /* no match */", |
||
457 |
"ZserioTreeCreator: Cannot create enum 'test_object.std_allocator.CreatorEnum' " |
||
458 |
1 |
"from string value '10 /* no match */'! (JsonParser:3:24)"); |
|
459 |
checkReadStringifiedEnumThrows("-10 /* no match */", |
||
460 |
"ZserioTreeCreator: Cannot create enum 'test_object.std_allocator.CreatorEnum' " |
||
461 |
1 |
"from string value '-10 /* no match */'! (JsonParser:3:24)"); |
|
462 |
checkReadStringifiedEnumThrows("", |
||
463 |
"ZserioTreeCreator: Cannot create enum 'test_object.std_allocator.CreatorEnum' " |
||
464 |
1 |
"from string value ''! (JsonParser:3:24)"); |
|
465 |
1 |
} |
|
466 |
|||
467 |
✓✗✓✗ ✓✗✗✓ |
802 |
TEST(JsonReaderTest, readStringifiedBitmask) |
468 |
{ |
||
469 |
2 |
checkReadStringifiedBitmask("READ", |
|
470 |
✓✗ | 1 |
CreatorBitmask::Values::READ); |
471 |
1 |
checkReadStringifiedBitmask("READ | WRITE", |
|
472 |
1 |
CreatorBitmask::Values::READ | CreatorBitmask::Values::WRITE); |
|
473 |
checkReadStringifiedBitmaskThrows("NONEXISTING", |
||
474 |
"ZserioTreeCreator: Cannot create bitmask 'test_object.std_allocator.CreatorBitmask' " |
||
475 |
1 |
"from string value 'NONEXISTING'! (JsonParser:3:27)"); |
|
476 |
checkReadStringifiedBitmaskThrows("READ | NONEXISTING", |
||
477 |
"ZserioTreeCreator: Cannot create bitmask 'test_object.std_allocator.CreatorBitmask' " |
||
478 |
1 |
"from string value 'READ | NONEXISTING'! (JsonParser:3:27)"); |
|
479 |
checkReadStringifiedBitmaskThrows("READ * NONEXISTING", |
||
480 |
"ZserioTreeCreator: Cannot create bitmask 'test_object.std_allocator.CreatorBitmask' " |
||
481 |
1 |
"from string value 'READ * NONEXISTING'! (JsonParser:3:27)"); |
|
482 |
✓✗ | 1 |
checkReadStringifiedBitmask("7 /* READ | WRITE */", CreatorBitmask(7)); |
483 |
✓✗ | 1 |
checkReadStringifiedBitmask("15 /* READ | WRITE */", CreatorBitmask(15)); |
484 |
✓✗ | 1 |
checkReadStringifiedBitmask("4 /* no match */", CreatorBitmask(4)); |
485 |
checkReadStringifiedBitmaskThrows("", |
||
486 |
"ZserioTreeCreator: Cannot create bitmask 'test_object.std_allocator.CreatorBitmask' " |
||
487 |
1 |
"from string value ''! (JsonParser:3:27)"); |
|
488 |
checkReadStringifiedBitmaskThrows(" ", |
||
489 |
"ZserioTreeCreator: Cannot create bitmask 'test_object.std_allocator.CreatorBitmask' " |
||
490 |
1 |
"from string value ' '! (JsonParser:3:27)"); |
|
491 |
checkReadStringifiedBitmaskThrows(" | ", |
||
492 |
"ZserioTreeCreator: Cannot create bitmask 'test_object.std_allocator.CreatorBitmask' " |
||
493 |
1 |
"from string value ' | '! (JsonParser:3:27)"); |
|
494 |
1 |
} |
|
495 |
|||
496 |
✓✗✓✗ ✓✗✗✓ |
802 |
TEST(JsonReaderTest, jsonParserException) |
497 |
{ |
||
498 |
std::stringstream str( |
||
499 |
"{\"value\"\n\"value\"" |
||
500 |
✓✗✓✗ |
2 |
); |
501 |
✓✗✓✗ ✗✓ |
2 |
JsonReader jsonReader(str); |
502 |
|||
503 |
✓✗✓✗ ✓✗✓✗ ✗✓✗✓ ✗✗✗✗ ✗✗✗✗ ✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✓✗ ✗✗✓✗ ✗✓✗✗ ✗✗✗✗ ✗✗✗✗ ✗✗✗✗ ✗✗✗ |
2 |
ASSERT_THROW({ |
504 |
try |
||
505 |
{ |
||
506 |
jsonReader.read(CreatorObject::typeInfo()); |
||
507 |
} |
||
508 |
catch (const JsonParserException& e) |
||
509 |
{ |
||
510 |
ASSERT_STREQ("JsonParser:2:1: unexpected token: VALUE, expecting KEY_SEPARATOR!", e.what()); |
||
511 |
throw; |
||
512 |
} |
||
513 |
}, JsonParserException); |
||
514 |
} |
||
515 |
|||
516 |
✓✗✓✗ ✓✗✗✓ |
802 |
TEST(JsonReaderTest, wrongKeyException) |
517 |
{ |
||
518 |
std::stringstream str( |
||
519 |
"{\"value\": 13,\n\"nonexisting\": 10}" |
||
520 |
✓✗✓✗ |
2 |
); |
521 |
✓✗✓✗ ✗✓ |
2 |
JsonReader jsonReader(str); |
522 |
|||
523 |
✓✗✓✗ ✓✗✓✗ ✗✓✗✓ ✗✗✗✗ ✗✗✗✗ ✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✓✗ ✗✗✓✗ ✗✓✗✗ ✗✗✗✗ ✗✗✗✗ ✗✗✗✗ ✗✗✗ |
2 |
ASSERT_THROW({ |
524 |
try |
||
525 |
{ |
||
526 |
jsonReader.read(CreatorObject::typeInfo()); |
||
527 |
} |
||
528 |
catch (const CppRuntimeException& e) |
||
529 |
{ |
||
530 |
ASSERT_STREQ("ZserioTreeCreator: Member 'nonexisting' not found in " |
||
531 |
"'test_object.std_allocator.CreatorObject'! (JsonParser:2:16)", e.what()); |
||
532 |
throw; |
||
533 |
} |
||
534 |
}, CppRuntimeException); |
||
535 |
} |
||
536 |
|||
537 |
✓✗✓✗ ✓✗✗✓ |
802 |
TEST(JsonReaderTest, wrongValueTypeException) |
538 |
{ |
||
539 |
std::stringstream str( |
||
540 |
"{\n \"value\": \"13\"\n}" |
||
541 |
✓✗✓✗ |
2 |
); |
542 |
✓✗✓✗ ✗✓ |
2 |
JsonReader jsonReader(str); |
543 |
|||
544 |
✓✗✓✗ ✓✗✓✗ ✗✓✗✓ ✗✗✗✗ ✗✗✗✗ ✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✓✗ ✗✗✓✗ ✗✓✗✗ ✗✗✗✗ ✗✗✗✗ ✗✗✗✗ ✗✗✗ |
2 |
ASSERT_THROW({ |
545 |
try |
||
546 |
{ |
||
547 |
jsonReader.read(CreatorObject::typeInfo()); |
||
548 |
} |
||
549 |
catch (const CppRuntimeException& e) |
||
550 |
{ |
||
551 |
ASSERT_STREQ("ZserioTreeCreator: Value '13' cannot be converted to integral value! " |
||
552 |
"(JsonParser:2:12)", e.what()); |
||
553 |
throw; |
||
554 |
} |
||
555 |
}, CppRuntimeException); |
||
556 |
} |
||
557 |
|||
558 |
✓✗✓✗ ✓✗✗✓ |
802 |
TEST(JsonReaderTest, wrongBitBufferException) |
559 |
{ |
||
560 |
std::stringstream str( |
||
561 |
"{\n" |
||
562 |
" \"value\": 13,\n" |
||
563 |
" \"nested\": {\n" |
||
564 |
" \"value\": 10,\n" |
||
565 |
" \"text\": \"nested\",\n" |
||
566 |
" \"externData\": {\n" |
||
567 |
" \"buffer\": [\n" |
||
568 |
" 203,\n" |
||
569 |
" 240\n" |
||
570 |
" ],\n" |
||
571 |
" \"bitSize\": {\n" |
||
572 |
" }\n" |
||
573 |
" }\n" |
||
574 |
" }\n" |
||
575 |
"}" |
||
576 |
✓✗✓✗ |
2 |
); |
577 |
✓✗✓✗ ✗✓ |
2 |
JsonReader jsonReader(str); |
578 |
|||
579 |
✓✗✓✗ ✓✗✓✗ ✗✓✗✓ ✗✗✗✗ ✗✗✗✗ ✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✓✗ ✗✗✓✗ ✗✓✗✗ ✗✗✗✗ ✗✗✗✗ ✗✗✗✗ ✗✗✗ |
2 |
ASSERT_THROW({ |
580 |
try |
||
581 |
{ |
||
582 |
jsonReader.read(CreatorObject::typeInfo()); |
||
583 |
} |
||
584 |
catch (const CppRuntimeException& e) |
||
585 |
{ |
||
586 |
ASSERT_STREQ("JsonReader: Unexpected beginObject in BitBuffer! (JsonParser:12:14)", e.what()); |
||
587 |
throw; |
||
588 |
} |
||
589 |
}, CppRuntimeException); |
||
590 |
} |
||
591 |
|||
592 |
✓✗✓✗ ✓✗✗✓ |
802 |
TEST(JsonReaderTest, partialBitBufferException) |
593 |
{ |
||
594 |
std::stringstream str( |
||
595 |
"{\n" |
||
596 |
" \"value\": 13,\n" |
||
597 |
" \"nested\": {\n" |
||
598 |
" \"value\": 10,\n" |
||
599 |
" \"text\": \"nested\",\n" |
||
600 |
" \"externData\": {\n" |
||
601 |
" \"buffer\": [\n" |
||
602 |
" 203,\n" |
||
603 |
" 240\n" |
||
604 |
" ]\n" |
||
605 |
" }\n" |
||
606 |
" }\n" |
||
607 |
"}" |
||
608 |
✓✗✓✗ |
2 |
); |
609 |
✓✗✓✗ ✗✓ |
2 |
JsonReader jsonReader(str); |
610 |
|||
611 |
✓✗✓✗ ✓✗✓✗ ✗✓✗✓ ✗✗✗✗ ✗✗✗✗ ✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✓✗ ✗✗✓✗ ✗✓✗✗ ✗✗✗✗ ✗✗✗✗ ✗✗✗✗ ✗✗✗ |
2 |
ASSERT_THROW({ |
612 |
try |
||
613 |
{ |
||
614 |
jsonReader.read(CreatorObject::typeInfo()); |
||
615 |
} |
||
616 |
catch (const CppRuntimeException& e) |
||
617 |
{ |
||
618 |
ASSERT_STREQ("JsonReader: Unexpected end in BitBuffer! (JsonParser:12:5)", e.what()); |
||
619 |
throw; |
||
620 |
} |
||
621 |
}, CppRuntimeException); |
||
622 |
} |
||
623 |
|||
624 |
✓✗✓✗ ✓✗✗✓ |
802 |
TEST(JsonReaderTest, bigBitBufferByteValueException) |
625 |
{ |
||
626 |
std::stringstream str( |
||
627 |
"{\n" |
||
628 |
" \"nested\": {\n" |
||
629 |
" \"externData\": {\n" |
||
630 |
" \"buffer\": [\n" |
||
631 |
" 256\n" |
||
632 |
" ],\n" |
||
633 |
" \"bitSize\": 7\n" |
||
634 |
" }\n" |
||
635 |
" }\n" |
||
636 |
"}" |
||
637 |
✓✗✓✗ |
2 |
); |
638 |
✓✗✓✗ ✗✓ |
2 |
JsonReader jsonReader(str); |
639 |
|||
640 |
✓✗✓✗ ✓✗✓✗ ✗✓✗✓ ✗✗✗✗ ✗✗✗✗ ✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✓✗ ✗✗✓✗ ✗✓✗✗ ✗✗✗✗ ✗✗✗✗ ✗✗✗✗ ✗✗✗ |
2 |
ASSERT_THROW({ |
641 |
try |
||
642 |
{ |
||
643 |
jsonReader.read(CreatorObject::typeInfo()); |
||
644 |
} |
||
645 |
catch (const CppRuntimeException& e) |
||
646 |
{ |
||
647 |
ASSERT_STREQ("JsonReader: Cannot create byte for Bit Buffer from value '256'! (JsonParser:5:18)", |
||
648 |
e.what()); |
||
649 |
throw; |
||
650 |
} |
||
651 |
}, CppRuntimeException); |
||
652 |
} |
||
653 |
|||
654 |
✓✗✓✗ ✓✗✗✓ |
802 |
TEST(JsonReaderTest, negativeBitBufferByteValueException) |
655 |
{ |
||
656 |
std::stringstream str( |
||
657 |
"{\n" |
||
658 |
" \"nested\": {\n" |
||
659 |
" \"externData\": {\n" |
||
660 |
" \"buffer\": [\n" |
||
661 |
" -1\n" |
||
662 |
" ],\n" |
||
663 |
" \"bitSize\": 7\n" |
||
664 |
" }\n" |
||
665 |
" }\n" |
||
666 |
"}" |
||
667 |
✓✗✓✗ |
2 |
); |
668 |
✓✗✓✗ ✗✓ |
2 |
JsonReader jsonReader(str); |
669 |
|||
670 |
✓✗✓✗ ✓✗✓✗ ✗✓✗✓ ✗✗✗✗ ✗✗✗✗ ✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✓✗ ✗✗✓✗ ✗✓✗✗ ✗✗✗✗ ✗✗✗✗ ✗✗✗✗ ✗✗✗ |
2 |
ASSERT_THROW({ |
671 |
try |
||
672 |
{ |
||
673 |
jsonReader.read(CreatorObject::typeInfo()); |
||
674 |
} |
||
675 |
catch (const CppRuntimeException& e) |
||
676 |
{ |
||
677 |
ASSERT_STREQ("JsonReader: Unexpected visitValue (int) in BitBuffer! (JsonParser:5:18)", e.what()); |
||
678 |
throw; |
||
679 |
} |
||
680 |
}, CppRuntimeException); |
||
681 |
} |
||
682 |
|||
683 |
✓✗✓✗ ✓✗✗✓ |
802 |
TEST(JsonReaderTest, wrongBitBufferSizeValueException) |
684 |
{ |
||
685 |
std::stringstream str( |
||
686 |
"{\n" |
||
687 |
" \"nested\": {\n" |
||
688 |
" \"externData\": {\n" |
||
689 |
" \"buffer\": [\n" |
||
690 |
" 255\n" |
||
691 |
" ],\n" |
||
692 |
" \"bitSize\": 18446744073709551616\n" |
||
693 |
" }\n" |
||
694 |
" }\n" |
||
695 |
"}" |
||
696 |
✓✗✓✗ |
2 |
); |
697 |
✓✗✓✗ ✗✓ |
2 |
JsonReader jsonReader(str); |
698 |
|||
699 |
✓✗✓✗ ✓✗✓✗ ✗✓✗✓ ✗✗✗✗ ✗✗✗✗ ✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✓✗ ✗✗✓✗ ✗✓✗✗ ✗✗✗✗ ✗✗✗✗ ✗✗✗✗ ✗✗✗ |
2 |
ASSERT_THROW({ |
700 |
try |
||
701 |
{ |
||
702 |
jsonReader.read(CreatorObject::typeInfo()); |
||
703 |
} |
||
704 |
catch (const CppRuntimeException& e) |
||
705 |
{ |
||
706 |
ASSERT_STREQ("JsonTokenizer:7:25: Value is outside of the 64-bit integer range!", e.what()); |
||
707 |
throw; |
||
708 |
} |
||
709 |
}, CppRuntimeException); |
||
710 |
} |
||
711 |
|||
712 |
✓✗✓✗ ✓✗✗✓ |
802 |
TEST(JsonReaderTest, wrongBitBufferNullPtrValueException) |
713 |
{ |
||
714 |
std::stringstream str( |
||
715 |
"{\n" |
||
716 |
" \"nested\": {\n" |
||
717 |
" \"externData\": {\n" |
||
718 |
" \"buffer\": [\n" |
||
719 |
" 255\n" |
||
720 |
" ],\n" |
||
721 |
" \"bitSize\": null\n" |
||
722 |
" }\n" |
||
723 |
" }\n" |
||
724 |
"}" |
||
725 |
✓✗✓✗ |
2 |
); |
726 |
✓✗✓✗ ✗✓ |
2 |
JsonReader jsonReader(str); |
727 |
|||
728 |
✓✗✓✗ ✓✗✓✗ ✗✓✗✓ ✗✗✗✗ ✗✗✗✗ ✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✓✗ ✗✗✓✗ ✗✓✗✗ ✗✗✗✗ ✗✗✗✗ ✗✗✗✗ ✗✗✗ |
2 |
ASSERT_THROW({ |
729 |
try |
||
730 |
{ |
||
731 |
jsonReader.read(CreatorObject::typeInfo()); |
||
732 |
} |
||
733 |
catch (const CppRuntimeException& e) |
||
734 |
{ |
||
735 |
ASSERT_STREQ("JsonReader: Unexpected visitValue (null) in BitBuffer! (JsonParser:7:25)", e.what()); |
||
736 |
throw; |
||
737 |
} |
||
738 |
}, CppRuntimeException); |
||
739 |
} |
||
740 |
|||
741 |
✓✗✓✗ ✓✗✗✓ |
802 |
TEST(JsonReaderTest, wrongBitBufferBoolValueException) |
742 |
{ |
||
743 |
std::stringstream str( |
||
744 |
"{\n" |
||
745 |
" \"nested\": {\n" |
||
746 |
" \"externData\": {\n" |
||
747 |
" \"buffer\": [\n" |
||
748 |
" 255\n" |
||
749 |
" ],\n" |
||
750 |
" \"bitSize\": true\n" |
||
751 |
" }\n" |
||
752 |
" }\n" |
||
753 |
"}" |
||
754 |
✓✗✓✗ |
2 |
); |
755 |
✓✗✓✗ ✗✓ |
2 |
JsonReader jsonReader(str); |
756 |
|||
757 |
✓✗✓✗ ✓✗✓✗ ✗✓✗✓ ✗✗✗✗ ✗✗✗✗ ✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✓✗ ✗✗✓✗ ✗✓✗✗ ✗✗✗✗ ✗✗✗✗ ✗✗✗✗ ✗✗✗ |
2 |
ASSERT_THROW({ |
758 |
try |
||
759 |
{ |
||
760 |
jsonReader.read(CreatorObject::typeInfo()); |
||
761 |
} |
||
762 |
catch (const CppRuntimeException& e) |
||
763 |
{ |
||
764 |
ASSERT_STREQ("JsonReader: Unexpected visitValue (bool) in BitBuffer! (JsonParser:7:25)", e.what()); |
||
765 |
throw; |
||
766 |
} |
||
767 |
}, CppRuntimeException); |
||
768 |
} |
||
769 |
|||
770 |
✓✗✓✗ ✓✗✗✓ |
802 |
TEST(JsonReaderTest, wrongBitBufferDoubleValueException) |
771 |
{ |
||
772 |
std::stringstream str( |
||
773 |
"{\n" |
||
774 |
" \"nested\": {\n" |
||
775 |
" \"externData\": {\n" |
||
776 |
" \"buffer\": [\n" |
||
777 |
" 255\n" |
||
778 |
" ],\n" |
||
779 |
" \"bitSize\": 1.0\n" |
||
780 |
" }\n" |
||
781 |
" }\n" |
||
782 |
"}" |
||
783 |
✓✗✓✗ |
2 |
); |
784 |
✓✗✓✗ ✗✓ |
2 |
JsonReader jsonReader(str); |
785 |
|||
786 |
✓✗✓✗ ✓✗✓✗ ✗✓✗✓ ✗✗✗✗ ✗✗✗✗ ✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✓✗ ✗✗✓✗ ✗✓✗✗ ✗✗✗✗ ✗✗✗✗ ✗✗✗✗ ✗✗✗ |
2 |
ASSERT_THROW({ |
787 |
try |
||
788 |
{ |
||
789 |
jsonReader.read(CreatorObject::typeInfo()); |
||
790 |
} |
||
791 |
catch (const CppRuntimeException& e) |
||
792 |
{ |
||
793 |
ASSERT_STREQ("JsonReader: Unexpected visitValue (double) in BitBuffer! (JsonParser:7:25)", |
||
794 |
e.what()); |
||
795 |
throw; |
||
796 |
} |
||
797 |
}, CppRuntimeException); |
||
798 |
} |
||
799 |
|||
800 |
✓✗✓✗ ✓✗✗✓ |
802 |
TEST(JsonReaderTest, wrongBitBufferStringValueException) |
801 |
{ |
||
802 |
std::stringstream str( |
||
803 |
"{\n" |
||
804 |
" \"nested\": {\n" |
||
805 |
" \"externData\": {\n" |
||
806 |
" \"buffer\": [\n" |
||
807 |
" 255\n" |
||
808 |
" ],\n" |
||
809 |
" \"bitSize\": \"Text\"\n" |
||
810 |
" }\n" |
||
811 |
" }\n" |
||
812 |
"}" |
||
813 |
✓✗✓✗ |
2 |
); |
814 |
✓✗✓✗ ✗✓ |
2 |
JsonReader jsonReader(str); |
815 |
|||
816 |
✓✗✓✗ ✓✗✓✗ ✗✓✗✓ ✗✗✗✗ ✗✗✗✗ ✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✓✗ ✗✗✓✗ ✗✓✗✗ ✗✗✗✗ ✗✗✗✗ ✗✗✗✗ ✗✗✗ |
2 |
ASSERT_THROW({ |
817 |
try |
||
818 |
{ |
||
819 |
jsonReader.read(CreatorObject::typeInfo()); |
||
820 |
} |
||
821 |
catch (const CppRuntimeException& e) |
||
822 |
{ |
||
823 |
ASSERT_STREQ("JsonReader: Unexpected visitValue (string) in BitBuffer! (JsonParser:7:25)", |
||
824 |
e.what()); |
||
825 |
throw; |
||
826 |
} |
||
827 |
}, CppRuntimeException); |
||
828 |
} |
||
829 |
|||
830 |
✓✗✓✗ ✓✗✗✓ |
802 |
TEST(JsonReaderTest, wrongBytesException) |
831 |
{ |
||
832 |
std::stringstream str( |
||
833 |
"{\n" |
||
834 |
" \"value\": 13,\n" |
||
835 |
" \"nested\": {\n" |
||
836 |
" \"value\": 10,\n" |
||
837 |
" \"text\": \"nested\",\n" |
||
838 |
" \"externData\": {\n" |
||
839 |
" \"buffer\": [\n" |
||
840 |
" 203,\n" |
||
841 |
" 240\n" |
||
842 |
" ],\n" |
||
843 |
" \"bitSize\": 12\n" |
||
844 |
" },\n" |
||
845 |
" \"bytesData\" : {\n" |
||
846 |
" \"buffer\" : {}\n" |
||
847 |
" }\n" |
||
848 |
" }\n" |
||
849 |
"}" |
||
850 |
✓✗✓✗ |
2 |
); |
851 |
✓✗✓✗ ✗✓ |
2 |
JsonReader jsonReader(str); |
852 |
|||
853 |
✓✗✓✗ ✓✗✓✗ ✗✓✗✓ ✗✗✗✗ ✗✗✗✗ ✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✓✗ ✗✗✓✗ ✗✓✗✗ ✗✗✗✗ ✗✗✗✗ ✗✗✗✗ ✗✗✗ |
2 |
ASSERT_THROW({ |
854 |
try |
||
855 |
{ |
||
856 |
jsonReader.read(CreatorObject::typeInfo()); |
||
857 |
} |
||
858 |
catch (const CppRuntimeException& e) |
||
859 |
{ |
||
860 |
ASSERT_STREQ("JsonReader: Unexpected beginObject in bytes! (JsonParser:14:25)", e.what()); |
||
861 |
throw; |
||
862 |
} |
||
863 |
}, CppRuntimeException); |
||
864 |
} |
||
865 |
|||
866 |
✓✗✓✗ ✓✗✗✓ |
802 |
TEST(JsonReaderTest, negativeBytesByteValueException) |
867 |
{ |
||
868 |
std::stringstream str( |
||
869 |
"{\n" |
||
870 |
" \"nested\": {\n" |
||
871 |
" \"bytesData\": {\n" |
||
872 |
" \"buffer\": [\n" |
||
873 |
" -1\n" |
||
874 |
" ]\n" |
||
875 |
" }\n" |
||
876 |
" }\n" |
||
877 |
"}" |
||
878 |
✓✗✓✗ |
2 |
); |
879 |
✓✗✓✗ ✗✓ |
2 |
JsonReader jsonReader(str); |
880 |
|||
881 |
✓✗✓✗ ✓✗✓✗ ✗✓✗✓ ✗✗✗✗ ✗✗✗✗ ✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✓✗ ✗✗✓✗ ✗✓✗✗ ✗✗✗✗ ✗✗✗✗ ✗✗✗✗ ✗✗✗ |
2 |
ASSERT_THROW({ |
882 |
try |
||
883 |
{ |
||
884 |
jsonReader.read(CreatorObject::typeInfo()); |
||
885 |
} |
||
886 |
catch (const CppRuntimeException& e) |
||
887 |
{ |
||
888 |
ASSERT_STREQ("JsonReader: Unexpected visitValue (int) in bytes! (JsonParser:5:18)", e.what()); |
||
889 |
throw; |
||
890 |
} |
||
891 |
}, CppRuntimeException); |
||
892 |
} |
||
893 |
|||
894 |
✓✗✓✗ ✓✗✗✓ |
802 |
TEST(JsonReaderTest, jsonArrayException) |
895 |
{ |
||
896 |
✓✗✓✗ |
2 |
std::stringstream str("[1, 2]"); |
897 |
✓✗✓✗ ✓✗✗ |
2 |
JsonReader jsonReader(str); |
898 |
|||
899 |
✓✗✓✗ ✓✗✓✗ ✗✓✗✓ ✗✗✗✗ ✗✗✗✗ ✓✗✓✗ ✓✗✗✗ ✗✗✗✗ ✗✗✗✗ ✗✗✗✗ ✗✗ |
2 |
ASSERT_THROW(jsonReader.read(CreatorObject::typeInfo()), CppRuntimeException); |
900 |
} |
||
901 |
|||
902 |
✓✗✓✗ ✓✗✗✓ |
802 |
TEST(JsonReaderTest, jsonValueException) |
903 |
{ |
||
904 |
✓✗✓✗ |
2 |
std::stringstream str("\"text\""); |
905 |
✓✗✓✗ ✓✗✗ |
2 |
JsonReader jsonReader(str); |
906 |
|||
907 |
✓✗✓✗ ✓✗✓✗ ✗✓✗✓ ✗✗✗✗ ✗✗✗✗ ✓✗✓✗ ✓✗✗✗ ✗✗✗✗ ✗✗✗✗ ✗✗✗✗ ✗✗ |
2 |
ASSERT_THROW(jsonReader.read(CreatorObject::typeInfo()), CppRuntimeException); |
908 |
} |
||
909 |
|||
910 |
✓✗✓✗ ✓✗✗✓ |
802 |
TEST(JsonReaderTest, bigLongValueException) |
911 |
{ |
||
912 |
std::stringstream str( |
||
913 |
"{\n" |
||
914 |
" \"value\": 4294967296\n" |
||
915 |
"}" |
||
916 |
✓✗✓✗ |
2 |
); |
917 |
✓✗✓✗ ✗✓ |
2 |
JsonReader jsonReader(str); |
918 |
|||
919 |
✓✗✓✗ ✓✗✓✗ ✗✓✗✓ ✗✗✗✗ ✗✗✗✗ ✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✓✗ ✗✗✓✗ ✗✓✗✗ ✗✗✗✗ ✗✗✗✗ ✗✗✗✗ ✗✗✗ |
2 |
ASSERT_THROW({ |
920 |
try |
||
921 |
{ |
||
922 |
jsonReader.read(CreatorObject::typeInfo()); |
||
923 |
} |
||
924 |
catch (const CppRuntimeException& e) |
||
925 |
{ |
||
926 |
ASSERT_STREQ("ZserioTreeCreator: Integral value '4294967296' overflow (<0, 4294967295>)! " |
||
927 |
"(JsonParser:2:14)", e.what()); |
||
928 |
throw; |
||
929 |
} |
||
930 |
}, CppRuntimeException); |
||
931 |
} |
||
932 |
|||
933 |
✓✗✓✗ ✓✗✗✓ |
802 |
TEST(JsonReaderTest, floatLongValueException) |
934 |
{ |
||
935 |
std::stringstream str( |
||
936 |
"{\n" |
||
937 |
" \"value\": 1.234\n" |
||
938 |
"}" |
||
939 |
✓✗✓✗ |
2 |
); |
940 |
✓✗✓✗ ✗✓ |
2 |
JsonReader jsonReader(str); |
941 |
|||
942 |
✓✗✓✗ ✓✗✓✗ ✗✓✗✓ ✗✗✗✗ ✗✗✗✗ ✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✓✗ ✗✗✓✗ ✗✓✗✗ ✗✗✗✗ ✗✗✗✗ ✗✗✗✗ ✗✗✗ |
2 |
ASSERT_THROW({ |
943 |
try |
||
944 |
{ |
||
945 |
jsonReader.read(CreatorObject::typeInfo()); |
||
946 |
} |
||
947 |
catch (const CppRuntimeException& e) |
||
948 |
{ |
||
949 |
ASSERT_STREQ("ZserioTreeCreator: Value '1.233' cannot be converted to integral value! " |
||
950 |
"(JsonParser:2:14)", e.what()); |
||
951 |
throw; |
||
952 |
} |
||
953 |
}, CppRuntimeException); |
||
954 |
} |
||
955 |
|||
956 |
✓✗✓✗ ✓✗✗✓ |
802 |
TEST(JsonReaderTest, bigBytesByteValueException) |
957 |
{ |
||
958 |
std::stringstream str( |
||
959 |
"{\n" |
||
960 |
" \"nested\": {\n" |
||
961 |
" \"bytesData\": {\n" |
||
962 |
" \"buffer\": [\n" |
||
963 |
" 256\n" |
||
964 |
" ]\n" |
||
965 |
" }\n" |
||
966 |
" }\n" |
||
967 |
"}" |
||
968 |
✓✗✓✗ |
2 |
); |
969 |
✓✗✓✗ ✗✓ |
2 |
JsonReader jsonReader(str); |
970 |
|||
971 |
✓✗✓✗ ✓✗✓✗ ✗✓✗✓ ✗✗✗✗ ✗✗✗✗ ✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✓✗ ✗✗✓✗ ✗✓✗✗ ✗✗✗✗ ✗✗✗✗ ✗✗✗✗ ✗✗✗ |
2 |
ASSERT_THROW({ |
972 |
try |
||
973 |
{ |
||
974 |
jsonReader.read(CreatorObject::typeInfo()); |
||
975 |
} |
||
976 |
catch (const CppRuntimeException& e) |
||
977 |
{ |
||
978 |
ASSERT_STREQ("JsonReader: Cannot create byte for bytes from value '256'! (JsonParser:5:18)", |
||
979 |
e.what()); |
||
980 |
throw; |
||
981 |
} |
||
982 |
}, CppRuntimeException); |
||
983 |
} |
||
984 |
|||
985 |
✓✗✓✗ ✓✗✗✓ |
802 |
TEST(JsonReaderTest, bytesAdapterUninitializedCalls) |
986 |
{ |
||
987 |
✓✗✓✗ ✗ |
2 |
detail::BytesAdapter<std::allocator<uint8_t>> bytesAdapter{std::allocator<uint8_t>()}; |
988 |
|||
989 |
✓✗✓✗ ✓✗✗✓ ✗✓✗✗ ✗✗✗✗ ✗✗✓✗ ✓✗✗✗ ✗✗✗✗ ✗✗✗✗ ✗✗✗✗ ✗✗✓✗ ✗ |
2 |
ASSERT_THROW(bytesAdapter.get(), CppRuntimeException); |
990 |
✓✗✓✗ ✓✗✗✓ ✗✓✗✗ ✗✗✗✗ ✗✗✓✗ ✓✗✗✗ ✗✗✗✗ ✗✗✗✗ ✗✗✗✗ ✗✗✓✗ ✗ |
2 |
ASSERT_THROW(bytesAdapter.beginObject(), CppRuntimeException); |
991 |
✓✗✓✗ ✓✗✗✓ ✗✓✗✗ ✗✗✗✗ ✗✗✓✗ ✓✗✗✗ ✗✗✗✗ ✗✗✗✗ ✗✗✗✗ ✗✗✓✗ ✗ |
2 |
ASSERT_THROW(bytesAdapter.endObject(), CppRuntimeException); |
992 |
✓✗✓✗ ✓✗✗✓ ✗✓✗✗ ✗✗✗✗ ✗✗✓✗ ✓✗✗✗ ✗✗✗✗ ✗✗✗✗ ✗✗✗✗ ✗✗✓✗ ✗ |
2 |
ASSERT_THROW(bytesAdapter.beginArray(), CppRuntimeException); |
993 |
✓✗✓✗ ✓✗✗✓ ✗✓✗✗ ✗✗✗✗ ✗✗✓✗ ✓✗✗✗ ✗✗✗✗ ✗✗✗✗ ✗✗✗✗ ✗✗✓✗ ✗ |
2 |
ASSERT_THROW(bytesAdapter.endArray(), CppRuntimeException); |
994 |
✓✗✓✗ ✓✗✗✓ ✗✓✗✗ ✗✗✗✗ ✗✗✓✗ ✓✗✗✗ ✗✗✗✗ ✗✗✗✗ ✗✗✗✗ ✗✗✓✗ ✗ |
2 |
ASSERT_THROW(bytesAdapter.visitKey("nonexisting"_sv), CppRuntimeException); |
995 |
✓✗✓✗ ✓✗✗✓ ✗✓✗✗ ✗✗✗✗ ✗✗✓✗ ✓✗✗✗ ✗✗✗✗ ✗✗✗✗ ✗✗✗✗ ✗✗✓✗ ✗ |
2 |
ASSERT_THROW(bytesAdapter.visitValue(static_cast<uint64_t>(10)), CppRuntimeException); |
996 |
✓✗ | 1 |
bytesAdapter.visitKey("buffer"_sv); |
997 |
✓✗✓✗ ✓✗✗✓ ✗✓✗✗ ✗✗✗✗ ✗✗✓✗ ✓✗✗✗ ✗✗✗✗ ✗✗✗✗ ✗✗✗✗ ✗✗✓✗ ✗ |
2 |
ASSERT_THROW(bytesAdapter.get(), CppRuntimeException); |
998 |
✓✗✓✗ ✓✗✗✓ ✗✓✗✗ ✗✗✗✗ ✗✗✓✗ ✓✗✗✗ ✗✗✗✗ ✗✗✗✗ ✗✗✗✗ ✗✗✓✗ ✗ |
2 |
ASSERT_THROW(bytesAdapter.visitKey("nonexisting"_sv), CppRuntimeException); |
999 |
✓✗✓✗ ✓✗✗✓ ✗✓✗✗ ✗✗✗✗ ✗✗✓✗ ✓✗✗✗ ✗✗✗✗ ✗✗✗✗ ✗✗✗✗ ✗✗✓✗ ✗ |
2 |
ASSERT_THROW(bytesAdapter.visitValue(nullptr), CppRuntimeException); |
1000 |
✓✗✓✗ ✓✗✗✓ ✗✓✗✗ ✗✗✗✗ ✗✗✓✗ ✓✗✗✗ ✗✗✗✗ ✗✗✗✗ ✗✗✗✗ ✗✗✓✗ ✗ |
2 |
ASSERT_THROW(bytesAdapter.visitValue(true), CppRuntimeException); |
1001 |
✓✗✓✗ ✓✗✗✓ ✗✓✗✗ ✗✗✗✗ ✗✗✓✗ ✓✗✗✗ ✗✗✗✗ ✗✗✗✗ ✗✗✗✗ ✗✗✓✗ ✗ |
2 |
ASSERT_THROW(bytesAdapter.visitValue(static_cast<int64_t>(-1)), CppRuntimeException); |
1002 |
✓✗✓✗ ✓✗✗✓ ✗✓✗✗ ✗✗✗✗ ✗✗✓✗ ✓✗✗✗ ✗✗✗✗ ✗✗✗✗ ✗✗✗✗ ✗✗✓✗ ✗ |
2 |
ASSERT_THROW(bytesAdapter.visitValue(static_cast<uint64_t>(1)), CppRuntimeException); |
1003 |
✓✗✓✗ ✓✗✗✓ ✗✓✗✗ ✗✗✗✗ ✗✗✓✗ ✓✗✗✗ ✗✗✗✗ ✗✗✗✗ ✗✗✗✗ ✗✗✓✗ ✗ |
2 |
ASSERT_THROW(bytesAdapter.visitValue(0.0), CppRuntimeException); |
1004 |
✓✗✓✗ ✓✗✗✓ ✗✓✗✗ ✗✗✗✗ ✗✗✓✗ ✓✗✓✗ ✗✗✗✗ ✗✗✗✗ ✗✗✗✗ ✗✗✗✗ |
2 |
ASSERT_THROW(bytesAdapter.visitValue("BadValue"_sv), CppRuntimeException); |
1005 |
} |
||
1006 |
|||
1007 |
✓✗✓✗ ✓✗✗✓ |
802 |
TEST(JsonReaderTest, bitBufferAdapterUninitializedCalls) |
1008 |
{ |
||
1009 |
✓✗✓✗ ✗ |
2 |
detail::BitBufferAdapter<std::allocator<uint8_t>> bitBufferAdapter{std::allocator<uint8_t>()}; |
1010 |
|||
1011 |
✓✗✓✗ ✓✗✗✓ ✗✓✗✗ ✗✗✗✗ ✗✗✓✗ ✓✗✗✗ ✗✗✗✗ ✗✗✗✗ ✗✗✗✗ ✗✗✓✗ ✗ |
2 |
ASSERT_THROW(bitBufferAdapter.get(), CppRuntimeException); |
1012 |
✓✗✓✗ ✓✗✗✓ ✗✓✗✗ ✗✗✗✗ ✗✗✓✗ ✓✗✗✗ ✗✗✗✗ ✗✗✗✗ ✗✗✗✗ ✗✗✓✗ ✗ |
2 |
ASSERT_THROW(bitBufferAdapter.beginObject(), CppRuntimeException); |
1013 |
✓✗✓✗ ✓✗✗✓ ✗✓✗✗ ✗✗✗✗ ✗✗✓✗ ✓✗✗✗ ✗✗✗✗ ✗✗✗✗ ✗✗✗✗ ✗✗✓✗ ✗ |
2 |
ASSERT_THROW(bitBufferAdapter.endObject(), CppRuntimeException); |
1014 |
✓✗✓✗ ✓✗✗✓ ✗✓✗✗ ✗✗✗✗ ✗✗✓✗ ✓✗✗✗ ✗✗✗✗ ✗✗✗✗ ✗✗✗✗ ✗✗✓✗ ✗ |
2 |
ASSERT_THROW(bitBufferAdapter.beginArray(), CppRuntimeException); |
1015 |
✓✗✓✗ ✓✗✗✓ ✗✓✗✗ ✗✗✗✗ ✗✗✓✗ ✓✗✗✗ ✗✗✗✗ ✗✗✗✗ ✗✗✗✗ ✗✗✓✗ ✗ |
2 |
ASSERT_THROW(bitBufferAdapter.endArray(), CppRuntimeException); |
1016 |
✓✗✓✗ ✓✗✗✓ ✗✓✗✗ ✗✗✗✗ ✗✗✓✗ ✓✗✗✗ ✗✗✗✗ ✗✗✗✗ ✗✗✗✗ ✗✗✓✗ ✗ |
2 |
ASSERT_THROW(bitBufferAdapter.visitKey("nonexisting"_sv), CppRuntimeException); |
1017 |
✓✗✓✗ ✓✗✗✓ ✗✓✗✗ ✗✗✗✗ ✗✗✓✗ ✓✗✗✗ ✗✗✗✗ ✗✗✗✗ ✗✗✗✗ ✗✗✓✗ ✗ |
2 |
ASSERT_THROW(bitBufferAdapter.visitValue(static_cast<uint64_t>(10)), CppRuntimeException); |
1018 |
✓✗ | 1 |
bitBufferAdapter.visitKey("buffer"_sv); |
1019 |
✓✗✓✗ ✓✗✗✓ ✗✓✗✗ ✗✗✗✗ ✗✗✓✗ ✓✗✗✗ ✗✗✗✗ ✗✗✗✗ ✗✗✗✗ ✗✗✓✗ ✗ |
2 |
ASSERT_THROW(bitBufferAdapter.get(), CppRuntimeException); |
1020 |
✓✗✓✗ ✓✗✗✓ ✗✓✗✗ ✗✗✗✗ ✗✗✓✗ ✓✗✗✗ ✗✗✗✗ ✗✗✗✗ ✗✗✗✗ ✗✗✓✗ ✗ |
2 |
ASSERT_THROW(bitBufferAdapter.visitKey("nonexisting"_sv), CppRuntimeException); |
1021 |
✓✗✓✗ ✓✗✗✓ ✗✓✗✗ ✗✗✗✗ ✗✗✓✗ ✓✗✗✗ ✗✗✗✗ ✗✗✗✗ ✗✗✗✗ ✗✗✓✗ ✗ |
2 |
ASSERT_THROW(bitBufferAdapter.visitValue(nullptr), CppRuntimeException); |
1022 |
✓✗✓✗ ✓✗✗✓ ✗✓✗✗ ✗✗✗✗ ✗✗✓✗ ✓✗✗✗ ✗✗✗✗ ✗✗✗✗ ✗✗✗✗ ✗✗✓✗ ✗ |
2 |
ASSERT_THROW(bitBufferAdapter.visitValue(true), CppRuntimeException); |
1023 |
✓✗✓✗ ✓✗✗✓ ✗✓✗✗ ✗✗✗✗ ✗✗✓✗ ✓✗✗✗ ✗✗✗✗ ✗✗✗✗ ✗✗✗✗ ✗✗✓✗ ✗ |
2 |
ASSERT_THROW(bitBufferAdapter.visitValue(static_cast<int64_t>(-1)), CppRuntimeException); |
1024 |
✓✗✓✗ ✓✗✗✓ ✗✓✗✗ ✗✗✗✗ ✗✗✓✗ ✓✗✗✗ ✗✗✗✗ ✗✗✗✗ ✗✗✗✗ ✗✗✓✗ ✗ |
2 |
ASSERT_THROW(bitBufferAdapter.visitValue(static_cast<uint64_t>(1)), CppRuntimeException); |
1025 |
✓✗✓✗ ✓✗✗✓ ✗✓✗✗ ✗✗✗✗ ✗✗✓✗ ✓✗✗✗ ✗✗✗✗ ✗✗✗✗ ✗✗✗✗ ✗✗✓✗ ✗ |
2 |
ASSERT_THROW(bitBufferAdapter.visitValue(0.0), CppRuntimeException); |
1026 |
✓✗✓✗ ✓✗✗✓ ✗✓✗✗ ✗✗✗✗ ✗✗✓✗ ✓✗✓✗ ✗✗✗✗ ✗✗✗✗ ✗✗✗✗ ✗✗✗✗ |
2 |
ASSERT_THROW(bitBufferAdapter.visitValue("BadValue"_sv), CppRuntimeException); |
1027 |
} |
||
1028 |
|||
1029 |
✓✗✓✗ ✓✗✗✓ |
802 |
TEST(JsonReaderTest, creatorAdapter) |
1030 |
{ |
||
1031 |
✓✗✓✗ ✗ |
2 |
detail::CreatorAdapter<std::allocator<uint8_t>> creatorAdapter{std::allocator<uint8_t>()}; |
1032 |
|||
1033 |
✓✗✓✗ ✓✗✗✓ ✗✓✗✗ ✗✗✗✗ ✗✗✓✗ ✓✗✗✗ ✗✗✗✗ ✗✗✗✗ ✗✗✗✗ ✗✗✓✗ ✗ |
2 |
ASSERT_THROW(creatorAdapter.get(), CppRuntimeException); |
1034 |
✓✗✓✗ ✓✗✗✓ ✗✓✗✗ ✗✗✗✗ ✗✗✓✗ ✓✗✗✗ ✗✗✗✗ ✗✗✗✗ ✗✗✗✗ ✗✗✓✗ ✗ |
2 |
ASSERT_THROW(creatorAdapter.beginObject(), CppRuntimeException); |
1035 |
✓✗✓✗ ✓✗✗✓ ✗✓✗✗ ✗✗✗✗ ✗✗✓✗ ✓✗✗✗ ✗✗✗✗ ✗✗✗✗ ✗✗✗✗ ✗✗✓✗ ✗ |
2 |
ASSERT_THROW(creatorAdapter.endObject(), CppRuntimeException); |
1036 |
✓✗✓✗ ✓✗✗✓ ✗✓✗✗ ✗✗✗✗ ✗✗✓✗ ✓✗✗✗ ✗✗✗✗ ✗✗✗✗ ✗✗✗✗ ✗✗✓✗ ✗ |
2 |
ASSERT_THROW(creatorAdapter.beginArray(), CppRuntimeException); |
1037 |
✓✗✓✗ ✓✗✗✓ ✗✓✗✗ ✗✗✗✗ ✗✗✓✗ ✓✗✗✗ ✗✗✗✗ ✗✗✗✗ ✗✗✗✗ ✗✗✓✗ ✗ |
2 |
ASSERT_THROW(creatorAdapter.endArray(), CppRuntimeException); |
1038 |
✓✗✓✗ ✓✗✗✓ ✗✓✗✗ ✗✗✗✗ ✗✗✓✗ ✓✗✗✗ ✗✗✗✗ ✗✗✗✗ ✗✗✗✗ ✗✗✓✗ ✗ |
2 |
ASSERT_THROW(creatorAdapter.visitKey("nonexistent"_sv), CppRuntimeException); |
1039 |
✓✗✓✗ ✓✗✗✓ ✗✓✗✗ ✗✗✗✗ ✗✗✓✗ ✓✗✗✗ ✗✗✗✗ ✗✗✗✗ ✗✗✗✗ ✗✗✓✗ ✗ |
2 |
ASSERT_THROW(creatorAdapter.visitValue(nullptr), CppRuntimeException); |
1040 |
✓✗✓✗ ✓✗✗✓ ✗✓✗✗ ✗✗✗✗ ✗✗✓✗ ✓✗✗✗ ✗✗✗✗ ✗✗✗✗ ✗✗✗✗ ✗✗✓✗ ✗ |
2 |
ASSERT_THROW(creatorAdapter.visitValue(true), CppRuntimeException); |
1041 |
✓✗✓✗ ✓✗✗✓ ✗✓✗✗ ✗✗✗✗ ✗✗✓✗ ✓✗✗✗ ✗✗✗✗ ✗✗✗✗ ✗✗✗✗ ✗✗✓✗ ✗ |
2 |
ASSERT_THROW(creatorAdapter.visitValue(static_cast<int64_t>(-1)), CppRuntimeException); |
1042 |
✓✗✓✗ ✓✗✗✓ ✗✓✗✗ ✗✗✗✗ ✗✗✓✗ ✓✗✗✗ ✗✗✗✗ ✗✗✗✗ ✗✗✗✗ ✗✗✓✗ ✗ |
2 |
ASSERT_THROW(creatorAdapter.visitValue(static_cast<uint64_t>(1)), CppRuntimeException); |
1043 |
✓✗✓✗ ✓✗✗✓ ✗✓✗✗ ✗✗✗✗ ✗✗✓✗ ✓✗✗✗ ✗✗✗✗ ✗✗✗✗ ✗✗✗✗ ✗✗✓✗ ✗ |
2 |
ASSERT_THROW(creatorAdapter.visitValue(0.0), CppRuntimeException); |
1044 |
✓✗✓✗ ✓✗✗✓ ✗✓✗✗ ✗✗✗✗ ✗✗✓✗ ✓✗✓✗ ✗✗✗✗ ✗✗✗✗ ✗✗✗✗ ✗✗✗✗ |
2 |
ASSERT_THROW(creatorAdapter.visitValue("BadValue"_sv), CppRuntimeException); |
1045 |
} |
||
1046 |
|||
1047 |
✓✗✓✗ |
2394 |
} // namespace zserio |
Generated by: GCOVR (Version 4.2) |