rippled
Loading...
Searching...
No Matches
Value.cpp
1#include <xrpl/beast/core/LexicalCast.h>
2#include <xrpl/json/json_errors.h>
3#include <xrpl/json/json_reader.h>
4#include <xrpl/json/json_value.h>
5#include <xrpl/json/json_writer.h>
6
7#include <doctest/doctest.h>
8
9#include <algorithm>
10#include <regex>
11#include <sstream>
12#include <string>
13
14namespace ripple {
15
16TEST_SUITE_BEGIN("json_value");
17
18TEST_CASE("construct and compare Json::StaticString")
19{
20 static constexpr char sample[]{"Contents of a Json::StaticString"};
21
22 static constexpr Json::StaticString test1(sample);
23 char const* addrTest1{test1};
24
25 CHECK(addrTest1 == &sample[0]);
26 CHECK(test1.c_str() == &sample[0]);
27
28 static constexpr Json::StaticString test2{
29 "Contents of a Json::StaticString"};
30 static constexpr Json::StaticString test3{"Another StaticString"};
31
32 CHECK(test1 == test2);
33 CHECK(test1 != test3);
34
35 std::string str{sample};
36 CHECK(str == test2);
37 CHECK(str != test3);
38 CHECK(test2 == str);
39 CHECK(test3 != str);
40}
41
42TEST_CASE("different types")
43{
44 // Exercise ValueType constructor
45 static constexpr Json::StaticString staticStr{"staticStr"};
46
47 auto testCopy = [](Json::ValueType typ) {
48 Json::Value val{typ};
49 Json::Value cpy{val};
50 CHECK(val.type() == typ);
51 CHECK(cpy.type() == typ);
52 return val;
53 };
54 {
55 Json::Value const nullV{testCopy(Json::nullValue)};
56 CHECK(nullV.isNull());
57 CHECK(!nullV.isBool());
58 CHECK(!nullV.isInt());
59 CHECK(!nullV.isUInt());
60 CHECK(!nullV.isIntegral());
61 CHECK(!nullV.isDouble());
62 CHECK(!nullV.isNumeric());
63 CHECK(!nullV.isString());
64 CHECK(!nullV.isArray());
65 CHECK(nullV.isArrayOrNull());
66 CHECK(!nullV.isObject());
67 CHECK(nullV.isObjectOrNull());
68 }
69 {
70 Json::Value const intV{testCopy(Json::intValue)};
71 CHECK(!intV.isNull());
72 CHECK(!intV.isBool());
73 CHECK(intV.isInt());
74 CHECK(!intV.isUInt());
75 CHECK(intV.isIntegral());
76 CHECK(!intV.isDouble());
77 CHECK(intV.isNumeric());
78 CHECK(!intV.isString());
79 CHECK(!intV.isArray());
80 CHECK(!intV.isArrayOrNull());
81 CHECK(!intV.isObject());
82 CHECK(!intV.isObjectOrNull());
83 }
84 {
85 Json::Value const uintV{testCopy(Json::uintValue)};
86 CHECK(!uintV.isNull());
87 CHECK(!uintV.isBool());
88 CHECK(!uintV.isInt());
89 CHECK(uintV.isUInt());
90 CHECK(uintV.isIntegral());
91 CHECK(!uintV.isDouble());
92 CHECK(uintV.isNumeric());
93 CHECK(!uintV.isString());
94 CHECK(!uintV.isArray());
95 CHECK(!uintV.isArrayOrNull());
96 CHECK(!uintV.isObject());
97 CHECK(!uintV.isObjectOrNull());
98 }
99 {
100 Json::Value const realV{testCopy(Json::realValue)};
101 CHECK(!realV.isNull());
102 CHECK(!realV.isBool());
103 CHECK(!realV.isInt());
104 CHECK(!realV.isUInt());
105 CHECK(!realV.isIntegral());
106 CHECK(realV.isDouble());
107 CHECK(realV.isNumeric());
108 CHECK(!realV.isString());
109 CHECK(!realV.isArray());
110 CHECK(!realV.isArrayOrNull());
111 CHECK(!realV.isObject());
112 CHECK(!realV.isObjectOrNull());
113 }
114 {
115 Json::Value const stringV{testCopy(Json::stringValue)};
116 CHECK(!stringV.isNull());
117 CHECK(!stringV.isBool());
118 CHECK(!stringV.isInt());
119 CHECK(!stringV.isUInt());
120 CHECK(!stringV.isIntegral());
121 CHECK(!stringV.isDouble());
122 CHECK(!stringV.isNumeric());
123 CHECK(stringV.isString());
124 CHECK(!stringV.isArray());
125 CHECK(!stringV.isArrayOrNull());
126 CHECK(!stringV.isObject());
127 CHECK(!stringV.isObjectOrNull());
128 }
129 {
130 Json::Value const staticStrV{staticStr};
131 {
132 Json::Value cpy{staticStrV};
133 CHECK(staticStrV.type() == Json::stringValue);
134 CHECK(cpy.type() == Json::stringValue);
135 }
136 CHECK(!staticStrV.isNull());
137 CHECK(!staticStrV.isBool());
138 CHECK(!staticStrV.isInt());
139 CHECK(!staticStrV.isUInt());
140 CHECK(!staticStrV.isIntegral());
141 CHECK(!staticStrV.isDouble());
142 CHECK(!staticStrV.isNumeric());
143 CHECK(staticStrV.isString());
144 CHECK(!staticStrV.isArray());
145 CHECK(!staticStrV.isArrayOrNull());
146 CHECK(!staticStrV.isObject());
147 CHECK(!staticStrV.isObjectOrNull());
148 }
149 {
150 Json::Value const boolV{testCopy(Json::booleanValue)};
151 CHECK(!boolV.isNull());
152 CHECK(boolV.isBool());
153 CHECK(!boolV.isInt());
154 CHECK(!boolV.isUInt());
155 CHECK(boolV.isIntegral());
156 CHECK(!boolV.isDouble());
157 CHECK(boolV.isNumeric());
158 CHECK(!boolV.isString());
159 CHECK(!boolV.isArray());
160 CHECK(!boolV.isArrayOrNull());
161 CHECK(!boolV.isObject());
162 CHECK(!boolV.isObjectOrNull());
163 }
164 {
165 Json::Value const arrayV{testCopy(Json::arrayValue)};
166 CHECK(!arrayV.isNull());
167 CHECK(!arrayV.isBool());
168 CHECK(!arrayV.isInt());
169 CHECK(!arrayV.isUInt());
170 CHECK(!arrayV.isIntegral());
171 CHECK(!arrayV.isDouble());
172 CHECK(!arrayV.isNumeric());
173 CHECK(!arrayV.isString());
174 CHECK(arrayV.isArray());
175 CHECK(arrayV.isArrayOrNull());
176 CHECK(!arrayV.isObject());
177 CHECK(!arrayV.isObjectOrNull());
178 }
179 {
180 Json::Value const objectV{testCopy(Json::objectValue)};
181 CHECK(!objectV.isNull());
182 CHECK(!objectV.isBool());
183 CHECK(!objectV.isInt());
184 CHECK(!objectV.isUInt());
185 CHECK(!objectV.isIntegral());
186 CHECK(!objectV.isDouble());
187 CHECK(!objectV.isNumeric());
188 CHECK(!objectV.isString());
189 CHECK(!objectV.isArray());
190 CHECK(!objectV.isArrayOrNull());
191 CHECK(objectV.isObject());
192 CHECK(objectV.isObjectOrNull());
193 }
194}
195
196TEST_CASE("compare strings")
197{
198 auto doCompare = [&](Json::Value const& lhs,
199 Json::Value const& rhs,
200 bool lhsEqRhs,
201 bool lhsLtRhs,
202 int line) {
203 CAPTURE(line);
204 CHECK((lhs == rhs) == lhsEqRhs);
205 CHECK((lhs != rhs) != lhsEqRhs);
206 CHECK((lhs < rhs) == (!(lhsEqRhs || !lhsLtRhs)));
207 CHECK((lhs <= rhs) == (lhsEqRhs || lhsLtRhs));
208 CHECK((lhs >= rhs) == (lhsEqRhs || !lhsLtRhs));
209 CHECK((lhs > rhs) == (!(lhsEqRhs || lhsLtRhs)));
210 };
211
212 Json::Value const null0;
213 Json::Value const intNeg1{-1};
214 Json::Value const int0{Json::intValue};
215 Json::Value const intPos1{1};
216 Json::Value const uint0{Json::uintValue};
217 Json::Value const uint1{1u};
218 Json::Value const realNeg1{-1.0};
219 Json::Value const real0{Json::realValue};
220 Json::Value const realPos1{1.0};
221 Json::Value const str0{Json::stringValue};
222 Json::Value const str1{"1"};
223 Json::Value const boolF{false};
224 Json::Value const boolT{true};
225 Json::Value const array0{Json::arrayValue};
226 Json::Value const array1{[]() {
227 Json::Value array1;
228 array1[0u] = 1;
229 return array1;
230 }()};
231 Json::Value const obj0{Json::objectValue};
232 Json::Value const obj1{[]() {
233 Json::Value obj1;
234 obj1["one"] = 1;
235 return obj1;
236 }()};
237
238#pragma push_macro("DO_COMPARE")
239 // DO_COMPARE(lhs, rhs, lhsEqualsToRhs lhsLessThanRhs)
240#define DO_COMPARE(lhs, rhs, eq, lt) doCompare(lhs, rhs, eq, lt, __LINE__)
241 DO_COMPARE(null0, Json::Value{}, true, false);
242 DO_COMPARE(null0, intNeg1, false, true);
243 DO_COMPARE(null0, int0, false, true);
244 DO_COMPARE(null0, intPos1, false, true);
245 DO_COMPARE(null0, uint0, false, true);
246 DO_COMPARE(null0, uint1, false, true);
247 DO_COMPARE(null0, realNeg1, false, true);
248 DO_COMPARE(null0, real0, false, true);
249 DO_COMPARE(null0, realPos1, false, true);
250 DO_COMPARE(null0, str0, false, true);
251 DO_COMPARE(null0, str1, false, true);
252 DO_COMPARE(null0, boolF, false, true);
253 DO_COMPARE(null0, boolT, false, true);
254 DO_COMPARE(null0, array0, false, true);
255 DO_COMPARE(null0, array1, false, true);
256 DO_COMPARE(null0, obj0, false, true);
257 DO_COMPARE(null0, obj1, false, true);
258
259 DO_COMPARE(intNeg1, null0, false, false);
260 DO_COMPARE(intNeg1, intNeg1, true, false);
261 DO_COMPARE(intNeg1, int0, false, true);
262 DO_COMPARE(intNeg1, intPos1, false, true);
263 DO_COMPARE(intNeg1, uint0, false, true);
264 DO_COMPARE(intNeg1, uint1, false, true);
265 DO_COMPARE(intNeg1, realNeg1, false, true);
266 DO_COMPARE(intNeg1, real0, false, true);
267 DO_COMPARE(intNeg1, realPos1, false, true);
268 DO_COMPARE(intNeg1, str0, false, true);
269 DO_COMPARE(intNeg1, str1, false, true);
270 DO_COMPARE(intNeg1, boolF, false, true);
271 DO_COMPARE(intNeg1, boolT, false, true);
272 DO_COMPARE(intNeg1, array0, false, true);
273 DO_COMPARE(intNeg1, array1, false, true);
274 DO_COMPARE(intNeg1, obj0, false, true);
275 DO_COMPARE(intNeg1, obj1, false, true);
276
277 DO_COMPARE(int0, null0, false, false);
278 DO_COMPARE(int0, intNeg1, false, false);
279 DO_COMPARE(int0, int0, true, false);
280 DO_COMPARE(int0, intPos1, false, true);
281 DO_COMPARE(int0, uint0, true, false);
282 DO_COMPARE(int0, uint1, false, true);
283 DO_COMPARE(int0, realNeg1, false, true);
284 DO_COMPARE(int0, real0, false, true);
285 DO_COMPARE(int0, realPos1, false, true);
286 DO_COMPARE(int0, str0, false, true);
287 DO_COMPARE(int0, str1, false, true);
288 DO_COMPARE(int0, boolF, false, true);
289 DO_COMPARE(int0, boolT, false, true);
290 DO_COMPARE(int0, array0, false, true);
291 DO_COMPARE(int0, array1, false, true);
292 DO_COMPARE(int0, obj0, false, true);
293 DO_COMPARE(int0, obj1, false, true);
294
295 DO_COMPARE(intPos1, null0, false, false);
296 DO_COMPARE(intPos1, intNeg1, false, false);
297 DO_COMPARE(intPos1, int0, false, false);
298 DO_COMPARE(intPos1, intPos1, true, false);
299 DO_COMPARE(intPos1, uint0, false, false);
300 DO_COMPARE(intPos1, uint1, true, false);
301 DO_COMPARE(intPos1, realNeg1, false, true);
302 DO_COMPARE(intPos1, real0, false, true);
303 DO_COMPARE(intPos1, realPos1, false, true);
304 DO_COMPARE(intPos1, str0, false, true);
305 DO_COMPARE(intPos1, str1, false, true);
306 DO_COMPARE(intPos1, boolF, false, true);
307 DO_COMPARE(intPos1, boolT, false, true);
308 DO_COMPARE(intPos1, array0, false, true);
309 DO_COMPARE(intPos1, array1, false, true);
310 DO_COMPARE(intPos1, obj0, false, true);
311 DO_COMPARE(intPos1, obj1, false, true);
312
313 DO_COMPARE(uint0, null0, false, false);
314 DO_COMPARE(uint0, intNeg1, false, false);
315 DO_COMPARE(uint0, int0, true, false);
316 DO_COMPARE(uint0, intPos1, false, true);
317 DO_COMPARE(uint0, uint0, true, false);
318 DO_COMPARE(uint0, uint1, false, true);
319 DO_COMPARE(uint0, realNeg1, false, true);
320 DO_COMPARE(uint0, real0, false, true);
321 DO_COMPARE(uint0, realPos1, false, true);
322 DO_COMPARE(uint0, str0, false, true);
323 DO_COMPARE(uint0, str1, false, true);
324 DO_COMPARE(uint0, boolF, false, true);
325 DO_COMPARE(uint0, boolT, false, true);
326 DO_COMPARE(uint0, array0, false, true);
327 DO_COMPARE(uint0, array1, false, true);
328 DO_COMPARE(uint0, obj0, false, true);
329 DO_COMPARE(uint0, obj1, false, true);
330
331 DO_COMPARE(uint1, null0, false, false);
332 DO_COMPARE(uint1, intNeg1, false, false);
333 DO_COMPARE(uint1, int0, false, false);
334 DO_COMPARE(uint1, intPos1, true, false);
335 DO_COMPARE(uint1, uint0, false, false);
336 DO_COMPARE(uint1, uint1, true, false);
337 DO_COMPARE(uint1, realNeg1, false, true);
338 DO_COMPARE(uint1, real0, false, true);
339 DO_COMPARE(uint1, realPos1, false, true);
340 DO_COMPARE(uint1, str0, false, true);
341 DO_COMPARE(uint1, str1, false, true);
342 DO_COMPARE(uint1, boolF, false, true);
343 DO_COMPARE(uint1, boolT, false, true);
344 DO_COMPARE(uint1, array0, false, true);
345 DO_COMPARE(uint1, array1, false, true);
346 DO_COMPARE(uint1, obj0, false, true);
347 DO_COMPARE(uint1, obj1, false, true);
348
349 DO_COMPARE(realNeg1, null0, false, false);
350 DO_COMPARE(realNeg1, intNeg1, false, false);
351 DO_COMPARE(realNeg1, int0, false, false);
352 DO_COMPARE(realNeg1, intPos1, false, false);
353 DO_COMPARE(realNeg1, uint0, false, false);
354 DO_COMPARE(realNeg1, uint1, false, false);
355 DO_COMPARE(realNeg1, realNeg1, true, false);
356 DO_COMPARE(realNeg1, real0, false, true);
357 DO_COMPARE(realNeg1, realPos1, false, true);
358 DO_COMPARE(realNeg1, str0, false, true);
359 DO_COMPARE(realNeg1, str1, false, true);
360 DO_COMPARE(realNeg1, boolF, false, true);
361 DO_COMPARE(realNeg1, boolT, false, true);
362 DO_COMPARE(realNeg1, array0, false, true);
363 DO_COMPARE(realNeg1, array1, false, true);
364 DO_COMPARE(realNeg1, obj0, false, true);
365 DO_COMPARE(realNeg1, obj1, false, true);
366
367 DO_COMPARE(real0, null0, false, false);
368 DO_COMPARE(real0, intNeg1, false, false);
369 DO_COMPARE(real0, int0, false, false);
370 DO_COMPARE(real0, intPos1, false, false);
371 DO_COMPARE(real0, uint0, false, false);
372 DO_COMPARE(real0, uint1, false, false);
373 DO_COMPARE(real0, realNeg1, false, false);
374 DO_COMPARE(real0, real0, true, false);
375 DO_COMPARE(real0, realPos1, false, true);
376 DO_COMPARE(real0, str0, false, true);
377 DO_COMPARE(real0, str1, false, true);
378 DO_COMPARE(real0, boolF, false, true);
379 DO_COMPARE(real0, boolT, false, true);
380 DO_COMPARE(real0, array0, false, true);
381 DO_COMPARE(real0, array1, false, true);
382 DO_COMPARE(real0, obj0, false, true);
383 DO_COMPARE(real0, obj1, false, true);
384
385 DO_COMPARE(realPos1, null0, false, false);
386 DO_COMPARE(realPos1, intNeg1, false, false);
387 DO_COMPARE(realPos1, int0, false, false);
388 DO_COMPARE(realPos1, intPos1, false, false);
389 DO_COMPARE(realPos1, uint0, false, false);
390 DO_COMPARE(realPos1, uint1, false, false);
391 DO_COMPARE(realPos1, realNeg1, false, false);
392 DO_COMPARE(realPos1, real0, false, false);
393 DO_COMPARE(realPos1, realPos1, true, false);
394 DO_COMPARE(realPos1, str0, false, true);
395 DO_COMPARE(realPos1, str1, false, true);
396 DO_COMPARE(realPos1, boolF, false, true);
397 DO_COMPARE(realPos1, boolT, false, true);
398 DO_COMPARE(realPos1, array0, false, true);
399 DO_COMPARE(realPos1, array1, false, true);
400 DO_COMPARE(realPos1, obj0, false, true);
401 DO_COMPARE(realPos1, obj1, false, true);
402
403 DO_COMPARE(str0, null0, false, false);
404 DO_COMPARE(str0, intNeg1, false, false);
405 DO_COMPARE(str0, int0, false, false);
406 DO_COMPARE(str0, intPos1, false, false);
407 DO_COMPARE(str0, uint0, false, false);
408 DO_COMPARE(str0, uint1, false, false);
409 DO_COMPARE(str0, realNeg1, false, false);
410 DO_COMPARE(str0, real0, false, false);
411 DO_COMPARE(str0, realPos1, false, false);
412 DO_COMPARE(str0, str0, true, false);
413 DO_COMPARE(str0, str1, false, true);
414 DO_COMPARE(str0, boolF, false, true);
415 DO_COMPARE(str0, boolT, false, true);
416 DO_COMPARE(str0, array0, false, true);
417 DO_COMPARE(str0, array1, false, true);
418 DO_COMPARE(str0, obj0, false, true);
419 DO_COMPARE(str0, obj1, false, true);
420
421 DO_COMPARE(str1, null0, false, false);
422 DO_COMPARE(str1, intNeg1, false, false);
423 DO_COMPARE(str1, int0, false, false);
424 DO_COMPARE(str1, intPos1, false, false);
425 DO_COMPARE(str1, uint0, false, false);
426 DO_COMPARE(str1, uint1, false, false);
427 DO_COMPARE(str1, realNeg1, false, false);
428 DO_COMPARE(str1, real0, false, false);
429 DO_COMPARE(str1, realPos1, false, false);
430 DO_COMPARE(str1, str0, false, false);
431 DO_COMPARE(str1, str1, true, false);
432 DO_COMPARE(str1, boolF, false, true);
433 DO_COMPARE(str1, boolT, false, true);
434 DO_COMPARE(str1, array0, false, true);
435 DO_COMPARE(str1, array1, false, true);
436 DO_COMPARE(str1, obj0, false, true);
437 DO_COMPARE(str1, obj1, false, true);
438
439 DO_COMPARE(boolF, null0, false, false);
440 DO_COMPARE(boolF, intNeg1, false, false);
441 DO_COMPARE(boolF, int0, false, false);
442 DO_COMPARE(boolF, intPos1, false, false);
443 DO_COMPARE(boolF, uint0, false, false);
444 DO_COMPARE(boolF, uint1, false, false);
445 DO_COMPARE(boolF, realNeg1, false, false);
446 DO_COMPARE(boolF, real0, false, false);
447 DO_COMPARE(boolF, realPos1, false, false);
448 DO_COMPARE(boolF, str0, false, false);
449 DO_COMPARE(boolF, str1, false, false);
450 DO_COMPARE(boolF, boolF, true, false);
451 DO_COMPARE(boolF, boolT, false, true);
452 DO_COMPARE(boolF, array0, false, true);
453 DO_COMPARE(boolF, array1, false, true);
454 DO_COMPARE(boolF, obj0, false, true);
455 DO_COMPARE(boolF, obj1, false, true);
456
457 DO_COMPARE(boolT, null0, false, false);
458 DO_COMPARE(boolT, intNeg1, false, false);
459 DO_COMPARE(boolT, int0, false, false);
460 DO_COMPARE(boolT, intPos1, false, false);
461 DO_COMPARE(boolT, uint0, false, false);
462 DO_COMPARE(boolT, uint1, false, false);
463 DO_COMPARE(boolT, realNeg1, false, false);
464 DO_COMPARE(boolT, real0, false, false);
465 DO_COMPARE(boolT, realPos1, false, false);
466 DO_COMPARE(boolT, str0, false, false);
467 DO_COMPARE(boolT, str1, false, false);
468 DO_COMPARE(boolT, boolF, false, false);
469 DO_COMPARE(boolT, boolT, true, false);
470 DO_COMPARE(boolT, array0, false, true);
471 DO_COMPARE(boolT, array1, false, true);
472 DO_COMPARE(boolT, obj0, false, true);
473 DO_COMPARE(boolT, obj1, false, true);
474
475 DO_COMPARE(array0, null0, false, false);
476 DO_COMPARE(array0, intNeg1, false, false);
477 DO_COMPARE(array0, int0, false, false);
478 DO_COMPARE(array0, intPos1, false, false);
479 DO_COMPARE(array0, uint0, false, false);
480 DO_COMPARE(array0, uint1, false, false);
481 DO_COMPARE(array0, realNeg1, false, false);
482 DO_COMPARE(array0, real0, false, false);
483 DO_COMPARE(array0, realPos1, false, false);
484 DO_COMPARE(array0, str0, false, false);
485 DO_COMPARE(array0, str1, false, false);
486 DO_COMPARE(array0, boolF, false, false);
487 DO_COMPARE(array0, boolT, false, false);
488 DO_COMPARE(array0, array0, true, false);
489 DO_COMPARE(array0, array1, false, true);
490 DO_COMPARE(array0, obj0, false, true);
491 DO_COMPARE(array0, obj1, false, true);
492
493 DO_COMPARE(array1, null0, false, false);
494 DO_COMPARE(array1, intNeg1, false, false);
495 DO_COMPARE(array1, int0, false, false);
496 DO_COMPARE(array1, intPos1, false, false);
497 DO_COMPARE(array1, uint0, false, false);
498 DO_COMPARE(array1, uint1, false, false);
499 DO_COMPARE(array1, realNeg1, false, false);
500 DO_COMPARE(array1, real0, false, false);
501 DO_COMPARE(array1, realPos1, false, false);
502 DO_COMPARE(array1, str0, false, false);
503 DO_COMPARE(array1, str1, false, false);
504 DO_COMPARE(array1, boolF, false, false);
505 DO_COMPARE(array1, boolT, false, false);
506 DO_COMPARE(array1, array0, false, false);
507 DO_COMPARE(array1, array1, true, false);
508 DO_COMPARE(array1, obj0, false, true);
509 DO_COMPARE(array1, obj1, false, true);
510
511 DO_COMPARE(obj0, null0, false, false);
512 DO_COMPARE(obj0, intNeg1, false, false);
513 DO_COMPARE(obj0, int0, false, false);
514 DO_COMPARE(obj0, intPos1, false, false);
515 DO_COMPARE(obj0, uint0, false, false);
516 DO_COMPARE(obj0, uint1, false, false);
517 DO_COMPARE(obj0, realNeg1, false, false);
518 DO_COMPARE(obj0, real0, false, false);
519 DO_COMPARE(obj0, realPos1, false, false);
520 DO_COMPARE(obj0, str0, false, false);
521 DO_COMPARE(obj0, str1, false, false);
522 DO_COMPARE(obj0, boolF, false, false);
523 DO_COMPARE(obj0, boolT, false, false);
524 DO_COMPARE(obj0, array0, false, false);
525 DO_COMPARE(obj0, array1, false, false);
526 DO_COMPARE(obj0, obj0, true, false);
527 DO_COMPARE(obj0, obj1, false, true);
528
529 DO_COMPARE(obj1, null0, false, false);
530 DO_COMPARE(obj1, intNeg1, false, false);
531 DO_COMPARE(obj1, int0, false, false);
532 DO_COMPARE(obj1, intPos1, false, false);
533 DO_COMPARE(obj1, uint0, false, false);
534 DO_COMPARE(obj1, uint1, false, false);
535 DO_COMPARE(obj1, realNeg1, false, false);
536 DO_COMPARE(obj1, real0, false, false);
537 DO_COMPARE(obj1, realPos1, false, false);
538 DO_COMPARE(obj1, str0, false, false);
539 DO_COMPARE(obj1, str1, false, false);
540 DO_COMPARE(obj1, boolF, false, false);
541 DO_COMPARE(obj1, boolT, false, false);
542 DO_COMPARE(obj1, array0, false, false);
543 DO_COMPARE(obj1, array1, false, false);
544 DO_COMPARE(obj1, obj0, false, false);
545 DO_COMPARE(obj1, obj1, true, false);
546#undef DO_COMPARE
547#pragma pop_macro("DO_COMPARE")
548}
549
551{
552 CHECK(!Json::Value());
553
554 CHECK(!Json::Value(""));
555
556 CHECK(bool(Json::Value("empty")));
557 CHECK(bool(Json::Value(false)));
558 CHECK(bool(Json::Value(true)));
559 CHECK(bool(Json::Value(0)));
560 CHECK(bool(Json::Value(1)));
561
563 CHECK(!array);
564 array.append(0);
565 CHECK(bool(array));
566
568 CHECK(!object);
569 object[""] = false;
570 CHECK(bool(object));
571}
572
573TEST_CASE("bad json")
574{
575 char const* s(R"({"method":"ledger","params":[{"ledger_index":1e300}]})");
576
577 Json::Value j;
578 Json::Reader r;
579
580 CHECK(r.parse(s, j));
581}
582
583TEST_CASE("edge cases")
584{
585 std::string json;
586
590
591 std::uint32_t a_uint = max_uint - 1978;
592 std::int32_t a_large_int = max_int - 1978;
593 std::int32_t a_small_int = min_int + 1978;
594
595 json = "{\"max_uint\":" + std::to_string(max_uint);
596 json += ",\"max_int\":" + std::to_string(max_int);
597 json += ",\"min_int\":" + std::to_string(min_int);
598 json += ",\"a_uint\":" + std::to_string(a_uint);
599 json += ",\"a_large_int\":" + std::to_string(a_large_int);
600 json += ",\"a_small_int\":" + std::to_string(a_small_int);
601 json += "}";
602
603 Json::Value j1;
604 Json::Reader r1;
605
606 CHECK(r1.parse(json, j1));
607 CHECK(j1["max_uint"].asUInt() == max_uint);
608 CHECK(j1["max_int"].asInt() == max_int);
609 CHECK(j1["min_int"].asInt() == min_int);
610 CHECK(j1["a_uint"].asUInt() == a_uint);
611 CHECK(j1["a_uint"] > a_large_int);
612 CHECK(j1["a_uint"] > a_small_int);
613 CHECK(j1["a_large_int"].asInt() == a_large_int);
614 CHECK(j1["a_large_int"].asUInt() == a_large_int);
615 CHECK(j1["a_large_int"] < a_uint);
616 CHECK(j1["a_small_int"].asInt() == a_small_int);
617 CHECK(j1["a_small_int"] < a_uint);
618
619 json = "{\"overflow\":";
620 json += std::to_string(std::uint64_t(max_uint) + 1);
621 json += "}";
622
623 Json::Value j2;
624 Json::Reader r2;
625
626 CHECK(!r2.parse(json, j2));
627
628 json = "{\"underflow\":";
629 json += std::to_string(std::int64_t(min_int) - 1);
630 json += "}";
631
632 Json::Value j3;
633 Json::Reader r3;
634
635 CHECK(!r3.parse(json, j3));
636
637 Json::Value intString{"4294967296"};
638 CHECK_THROWS_AS(intString.asUInt(), beast::BadLexicalCast);
639
640 intString = "4294967295";
641 CHECK(intString.asUInt() == 4294967295u);
642
643 intString = "0";
644 CHECK(intString.asUInt() == 0);
645
646 intString = "-1";
647 CHECK_THROWS_AS(intString.asUInt(), beast::BadLexicalCast);
648
649 intString = "2147483648";
650 CHECK_THROWS_AS(intString.asInt(), beast::BadLexicalCast);
651
652 intString = "2147483647";
653 CHECK(intString.asInt() == 2147483647);
654
655 intString = "-2147483648";
656 CHECK(intString.asInt() == -2147483648LL); // MSVC wants the LL
657
658 intString = "-2147483649";
659 CHECK_THROWS_AS(intString.asInt(), beast::BadLexicalCast);
660}
661
663{
664 Json::Value v1{2.5};
665 CHECK(v1.isDouble());
666 CHECK(v1.asDouble() == 2.5);
667
668 Json::Value v2 = v1;
669 CHECK(v1.isDouble());
670 CHECK(v1.asDouble() == 2.5);
671 CHECK(v2.isDouble());
672 CHECK(v2.asDouble() == 2.5);
673 CHECK(v1 == v2);
674
675 v1 = v2;
676 CHECK(v1.isDouble());
677 CHECK(v1.asDouble() == 2.5);
678 CHECK(v2.isDouble());
679 CHECK(v2.asDouble() == 2.5);
680 CHECK(v1 == v2);
681}
682
684{
685 Json::Value v1{2.5};
686 CHECK(v1.isDouble());
687 CHECK(v1.asDouble() == 2.5);
688
689 Json::Value v2 = std::move(v1);
690 CHECK(!v1);
691 CHECK(v2.isDouble());
692 CHECK(v2.asDouble() == 2.5);
693 CHECK(v1 != v2);
694
695 v1 = std::move(v2);
696 CHECK(v1.isDouble());
697 CHECK(v1.asDouble() == 2.5);
698 CHECK(!v2);
699 CHECK(v1 != v2);
700}
701
702TEST_CASE("comparisons")
703{
704 Json::Value a, b;
705 auto testEquals = [&](std::string const& name) {
706 CHECK(a == b);
707 CHECK(a <= b);
708 CHECK(a >= b);
709
710 CHECK(!(a != b));
711 CHECK(!(a < b));
712 CHECK(!(a > b));
713
714 CHECK(b == a);
715 CHECK(b <= a);
716 CHECK(b >= a);
717
718 CHECK(!(b != a));
719 CHECK(!(b < a));
720 CHECK(!(b > a));
721 };
722
723 auto testGreaterThan = [&](std::string const& name) {
724 CHECK(!(a == b));
725 CHECK(!(a <= b));
726 CHECK(a >= b);
727
728 CHECK(a != b);
729 CHECK(!(a < b));
730 CHECK(a > b);
731
732 CHECK(!(b == a));
733 CHECK(b <= a);
734 CHECK(!(b >= a));
735
736 CHECK(b != a);
737 CHECK(b < a);
738 CHECK(!(b > a));
739 };
740
741 a["a"] = Json::UInt(0);
742 b["a"] = Json::Int(0);
743 testEquals("zero");
744
745 b["a"] = Json::Int(-1);
746 testGreaterThan("negative");
747
749 Json::UInt bigger = big;
750 bigger++;
751
752 a["a"] = bigger;
753 b["a"] = big;
754 testGreaterThan("big");
755}
756
757TEST_CASE("compact")
758{
759 Json::Value j;
760 Json::Reader r;
761 char const* s("{\"array\":[{\"12\":23},{},null,false,0.5]}");
762
763 auto countLines = [](std::string const& str) {
764 return 1 + std::count_if(str.begin(), str.end(), [](char c) {
765 return c == '\n';
766 });
767 };
768
769 CHECK(r.parse(s, j));
770 {
772 ss << j;
773 CHECK(countLines(ss.str()) > 1);
774 }
775 {
777 ss << Json::Compact(std::move(j));
778 CHECK(countLines(ss.str()) == 1);
779 }
780}
781
782TEST_CASE("conversions")
783{
784 // We have Json::Int, but not Json::Double or Json::Real.
785 // We have Json::Int, Json::Value::Int, and Json::ValueType::intValue.
786 // We have Json::ValueType::realValue but Json::Value::asDouble.
787 // TODO: What's the thinking here?
788 {
789 // null
790 Json::Value val;
791 CHECK(val.isNull());
792 // val.asCString() should trigger an assertion failure
793 CHECK(val.asString() == "");
794 CHECK(val.asInt() == 0);
795 CHECK(val.asUInt() == 0);
796 CHECK(val.asDouble() == 0.0);
797 CHECK(val.asBool() == false);
798
807 }
808 {
809 // int
810 Json::Value val = -1234;
811 CHECK(val.isInt());
812 // val.asCString() should trigger an assertion failure
813 CHECK(val.asString() == "-1234");
814 CHECK(val.asInt() == -1234);
815 CHECK_THROWS_AS(val.asUInt(), Json::error);
816 CHECK(val.asDouble() == -1234.0);
817 CHECK(val.asBool() == true);
818
827 }
828 {
829 // uint
830 Json::Value val = 1234U;
831 CHECK(val.isUInt());
832 // val.asCString() should trigger an assertion failure
833 CHECK(val.asString() == "1234");
834 CHECK(val.asInt() == 1234);
835 CHECK(val.asUInt() == 1234u);
836 CHECK(val.asDouble() == 1234.0);
837 CHECK(val.asBool() == true);
838
847 }
848 {
849 // real
850 Json::Value val = 2.0;
851 CHECK(val.isDouble());
852 // val.asCString() should trigger an assertion failure
853 CHECK(std::regex_match(val.asString(), std::regex("^2\\.0*$")));
854 CHECK(val.asInt() == 2);
855 CHECK(val.asUInt() == 2u);
856 CHECK(val.asDouble() == 2.0);
857 CHECK(val.asBool() == true);
858
867 }
868 {
869 // numeric string
870 Json::Value val = "54321";
871 CHECK(val.isString());
872 CHECK(strcmp(val.asCString(), "54321") == 0);
873 CHECK(val.asString() == "54321");
874 CHECK(val.asInt() == 54321);
875 CHECK(val.asUInt() == 54321u);
876 CHECK_THROWS_AS(val.asDouble(), Json::error);
877 CHECK(val.asBool() == true);
878
887 }
888 {
889 // non-numeric string
891 CHECK(val.isString());
892 CHECK(val.asCString() == nullptr);
893 CHECK(val.asString() == "");
894 CHECK_THROWS_AS(val.asInt(), std::exception);
895 CHECK_THROWS_AS(val.asUInt(), std::exception);
896 CHECK_THROWS_AS(val.asDouble(), std::exception);
897 CHECK(val.asBool() == false);
898
907 }
908 {
909 // bool false
910 Json::Value val = false;
911 CHECK(val.isBool());
912 // val.asCString() should trigger an assertion failure
913 CHECK(val.asString() == "false");
914 CHECK(val.asInt() == 0);
915 CHECK(val.asUInt() == 0);
916 CHECK(val.asDouble() == 0.0);
917 CHECK(val.asBool() == false);
918
927 }
928 {
929 // bool true
930 Json::Value val = true;
931 CHECK(val.isBool());
932 // val.asCString() should trigger an assertion failure
933 CHECK(val.asString() == "true");
934 CHECK(val.asInt() == 1);
935 CHECK(val.asUInt() == 1);
936 CHECK(val.asDouble() == 1.0);
937 CHECK(val.asBool() == true);
938
947 }
948 {
949 // array type
951 CHECK(val.isArray());
952 // val.asCString should trigger an assertion failure
953 CHECK_THROWS_AS(val.asString(), Json::error);
954 CHECK_THROWS_AS(val.asInt(), Json::error);
955 CHECK_THROWS_AS(val.asUInt(), Json::error);
956 CHECK_THROWS_AS(val.asDouble(), Json::error);
957 CHECK(val.asBool() == false); // empty or not
958
967 }
968 {
969 // object type
971 CHECK(val.isObject());
972 // val.asCString should trigger an assertion failure
973 CHECK_THROWS_AS(val.asString(), Json::error);
974 CHECK_THROWS_AS(val.asInt(), Json::error);
975 CHECK_THROWS_AS(val.asUInt(), Json::error);
976 CHECK_THROWS_AS(val.asDouble(), Json::error);
977 CHECK(val.asBool() == false); // empty or not
978
987 }
988}
989
990TEST_CASE("access members")
991{
992 Json::Value val;
993 CHECK(val.type() == Json::nullValue);
994 CHECK(val.size() == 0);
995 CHECK(!val.isValidIndex(0));
996 CHECK(!val.isMember("key"));
997 {
998 Json::Value const constVal = val;
999 CHECK(constVal[7u].type() == Json::nullValue);
1000 CHECK(!constVal.isMember("key"));
1001 CHECK(constVal["key"].type() == Json::nullValue);
1002 CHECK(constVal.getMemberNames().empty());
1003 CHECK(constVal.get(1u, "default0") == "default0");
1004 CHECK(constVal.get(std::string("not"), "oh") == "oh");
1005 CHECK(constVal.get("missing", "default2") == "default2");
1006 }
1007
1008 val = -7;
1009 CHECK(val.type() == Json::intValue);
1010 CHECK(val.size() == 0);
1011 CHECK(!val.isValidIndex(0));
1012 CHECK(!val.isMember("key"));
1013
1014 val = 42u;
1015 CHECK(val.type() == Json::uintValue);
1016 CHECK(val.size() == 0);
1017 CHECK(!val.isValidIndex(0));
1018 CHECK(!val.isMember("key"));
1019
1020 val = 3.14159;
1021 CHECK(val.type() == Json::realValue);
1022 CHECK(val.size() == 0);
1023 CHECK(!val.isValidIndex(0));
1024 CHECK(!val.isMember("key"));
1025
1026 val = true;
1027 CHECK(val.type() == Json::booleanValue);
1028 CHECK(val.size() == 0);
1029 CHECK(!val.isValidIndex(0));
1030 CHECK(!val.isMember("key"));
1031
1032 val = "string";
1033 CHECK(val.type() == Json::stringValue);
1034 CHECK(val.size() == 0);
1035 CHECK(!val.isValidIndex(0));
1036 CHECK(!val.isMember("key"));
1037
1039 CHECK(val.type() == Json::objectValue);
1040 CHECK(val.size() == 0);
1041 static Json::StaticString const staticThree("three");
1042 val[staticThree] = 3;
1043 val["two"] = 2;
1044 CHECK(val.size() == 2);
1045 CHECK(val.isValidIndex(1));
1046 CHECK(!val.isValidIndex(2));
1047 CHECK(val[staticThree] == 3);
1048 CHECK(val.isMember("two"));
1049 CHECK(val.isMember(staticThree));
1050 CHECK(!val.isMember("key"));
1051 {
1052 Json::Value const constVal = val;
1053 CHECK(constVal["two"] == 2);
1054 CHECK(constVal["four"].type() == Json::nullValue);
1055 CHECK(constVal[staticThree] == 3);
1056 CHECK(constVal.isMember("two"));
1057 CHECK(constVal.isMember(staticThree));
1058 CHECK(!constVal.isMember("key"));
1059 CHECK(val.get(std::string("two"), "backup") == 2);
1060 CHECK(val.get("missing", "default2") == "default2");
1061 }
1062
1064 CHECK(val.type() == Json::arrayValue);
1065 CHECK(val.size() == 0);
1066 val[0u] = "zero";
1067 val[1u] = "one";
1068 CHECK(val.size() == 2);
1069 CHECK(val.isValidIndex(1));
1070 CHECK(!val.isValidIndex(2));
1071 CHECK(val[20u].type() == Json::nullValue);
1072 CHECK(!val.isMember("key"));
1073 {
1074 Json::Value const constVal = val;
1075 CHECK(constVal[0u] == "zero");
1076 CHECK(constVal[2u].type() == Json::nullValue);
1077 CHECK(!constVal.isMember("key"));
1078 CHECK(val.get(1u, "default0") == "one");
1079 CHECK(val.get(3u, "default1") == "default1");
1080 }
1081}
1082
1083TEST_CASE("remove members")
1084{
1085 Json::Value val;
1086 CHECK(val.removeMember(std::string("member")).type() == Json::nullValue);
1087
1089 static Json::StaticString const staticThree("three");
1090 val[staticThree] = 3;
1091 val["two"] = 2;
1092 CHECK(val.size() == 2);
1093
1095 CHECK(val.size() == 2);
1096
1097 CHECK(val.removeMember(staticThree) == 3);
1098 CHECK(val.size() == 1);
1099
1100 CHECK(val.removeMember(staticThree).type() == Json::nullValue);
1101 CHECK(val.size() == 1);
1102
1103 CHECK(val.removeMember(std::string("two")) == 2);
1104 CHECK(val.size() == 0);
1105
1107 CHECK(val.size() == 0);
1108}
1109
1110TEST_CASE("iterator")
1111{
1112 {
1113 // Iterating an array.
1115 arr[0u] = "zero";
1116 arr[1u] = "one";
1117 arr[2u] = "two";
1118 arr[3u] = "three";
1119
1120 Json::ValueIterator const b{arr.begin()};
1121 Json::ValueIterator const e{arr.end()};
1122
1123 Json::ValueIterator i1 = b;
1124 Json::ValueIterator i2 = e;
1125 --i2;
1126
1127 // key(), index(), and memberName() on an object iterator.
1128 CHECK(b != e);
1129 CHECK(!(b == e));
1130 CHECK(i1.key() == 0);
1131 CHECK(i2.key() == 3);
1132 CHECK(i1.index() == 0);
1133 CHECK(i2.index() == 3);
1134 CHECK(std::strcmp(i1.memberName(), "") == 0);
1135 CHECK(std::strcmp(i2.memberName(), "") == 0);
1136
1137 // Pre and post increment and decrement.
1138 *i1++ = "0";
1139 CHECK(*i1 == "one");
1140 *i1 = "1";
1141 ++i1;
1142
1143 *i2-- = "3";
1144 CHECK(*i2 == "two");
1145 CHECK(i1 == i2);
1146 *i2 = "2";
1147 CHECK(*i1 == "2");
1148 }
1149 {
1150 // Iterating a const object.
1151 Json::Value const obj{[]() {
1153 obj["0"] = 0;
1154 obj["1"] = 1;
1155 obj["2"] = 2;
1156 obj["3"] = 3;
1157 return obj;
1158 }()};
1159
1160 Json::ValueConstIterator i1{obj.begin()};
1161 Json::ValueConstIterator i2{obj.end()};
1162 --i2;
1163
1164 // key(), index(), and memberName() on an object iterator.
1165 CHECK(i1 != i2);
1166 CHECK(!(i1 == i2));
1167 CHECK(i1.key() == "0");
1168 CHECK(i2.key() == "3");
1169 CHECK(i1.index() == -1);
1170 CHECK(i2.index() == -1);
1171 CHECK(std::strcmp(i1.memberName(), "0") == 0);
1172 CHECK(std::strcmp(i2.memberName(), "3") == 0);
1173
1174 // Pre and post increment and decrement.
1175 CHECK(*i1++ == 0);
1176 CHECK(*i1 == 1);
1177 ++i1;
1178
1179 CHECK(*i2-- == 3);
1180 CHECK(*i2 == 2);
1181 CHECK(i1 == i2);
1182 CHECK(*i1 == 2);
1183 }
1184 {
1185 // Iterating a non-const null object.
1186 Json::Value nul{};
1187 CHECK(nul.begin() == nul.end());
1188 }
1189 {
1190 // Iterating a const Int.
1191 Json::Value const i{-3};
1192 CHECK(i.begin() == i.end());
1193 }
1194}
1195
1196TEST_CASE("nest limits")
1197{
1198 Json::Reader r;
1199 {
1200 auto nest = [](std::uint32_t depth) -> std::string {
1201 std::string s = "{";
1202 for (std::uint32_t i{1}; i <= depth; ++i)
1203 s += "\"obj\":{";
1204 for (std::uint32_t i{1}; i <= depth; ++i)
1205 s += "}";
1206 s += "}";
1207 return s;
1208 };
1209
1210 {
1211 // Within object nest limit
1212 auto json{nest(std::min(10u, Json::Reader::nest_limit))};
1213 Json::Value j;
1214 CHECK(r.parse(json, j));
1215 }
1216
1217 {
1218 // Exceed object nest limit
1219 auto json{nest(Json::Reader::nest_limit + 1)};
1220 Json::Value j;
1221 CHECK(!r.parse(json, j));
1222 }
1223 }
1224
1225 auto nest = [](std::uint32_t depth) -> std::string {
1226 std::string s = "{";
1227 for (std::uint32_t i{1}; i <= depth; ++i)
1228 s += "\"array\":[{";
1229 for (std::uint32_t i{1}; i <= depth; ++i)
1230 s += "]}";
1231 s += "}";
1232 return s;
1233 };
1234 {
1235 // Exceed array nest limit
1236 auto json{nest(Json::Reader::nest_limit + 1)};
1237 Json::Value j;
1238 CHECK(!r.parse(json, j));
1239 }
1240}
1241
1242TEST_CASE("memory leak")
1243{
1244 // When run with the address sanitizer, this test confirms there is no
1245 // memory leak with the scenarios below.
1246 {
1247 Json::Value a;
1248 a[0u] = 1;
1249 CHECK(a.type() == Json::arrayValue);
1250 CHECK(a[0u].type() == Json::intValue);
1251 a = std::move(a[0u]);
1252 CHECK(a.type() == Json::intValue);
1253 }
1254 {
1255 Json::Value b;
1256 Json::Value temp;
1257 temp["a"] = "Probably avoids the small string optimization";
1258 temp["b"] = "Also probably avoids the small string optimization";
1259 CHECK(temp.type() == Json::objectValue);
1260 b.append(temp);
1261 CHECK(temp.type() == Json::objectValue);
1262 CHECK(b.size() == 1);
1263
1264 b.append(std::move(temp));
1265 CHECK(b.size() == 2);
1266
1267 // Note that the type() == nullValue check is implementation
1268 // specific and not guaranteed to be valid in the future.
1269 CHECK(temp.type() == Json::nullValue);
1270 }
1271}
1272
1274
1275} // namespace ripple
Decorator for streaming out compact json.
Unserialize a JSON document into a Value.
Definition json_reader.h:20
static constexpr unsigned nest_limit
Definition json_reader.h:73
bool parse(std::string const &document, Value &root)
Read a Value from a JSON document.
Lightweight wrapper to tag static string.
Definition json_value.h:44
constexpr char const * c_str() const
Definition json_value.h:57
const iterator for object and array value.
Definition json_value.h:554
Value key() const
Return either the index or the member name of the referenced value as a Value.
char const * memberName() const
Return the member name of the referenced Value.
UInt index() const
Return the index of the referenced Value. -1 if it is not an arrayValue.
Iterator for object and array value.
Definition json_value.h:615
Represents a JSON value.
Definition json_value.h:130
bool isArray() const
Value & append(Value const &value)
Append value to array at the end.
UInt size() const
Number of values in array or object.
bool isDouble() const
char const * asCString() const
Int asInt() const
bool isString() const
UInt asUInt() const
Members getMemberNames() const
Return a list of the member names.
ValueType type() const
bool isObject() const
Value removeMember(char const *key)
Remove and return the named member.
bool isValidIndex(UInt index) const
Return true if index < size().
std::string asString() const
Returns the unquoted string value.
bool isBool() const
bool asBool() const
bool isUInt() const
bool isNull() const
isNull() tests to see if this field is null.
bool isMember(char const *key) const
Return true if the object has a member named key.
Value get(UInt index, Value const &defaultValue) const
If the array contains at least index+1 elements, returns the element value, otherwise returns default...
bool isConvertibleTo(ValueType other) const
double asDouble() const
bool isInt() const
T count_if(T... args)
T empty(T... args)
T max(T... args)
T min(T... args)
ValueType
Type of the value held by a Value object.
Definition json_value.h:18
@ booleanValue
bool value
Definition json_value.h:24
@ nullValue
'null' value
Definition json_value.h:19
@ stringValue
UTF-8 string value.
Definition json_value.h:23
@ realValue
double value
Definition json_value.h:22
@ arrayValue
array value (ordered list)
Definition json_value.h:25
@ intValue
signed integer value
Definition json_value.h:20
@ objectValue
object value (collection of name/value pairs).
Definition json_value.h:26
@ uintValue
unsigned integer value
Definition json_value.h:21
int Int
unsigned int UInt
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:6
TEST_SUITE_END()
TEST_CASE("construct and compare Json::StaticString")
Definition Value.cpp:18
TEST_SUITE_BEGIN("json_value")
T regex_match(T... args)
T str(T... args)
T strcmp(T... args)
Thrown when a conversion is not possible with LexicalCast.
T to_string(T... args)