1 // __ _____ _____ _____
2 // __| | __| | | | JSON for Modern C++ (supporting code)
3 // | | |__ | | | | | | version 3.11.2
4 // |_____|_____|_____|_|___| https://github.com/nlohmann/json
5 //
6 // SPDX-FileCopyrightText: 2013-2022 Niels Lohmann <https://nlohmann.me>
7 // SPDX-License-Identifier: MIT
8
9 #include "doctest_compatibility.h"
10
11 #include <nlohmann/json.hpp>
12 using nlohmann::json;
13
14 #include <fstream>
15 #include "make_test_data_available.hpp"
16
17 TEST_CASE("compliance tests from json.org")
18 {
19 // test cases are from https://json.org/JSON_checker/
20
21 SECTION("expected failures")
22 {
23 for (const auto* filename :
24 {
25 //TEST_DATA_DIRECTORY "/json_tests/fail1.json",
26 TEST_DATA_DIRECTORY "/json_tests/fail2.json",
27 TEST_DATA_DIRECTORY "/json_tests/fail3.json",
28 TEST_DATA_DIRECTORY "/json_tests/fail4.json",
29 TEST_DATA_DIRECTORY "/json_tests/fail5.json",
30 TEST_DATA_DIRECTORY "/json_tests/fail6.json",
31 TEST_DATA_DIRECTORY "/json_tests/fail7.json",
32 TEST_DATA_DIRECTORY "/json_tests/fail8.json",
33 TEST_DATA_DIRECTORY "/json_tests/fail9.json",
34 TEST_DATA_DIRECTORY "/json_tests/fail10.json",
35 TEST_DATA_DIRECTORY "/json_tests/fail11.json",
36 TEST_DATA_DIRECTORY "/json_tests/fail12.json",
37 TEST_DATA_DIRECTORY "/json_tests/fail13.json",
38 TEST_DATA_DIRECTORY "/json_tests/fail14.json",
39 TEST_DATA_DIRECTORY "/json_tests/fail15.json",
40 TEST_DATA_DIRECTORY "/json_tests/fail16.json",
41 TEST_DATA_DIRECTORY "/json_tests/fail17.json",
42 //TEST_DATA_DIRECTORY "/json_tests/fail18.json",
43 TEST_DATA_DIRECTORY "/json_tests/fail19.json",
44 TEST_DATA_DIRECTORY "/json_tests/fail20.json",
45 TEST_DATA_DIRECTORY "/json_tests/fail21.json",
46 TEST_DATA_DIRECTORY "/json_tests/fail22.json",
47 TEST_DATA_DIRECTORY "/json_tests/fail23.json",
48 TEST_DATA_DIRECTORY "/json_tests/fail24.json",
49 TEST_DATA_DIRECTORY "/json_tests/fail25.json",
50 TEST_DATA_DIRECTORY "/json_tests/fail26.json",
51 TEST_DATA_DIRECTORY "/json_tests/fail27.json",
52 TEST_DATA_DIRECTORY "/json_tests/fail28.json",
53 TEST_DATA_DIRECTORY "/json_tests/fail29.json",
54 TEST_DATA_DIRECTORY "/json_tests/fail30.json",
55 TEST_DATA_DIRECTORY "/json_tests/fail31.json",
56 TEST_DATA_DIRECTORY "/json_tests/fail32.json",
57 TEST_DATA_DIRECTORY "/json_tests/fail33.json"
58 })
59 {
60 CAPTURE(filename)
61 std::ifstream f(filename);
62 json _;
63 CHECK_THROWS_AS(_ = json::parse(f), json::parse_error&);
64 }
65 }
66
67 SECTION("no failures with trailing literals (relaxed)")
68 {
69 // these tests fail above, because the parser does not end on EOF;
70 // they succeed when the operator>> is used, because it does not
71 // have this constraint
72 for (const auto* filename :
73 {
74 TEST_DATA_DIRECTORY "/json_tests/fail7.json",
75 TEST_DATA_DIRECTORY "/json_tests/fail8.json",
76 TEST_DATA_DIRECTORY "/json_tests/fail10.json",
77 })
78 {
79 CAPTURE(filename)
80 std::ifstream f(filename);
81 json j;
82 CHECK_NOTHROW(f >> j);
83 }
84 }
85
86 SECTION("expected passes")
87 {
88 for (const auto* filename :
89 {
90 TEST_DATA_DIRECTORY "/json_tests/pass1.json",
91 TEST_DATA_DIRECTORY "/json_tests/pass2.json",
92 TEST_DATA_DIRECTORY "/json_tests/pass3.json"
93 })
94 {
95 CAPTURE(filename)
96 std::ifstream f(filename);
97 json j;
98 CHECK_NOTHROW(f >> j);
99 }
100 }
101 }
102
103 TEST_CASE("compliance tests from nativejson-benchmark")
104 {
105 // test cases from https://github.com/miloyip/nativejson-benchmark/blob/master/src/main.cpp
106
107 SECTION("doubles")
108 {
109 auto TEST_DOUBLE = [](const std::string & json_string, const double expected)
__anon6980bbe00102(const std::string & json_string, const double expected) 110 {
111 CAPTURE(json_string)
112 CAPTURE(expected)
113 CHECK(json::parse(json_string)[0].get<double>() == Approx(expected));
114 };
115
116 TEST_DOUBLE("[0.0]", 0.0);
117 TEST_DOUBLE("[-0.0]", -0.0);
118 TEST_DOUBLE("[1.0]", 1.0);
119 TEST_DOUBLE("[-1.0]", -1.0);
120 TEST_DOUBLE("[1.5]", 1.5);
121 TEST_DOUBLE("[-1.5]", -1.5);
122 TEST_DOUBLE("[3.1416]", 3.1416);
123 TEST_DOUBLE("[1E10]", 1E10);
124 TEST_DOUBLE("[1e10]", 1e10);
125 TEST_DOUBLE("[1E+10]", 1E+10);
126 TEST_DOUBLE("[1E-10]", 1E-10);
127 TEST_DOUBLE("[-1E10]", -1E10);
128 TEST_DOUBLE("[-1e10]", -1e10);
129 TEST_DOUBLE("[-1E+10]", -1E+10);
130 TEST_DOUBLE("[-1E-10]", -1E-10);
131 TEST_DOUBLE("[1.234E+10]", 1.234E+10);
132 TEST_DOUBLE("[1.234E-10]", 1.234E-10);
133 TEST_DOUBLE("[1.79769e+308]", 1.79769e+308);
134 TEST_DOUBLE("[2.22507e-308]", 2.22507e-308);
135 TEST_DOUBLE("[-1.79769e+308]", -1.79769e+308);
136 TEST_DOUBLE("[-2.22507e-308]", -2.22507e-308);
137 TEST_DOUBLE("[4.9406564584124654e-324]", 4.9406564584124654e-324); // minimum denormal
138 TEST_DOUBLE("[2.2250738585072009e-308]", 2.2250738585072009e-308); // Max subnormal double
139 TEST_DOUBLE("[2.2250738585072014e-308]", 2.2250738585072014e-308); // Min normal positive double
140 TEST_DOUBLE("[1.7976931348623157e+308]", 1.7976931348623157e+308); // Max double
141 TEST_DOUBLE("[1e-10000]", 0.0); // must underflow
142 TEST_DOUBLE("[18446744073709551616]",
143 18446744073709551616.0); // 2^64 (max of uint64_t + 1, force to use double)
144 TEST_DOUBLE("[-9223372036854775809]",
145 -9223372036854775809.0); // -2^63 - 1(min of int64_t + 1, force to use double)
146 TEST_DOUBLE("[0.9868011474609375]",
147 0.9868011474609375); // https://github.com/miloyip/rapidjson/issues/120
148 TEST_DOUBLE("[123e34]", 123e34); // Fast Path Cases In Disguise
149 TEST_DOUBLE("[45913141877270640000.0]", 45913141877270640000.0);
150 TEST_DOUBLE("[2.2250738585072011e-308]",
151 2.2250738585072011e-308);
152 //TEST_DOUBLE("[1e-00011111111111]", 0.0);
153 //TEST_DOUBLE("[-1e-00011111111111]", -0.0);
154 TEST_DOUBLE("[1e-214748363]", 0.0);
155 TEST_DOUBLE("[1e-214748364]", 0.0);
156 //TEST_DOUBLE("[1e-21474836311]", 0.0);
157 TEST_DOUBLE("[0.017976931348623157e+310]", 1.7976931348623157e+308); // Max double in another form
158
159 // Since
160 // abs((2^-1022 - 2^-1074) - 2.2250738585072012e-308) = 3.109754131239141401123495768877590405345064751974375599... ¡Á 10^-324
161 // abs((2^-1022) - 2.2250738585072012e-308) = 1.830902327173324040642192159804623318305533274168872044... ¡Á 10 ^ -324
162 // So 2.2250738585072012e-308 should round to 2^-1022 = 2.2250738585072014e-308
163 TEST_DOUBLE("[2.2250738585072012e-308]",
164 2.2250738585072014e-308);
165
166 // More closer to normal/subnormal boundary
167 // boundary = 2^-1022 - 2^-1075 = 2.225073858507201136057409796709131975934819546351645648... ¡Á 10^-308
168 TEST_DOUBLE("[2.22507385850720113605740979670913197593481954635164564e-308]",
169 2.2250738585072009e-308);
170 TEST_DOUBLE("[2.22507385850720113605740979670913197593481954635164565e-308]",
171 2.2250738585072014e-308);
172
173 // 1.0 is in (1.0 - 2^-54, 1.0 + 2^-53)
174 // 1.0 - 2^-54 = 0.999999999999999944488848768742172978818416595458984375
175 TEST_DOUBLE("[0.999999999999999944488848768742172978818416595458984375]", 1.0); // round to even
176 TEST_DOUBLE("[0.999999999999999944488848768742172978818416595458984374]",
177 0.99999999999999989); // previous double
178 TEST_DOUBLE("[0.999999999999999944488848768742172978818416595458984376]", 1.0); // next double
179 // 1.0 + 2^-53 = 1.00000000000000011102230246251565404236316680908203125
180 TEST_DOUBLE("[1.00000000000000011102230246251565404236316680908203125]", 1.0); // round to even
181 TEST_DOUBLE("[1.00000000000000011102230246251565404236316680908203124]", 1.0); // previous double
182 TEST_DOUBLE("[1.00000000000000011102230246251565404236316680908203126]",
183 1.00000000000000022); // next double
184
185 // Numbers from https://github.com/floitsch/double-conversion/blob/master/test/cctest/test-strtod.cc
186
187 TEST_DOUBLE("[72057594037927928.0]", 72057594037927928.0);
188 TEST_DOUBLE("[72057594037927936.0]", 72057594037927936.0);
189 TEST_DOUBLE("[72057594037927932.0]", 72057594037927936.0);
190 TEST_DOUBLE("[7205759403792793199999e-5]", 72057594037927928.0);
191 TEST_DOUBLE("[7205759403792793200001e-5]", 72057594037927936.0);
192
193 TEST_DOUBLE("[9223372036854774784.0]", 9223372036854774784.0);
194 TEST_DOUBLE("[9223372036854775808.0]", 9223372036854775808.0);
195 TEST_DOUBLE("[9223372036854775296.0]", 9223372036854775808.0);
196 TEST_DOUBLE("[922337203685477529599999e-5]", 9223372036854774784.0);
197 TEST_DOUBLE("[922337203685477529600001e-5]", 9223372036854775808.0);
198
199 TEST_DOUBLE("[10141204801825834086073718800384]", 10141204801825834086073718800384.0);
200 TEST_DOUBLE("[10141204801825835211973625643008]", 10141204801825835211973625643008.0);
201 TEST_DOUBLE("[10141204801825834649023672221696]", 10141204801825835211973625643008.0);
202 TEST_DOUBLE("[1014120480182583464902367222169599999e-5]", 10141204801825834086073718800384.0);
203 TEST_DOUBLE("[1014120480182583464902367222169600001e-5]", 10141204801825835211973625643008.0);
204
205 TEST_DOUBLE("[5708990770823838890407843763683279797179383808]",
206 5708990770823838890407843763683279797179383808.0);
207 TEST_DOUBLE("[5708990770823839524233143877797980545530986496]",
208 5708990770823839524233143877797980545530986496.0);
209 TEST_DOUBLE("[5708990770823839207320493820740630171355185152]",
210 5708990770823839524233143877797980545530986496.0);
211 TEST_DOUBLE("[5708990770823839207320493820740630171355185151999e-3]",
212 5708990770823838890407843763683279797179383808.0);
213 TEST_DOUBLE("[5708990770823839207320493820740630171355185152001e-3]",
214 5708990770823839524233143877797980545530986496.0);
215
216 {
217 std::string n1e308(312, '0'); // '1' followed by 308 '0'
218 n1e308[0] = '[';
219 n1e308[1] = '1';
220 n1e308[310] = ']';
221 n1e308[311] = '\0';
222 TEST_DOUBLE(n1e308, 1E308);
223 }
224
225 // Cover trimming
226 TEST_DOUBLE(
227 "[2.22507385850720113605740979670913197593481954635164564802342610972482222202107694551652952390813508"
228 "7914149158913039621106870086438694594645527657207407820621743379988141063267329253552286881372149012"
229 "9811224514518898490572223072852551331557550159143974763979834118019993239625482890171070818506906306"
230 "6665599493827577257201576306269066333264756530000924588831643303777979186961204949739037782970490505"
231 "1080609940730262937128958950003583799967207254304360284078895771796150945516748243471030702609144621"
232 "5722898802581825451803257070188608721131280795122334262883686223215037756666225039825343359745688844"
233 "2390026549819838548794829220689472168983109969836584681402285424333066033985088644580400103493397042"
234 "7567186443383770486037861622771738545623065874679014086723327636718751234567890123456789012345678901"
235 "e-308]",
236 2.2250738585072014e-308);
237 }
238
239 SECTION("strings")
240 {
241 auto TEST_STRING = [](const std::string & json_string, const std::string & expected)
__anon6980bbe00202(const std::string & json_string, const std::string & expected) 242 {
243 CAPTURE(json_string)
244 CAPTURE(expected)
245 CHECK(json::parse(json_string)[0].get<std::string>() == expected);
246 };
247
248 TEST_STRING("[\"\"]", "");
249 TEST_STRING("[\"Hello\"]", "Hello");
250 TEST_STRING(R"(["Hello\nWorld"])", "Hello\nWorld");
251 //TEST_STRING("[\"Hello\\u0000World\"]", "Hello\0World");
252 TEST_STRING(R"(["\"\\/\b\f\n\r\t"])", "\"\\/\b\f\n\r\t");
253 TEST_STRING(R"(["\u0024"])", "$"); // Dollar sign U+0024
254 TEST_STRING(R"(["\u00A2"])", "\xC2\xA2"); // Cents sign U+00A2
255 TEST_STRING(R"(["\u20AC"])", "\xE2\x82\xAC"); // Euro sign U+20AC
256 TEST_STRING(R"(["\uD834\uDD1E"])", "\xF0\x9D\x84\x9E"); // G clef sign U+1D11E
257 }
258
259 SECTION("roundtrip")
260 {
261 // test cases are from https://github.com/miloyip/nativejson-benchmark/tree/master/test/data/roundtrip
262
263 for (const auto* filename :
264 {
265 TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip01.json",
266 TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip02.json",
267 TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip03.json",
268 TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip04.json",
269 TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip05.json",
270 TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip06.json",
271 TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip07.json",
272 TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip08.json",
273 TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip09.json",
274 TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip10.json",
275 TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip11.json",
276 TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip12.json",
277 TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip13.json",
278 TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip14.json",
279 TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip15.json",
280 TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip16.json",
281 TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip17.json",
282 TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip18.json",
283 TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip19.json",
284 TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip20.json",
285 TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip21.json",
286 TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip22.json",
287 TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip23.json",
288 TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip24.json",
289 TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip25.json",
290 TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip26.json",
291 TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip27.json",
292 //TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip28.json", // incompatible with roundtrip24
293 TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip29.json",
294 TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip30.json",
295 TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip31.json"
296 //TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip32.json" // same as roundtrip31
297 })
298 {
299 CAPTURE(filename)
300 std::ifstream f(filename);
301 std::string json_string( (std::istreambuf_iterator<char>(f) ),
302 (std::istreambuf_iterator<char>()) );
303
304 CAPTURE(json_string)
305 json j = json::parse(json_string);
306 CHECK(j.dump() == json_string);
307 }
308 }
309 }
310
311 TEST_CASE("test suite from json-test-suite")
312 {
313 SECTION("read all sample.json")
314 {
315 // read a file with all unicode characters stored as single-character
316 // strings in a JSON array
317 std::ifstream f(TEST_DATA_DIRECTORY "/json_testsuite/sample.json");
318 json j;
319 CHECK_NOTHROW(f >> j);
320
321 // the array has 3 elements
322 CHECK(j.size() == 3);
323 }
324 }
325
326 TEST_CASE("json.org examples")
327 {
328 // here, we list all JSON values from https://json.org/example
329
330 SECTION("1.json")
331 {
332 std::ifstream f(TEST_DATA_DIRECTORY "/json.org/1.json");
333 json j;
334 CHECK_NOTHROW(f >> j);
335 }
336
337 SECTION("2.json")
338 {
339 std::ifstream f(TEST_DATA_DIRECTORY "/json.org/2.json");
340 json j;
341 CHECK_NOTHROW(f >> j);
342 }
343
344 SECTION("3.json")
345 {
346 std::ifstream f(TEST_DATA_DIRECTORY "/json.org/3.json");
347 json j;
348 CHECK_NOTHROW(f >> j);
349 }
350
351 SECTION("4.json")
352 {
353 std::ifstream f(TEST_DATA_DIRECTORY "/json.org/4.json");
354 json j;
355 CHECK_NOTHROW(f >> j);
356 }
357
358 SECTION("5.json")
359 {
360 std::ifstream f(TEST_DATA_DIRECTORY "/json.org/5.json");
361 json j;
362 CHECK_NOTHROW(f >> j);
363 }
364 SECTION("FILE 1.json")
365 {
366 std::unique_ptr<std::FILE, decltype(&std::fclose)> f(std::fopen(TEST_DATA_DIRECTORY "/json.org/1.json", "r"), &std::fclose);
367 json _;
368 CHECK_NOTHROW(_ = json::parse(f.get()));
369 }
370
371 SECTION("FILE 2.json")
372 {
373 std::unique_ptr<std::FILE, decltype(&std::fclose)> f(std::fopen(TEST_DATA_DIRECTORY "/json.org/2.json", "r"), &std::fclose);
374 json _;
375 CHECK_NOTHROW(_ = json::parse(f.get()));
376 }
377
378 SECTION("FILE 3.json")
379 {
380 std::unique_ptr<std::FILE, decltype(&std::fclose)> f(std::fopen(TEST_DATA_DIRECTORY "/json.org/3.json", "r"), &std::fclose);
381 json _;
382 CHECK_NOTHROW(_ = json::parse(f.get()));
383 }
384
385 SECTION("FILE 4.json")
386 {
387 std::unique_ptr<std::FILE, decltype(&std::fclose)> f(std::fopen(TEST_DATA_DIRECTORY "/json.org/4.json", "r"), &std::fclose);
388 json _;
389 CHECK_NOTHROW(_ = json::parse(f.get()));
390 }
391
392 SECTION("FILE 5.json")
393 {
394 std::unique_ptr<std::FILE, decltype(&std::fclose)> f(std::fopen(TEST_DATA_DIRECTORY "/json.org/5.json", "r"), &std::fclose);
395 json _;
396 CHECK_NOTHROW(_ = json::parse(f.get()));
397 }
398 }
399
400 TEST_CASE("RFC 8259 examples")
401 {
402 // here, we list all JSON values from the RFC 8259 document
403
404 SECTION("7. Strings")
405 {
406 CHECK(json::parse("\"\\u005C\"") == json("\\"));
407 CHECK(json::parse("\"\\uD834\\uDD1E\"") == json(""));
408 CHECK(json::parse("\"\"") == json(""));
409 }
410
411 SECTION("8.3 String Comparison")
412 {
413 CHECK(json::parse("\"a\\b\"") == json::parse("\"a\u005Cb\""));
414 }
415
416 SECTION("13 Examples")
417 {
418 {
419 const auto* json_contents = R"(
420 {
421 "Image": {
422 "Width": 800,
423 "Height": 600,
424 "Title": "View from 15th Floor",
425 "Thumbnail": {
426 "Url": "http://www.example.com/image/481989943",
427 "Height": 125,
428 "Width": 100
429 },
430 "Animated" : false,
431 "IDs": [116, 943, 234, 38793]
432 }
433 }
434 )";
435
436 CHECK_NOTHROW(json(json_contents));
437 }
438
439 {
440 const auto* json_contents = R"(
441 [
442 {
443 "precision": "zip",
444 "Latitude": 37.7668,
445 "Longitude": -122.3959,
446 "Address": "",
447 "City": "SAN FRANCISCO",
448 "State": "CA",
449 "Zip": "94107",
450 "Country": "US"
451 },
452 {
453 "precision": "zip",
454 "Latitude": 37.371991,
455 "Longitude": -122.026020,
456 "Address": "",
457 "City": "SUNNYVALE",
458 "State": "CA",
459 "Zip": "94085",
460 "Country": "US"
461 }
462 ])";
463 CHECK_NOTHROW(json(json_contents));
464 }
465
466 CHECK(json::parse("\"Hello world!\"") == json("Hello world!"));
467 CHECK(json::parse("42") == json(42));
468 CHECK(json::parse("true") == json(true));
469 }
470 }
471
472 TEST_CASE("nst's JSONTestSuite")
473 {
474 SECTION("test_parsing")
475 {
476 SECTION("y")
477 {
478 for (const auto* filename :
479 {
480 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_array_arraysWithSpaces.json",
481 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_array_empty-string.json",
482 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_array_empty.json",
483 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_array_ending_with_newline.json",
484 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_array_false.json",
485 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_array_heterogeneous.json",
486 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_array_null.json",
487 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_array_with_1_and_newline.json",
488 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_array_with_leading_space.json",
489 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_array_with_several_null.json",
490 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_array_with_trailing_space.json",
491 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_number.json",
492 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_number_0e+1.json",
493 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_number_0e1.json",
494 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_number_after_space.json",
495 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_number_double_close_to_zero.json",
496 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_number_double_huge_neg_exp.json",
497 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_number_int_with_exp.json",
498 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_number_minus_zero.json",
499 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_number_negative_int.json",
500 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_number_negative_one.json",
501 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_number_negative_zero.json",
502 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_number_real_capital_e.json",
503 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_number_real_capital_e_neg_exp.json",
504 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_number_real_capital_e_pos_exp.json",
505 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_number_real_exponent.json",
506 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_number_real_fraction_exponent.json",
507 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_number_real_neg_exp.json",
508 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_number_real_pos_exponent.json",
509 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_number_real_underflow.json",
510 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_number_simple_int.json",
511 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_number_simple_real.json",
512 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_number_too_big_neg_int.json",
513 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_number_too_big_pos_int.json",
514 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_number_very_big_negative_int.json",
515 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_object.json",
516 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_object_basic.json",
517 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_object_duplicated_key.json",
518 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_object_duplicated_key_and_value.json",
519 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_object_empty.json",
520 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_object_empty_key.json",
521 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_object_escaped_null_in_key.json",
522 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_object_extreme_numbers.json",
523 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_object_long_strings.json",
524 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_object_simple.json",
525 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_object_string_unicode.json",
526 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_object_with_newlines.json",
527 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_1_2_3_bytes_UTF-8_sequences.json",
528 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_UTF-16_Surrogates_U+1D11E_MUSICAL_SYMBOL_G_CLEF.json",
529 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_accepted_surrogate_pair.json",
530 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_accepted_surrogate_pairs.json",
531 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_allowed_escapes.json",
532 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_backslash_and_u_escaped_zero.json",
533 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_backslash_doublequotes.json",
534 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_comments.json",
535 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_double_escape_a.json",
536 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_double_escape_n.json",
537 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_escaped_control_character.json",
538 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_escaped_noncharacter.json",
539 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_in_array.json",
540 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_in_array_with_leading_space.json",
541 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_last_surrogates_1_and_2.json",
542 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_newline_uescaped.json",
543 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_nonCharacterInUTF-8_U+10FFFF.json",
544 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_nonCharacterInUTF-8_U+1FFFF.json",
545 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_nonCharacterInUTF-8_U+FFFF.json",
546 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_null_escape.json",
547 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_one-byte-utf-8.json",
548 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_pi.json",
549 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_simple_ascii.json",
550 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_space.json",
551 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_three-byte-utf-8.json",
552 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_two-byte-utf-8.json",
553 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_u+2028_line_sep.json",
554 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_u+2029_par_sep.json",
555 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_uEscape.json",
556 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_unescaped_char_delete.json",
557 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_unicode.json",
558 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_unicodeEscapedBackslash.json",
559 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_unicode_2.json",
560 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_unicode_U+200B_ZERO_WIDTH_SPACE.json",
561 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_unicode_U+2064_invisible_plus.json",
562 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_unicode_escaped_double_quote.json",
563 // TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_utf16.json",
564 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_utf8.json",
565 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_with_del_character.json",
566 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_structure_lonely_false.json",
567 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_structure_lonely_int.json",
568 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_structure_lonely_negative_real.json",
569 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_structure_lonely_null.json",
570 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_structure_lonely_string.json",
571 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_structure_lonely_true.json",
572 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_structure_string_empty.json",
573 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_structure_trailing_newline.json",
574 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_structure_true_in_array.json",
575 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_structure_whitespace_array.json"
576 }
577 )
578 {
579 CAPTURE(filename)
580 std::ifstream f(filename);
581 json j;
582 CHECK_NOTHROW(f >> j);
583 }
584 }
585
586 SECTION("n")
587 {
588 for (const auto* filename :
589 {
590 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_array_1_true_without_comma.json",
591 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_array_a_invalid_utf8.json",
592 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_array_colon_instead_of_comma.json",
593 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_array_comma_after_close.json",
594 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_array_comma_and_number.json",
595 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_array_double_comma.json",
596 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_array_double_extra_comma.json",
597 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_array_extra_close.json",
598 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_array_extra_comma.json",
599 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_array_incomplete.json",
600 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_array_incomplete_invalid_value.json",
601 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_array_inner_array_no_comma.json",
602 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_array_invalid_utf8.json",
603 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_array_items_separated_by_semicolon.json",
604 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_array_just_comma.json",
605 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_array_just_minus.json",
606 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_array_missing_value.json",
607 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_array_newlines_unclosed.json",
608 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_array_number_and_comma.json",
609 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_array_number_and_several_commas.json",
610 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_array_spaces_vertical_tab_formfeed.json",
611 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_array_star_inside.json",
612 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_array_unclosed.json",
613 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_array_unclosed_trailing_comma.json",
614 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_array_unclosed_with_new_lines.json",
615 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_array_unclosed_with_object_inside.json",
616 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_incomplete_false.json",
617 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_incomplete_null.json",
618 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_incomplete_true.json",
619 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_number_++.json",
620 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_number_+1.json",
621 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_number_+Inf.json",
622 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_number_-01.json",
623 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_number_-1.0..json",
624 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_number_-2..json",
625 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_number_-NaN.json",
626 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_number_.-1.json",
627 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_number_.2e-3.json",
628 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_number_0.1.2.json",
629 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_number_0.3e+.json",
630 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_number_0.3e.json",
631 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_number_0.e1.json",
632 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_number_0_capital_E+.json",
633 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_number_0_capital_E.json",
634 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_number_0e+.json",
635 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_number_0e.json",
636 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_number_1.0e+.json",
637 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_number_1.0e-.json",
638 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_number_1.0e.json",
639 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_number_1_000.json",
640 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_number_1eE2.json",
641 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_number_2.e+3.json",
642 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_number_2.e-3.json",
643 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_number_2.e3.json",
644 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_number_9.e+.json",
645 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_number_Inf.json",
646 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_number_NaN.json",
647 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_number_U+FF11_fullwidth_digit_one.json",
648 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_number_expression.json",
649 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_number_hex_1_digit.json",
650 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_number_hex_2_digits.json",
651 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_number_infinity.json",
652 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_number_invalid+-.json",
653 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_number_invalid-negative-real.json",
654 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_number_invalid-utf-8-in-bigger-int.json",
655 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_number_invalid-utf-8-in-exponent.json",
656 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_number_invalid-utf-8-in-int.json",
657 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_number_minus_infinity.json",
658 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_number_minus_sign_with_trailing_garbage.json",
659 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_number_minus_space_1.json",
660 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_number_neg_int_starting_with_zero.json",
661 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_number_neg_real_without_int_part.json",
662 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_number_neg_with_garbage_at_end.json",
663 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_number_real_garbage_after_e.json",
664 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_number_real_with_invalid_utf8_after_e.json",
665 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_number_real_without_fractional_part.json",
666 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_number_starting_with_dot.json",
667 //TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_number_then_00.json",
668 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_number_with_alpha.json",
669 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_number_with_alpha_char.json",
670 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_number_with_leading_zero.json",
671 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_object_bad_value.json",
672 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_object_bracket_key.json",
673 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_object_comma_instead_of_colon.json",
674 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_object_double_colon.json",
675 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_object_emoji.json",
676 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_object_garbage_at_end.json",
677 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_object_key_with_single_quotes.json",
678 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_object_missing_colon.json",
679 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_object_missing_key.json",
680 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_object_missing_semicolon.json",
681 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_object_missing_value.json",
682 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_object_no-colon.json",
683 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_object_non_string_key.json",
684 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_object_non_string_key_but_huge_number_instead.json",
685 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_object_pi_in_key_and_trailing_comma.json",
686 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_object_repeated_null_null.json",
687 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_object_several_trailing_commas.json",
688 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_object_single_quote.json",
689 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_object_trailing_comma.json",
690 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_object_trailing_comment.json",
691 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_object_trailing_comment_open.json",
692 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_object_trailing_comment_slash_open.json",
693 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_object_trailing_comment_slash_open_incomplete.json",
694 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_object_two_commas_in_a_row.json",
695 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_object_unquoted_key.json",
696 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_object_unterminated-value.json",
697 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_object_with_single_string.json",
698 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_object_with_trailing_garbage.json",
699 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_single_space.json",
700 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_string_1_surrogate_then_escape u.json",
701 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_string_1_surrogate_then_escape u1.json",
702 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_string_1_surrogate_then_escape u1x.json",
703 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_string_1_surrogate_then_escape.json",
704 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_string_UTF-16_incomplete_surrogate.json",
705 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_string_UTF8_surrogate_U+D800.json",
706 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_string_accentuated_char_no_quotes.json",
707 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_string_backslash_00.json",
708 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_string_escape_x.json",
709 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_string_escaped_backslash_bad.json",
710 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_string_escaped_ctrl_char_tab.json",
711 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_string_escaped_emoji.json",
712 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_string_incomplete_escape.json",
713 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_string_incomplete_escaped_character.json",
714 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_string_incomplete_surrogate_escape_invalid.json",
715 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_string_invalid-utf-8-in-escape.json",
716 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_string_invalid_backslash_esc.json",
717 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_string_invalid_unicode_escape.json",
718 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_string_invalid_utf-8.json",
719 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_string_invalid_utf8_after_escape.json",
720 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_string_iso_latin_1.json",
721 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_string_leading_uescaped_thinspace.json",
722 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_string_lone_utf8_continuation_byte.json",
723 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_string_no_quotes_with_bad_escape.json",
724 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_string_overlong_sequence_2_bytes.json",
725 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_string_overlong_sequence_6_bytes.json",
726 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_string_overlong_sequence_6_bytes_null.json",
727 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_string_single_doublequote.json",
728 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_string_single_quote.json",
729 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_string_single_string_no_double_quotes.json",
730 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_string_start_escape_unclosed.json",
731 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_string_unescaped_crtl_char.json",
732 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_string_unescaped_newline.json",
733 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_string_unescaped_tab.json",
734 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_string_unicode_CapitalU.json",
735 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_string_with_trailing_garbage.json",
736 //!TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_structure_100000_opening_arrays.json",
737 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_structure_3C.3E.json",
738 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_structure_3Cnull3E.json",
739 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_structure_U+2060_word_joined.json",
740 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_structure_UTF8_BOM_no_data.json",
741 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_structure_array_trailing_garbage.json",
742 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_structure_array_with_extra_array_close.json",
743 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_structure_array_with_unclosed_string.json",
744 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_structure_ascii-unicode-identifier.json",
745 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_structure_capitalized_True.json",
746 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_structure_close_unopened_array.json",
747 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_structure_comma_instead_of_closing_brace.json",
748 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_structure_double_array.json",
749 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_structure_end_array.json",
750 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_structure_incomplete_UTF8_BOM.json",
751 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_structure_lone-invalid-utf-8.json",
752 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_structure_lone-open-bracket.json",
753 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_structure_no_data.json",
754 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_structure_null-byte-outside-string.json",
755 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_structure_number_with_trailing_garbage.json",
756 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_structure_object_followed_by_closing_object.json",
757 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_structure_object_unclosed_no_value.json",
758 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_structure_object_with_comment.json",
759 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_structure_object_with_trailing_garbage.json",
760 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_structure_open_array_apostrophe.json",
761 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_structure_open_array_comma.json",
762 //!TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_structure_open_array_object.json",
763 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_structure_open_array_open_object.json",
764 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_structure_open_array_open_string.json",
765 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_structure_open_array_string.json",
766 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_structure_open_object.json",
767 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_structure_open_object_close_array.json",
768 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_structure_open_object_comma.json",
769 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_structure_open_object_open_array.json",
770 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_structure_open_object_open_string.json",
771 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_structure_open_object_string_with_apostrophes.json",
772 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_structure_open_open.json",
773 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_structure_single_point.json",
774 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_structure_single_star.json",
775 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_structure_trailing_#.json",
776 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_structure_uescaped_LF_before_string.json",
777 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_structure_unclosed_array.json",
778 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_structure_unclosed_array_partial_null.json",
779 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_structure_unclosed_array_unfinished_false.json",
780 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_structure_unclosed_array_unfinished_true.json",
781 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_structure_unclosed_object.json",
782 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_structure_unicode-identifier.json",
783 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_structure_whitespace_U+2060_word_joiner.json",
784 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_structure_whitespace_formfeed.json"
785 }
786 )
787 {
788 CAPTURE(filename)
789 std::ifstream f(filename);
790 json _;
791 CHECK_THROWS_AS(_ = json::parse(f), json::parse_error&);
792 }
793 }
794
795 SECTION("n -> y (relaxed)")
796 {
797 // these tests fail above, because the parser does not end on EOF;
798 // they succeed when the operator>> is used, because it does not
799 // have this constraint
800 for (const auto* filename :
801 {
802 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_array_comma_after_close.json",
803 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_array_extra_close.json",
804 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_object_trailing_comment.json",
805 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_object_trailing_comment_open.json",
806 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_object_trailing_comment_slash_open.json",
807 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_object_trailing_comment_slash_open_incomplete.json",
808 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_object_with_trailing_garbage.json",
809 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_string_with_trailing_garbage.json",
810 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_structure_array_trailing_garbage.json",
811 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_structure_array_with_extra_array_close.json",
812 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_structure_close_unopened_array.json",
813 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_structure_double_array.json",
814 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_structure_number_with_trailing_garbage.json",
815 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_structure_object_followed_by_closing_object.json",
816 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_structure_object_with_trailing_garbage.json",
817 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_structure_trailing_#.json"
818 }
819 )
820 {
821 CAPTURE(filename)
822 std::ifstream f(filename);
823 json j;
824 CHECK_NOTHROW(f >> j);
825 }
826 }
827
828 SECTION("i -> y")
829 {
830 for (const auto* filename :
831 {
832 // we do not pose a limit on nesting
833 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/i_structure_500_nested_arrays.json",
834 // we silently ignore BOMs
835 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/i_structure_UTF-8_BOM_empty_object.json",
836 // we accept and forward non-characters
837 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/i_string_unicode_U+10FFFE_nonchar.json",
838 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/i_string_unicode_U+1FFFE_nonchar.json",
839 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/i_string_unicode_U+FDD0_nonchar.json",
840 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/i_string_unicode_U+FFFE_nonchar.json"
841 }
842 )
843 {
844 CAPTURE(filename)
845 std::ifstream f(filename);
846 json j;
847 CHECK_NOTHROW(f >> j);
848 }
849 }
850
851 // numbers that overflow during parsing
852 SECTION("i/y -> n (out of range)")
853 {
854 for (const auto* filename :
855 {
856 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/i_number_neg_int_huge_exp.json",
857 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/i_number_pos_double_huge_exp.json",
858 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_number_huge_exp.json",
859 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_number_real_neg_overflow.json",
860 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_number_real_pos_overflow.json"
861 }
862 )
863 {
864 CAPTURE(filename)
865 std::ifstream f(filename);
866 json j;
867 CHECK_THROWS_AS(f >> j, json::out_of_range&);
868 }
869 }
870
871 SECTION("i -> n")
872 {
873 for (const auto* filename :
874 {
875 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/i_object_key_lone_2nd_surrogate.json",
876 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/i_string_1st_surrogate_but_2nd_missing.json",
877 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/i_string_1st_valid_surrogate_2nd_invalid.json",
878 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/i_string_UTF-16_invalid_lonely_surrogate.json",
879 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/i_string_UTF-16_invalid_surrogate.json",
880 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/i_string_UTF-8_invalid_sequence.json",
881 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/i_string_incomplete_surrogate_and_escape_valid.json",
882 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/i_string_incomplete_surrogate_pair.json",
883 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/i_string_incomplete_surrogates_escape_valid.json",
884 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/i_string_inverted_surrogates_U+1D11E.json",
885 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/i_string_lone_second_surrogate.json",
886 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/i_string_not_in_unicode_range.json",
887 TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/i_string_truncated-utf-8.json"
888 }
889 )
890 {
891 CAPTURE(filename)
892 std::ifstream f(filename);
893 json j;
894 CHECK_THROWS_AS(f >> j, json::parse_error&);
895 }
896 }
897 }
898 }
899
900 TEST_CASE("nst's JSONTestSuite (2)")
901 {
902 SECTION("test_parsing")
903 {
904 SECTION("y")
905 {
906 for (const auto* filename :
907 {
908 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_array_arraysWithSpaces.json",
909 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_array_empty-string.json",
910 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_array_empty.json",
911 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_array_ending_with_newline.json",
912 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_array_false.json",
913 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_array_heterogeneous.json",
914 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_array_null.json",
915 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_array_with_1_and_newline.json",
916 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_array_with_leading_space.json",
917 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_array_with_several_null.json",
918 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_array_with_trailing_space.json",
919 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_number.json",
920 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_number_0e+1.json",
921 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_number_0e1.json",
922 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_number_after_space.json",
923 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_number_double_close_to_zero.json",
924 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_number_int_with_exp.json",
925 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_number_minus_zero.json",
926 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_number_negative_int.json",
927 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_number_negative_one.json",
928 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_number_negative_zero.json",
929 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_number_real_capital_e.json",
930 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_number_real_capital_e_neg_exp.json",
931 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_number_real_capital_e_pos_exp.json",
932 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_number_real_exponent.json",
933 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_number_real_fraction_exponent.json",
934 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_number_real_neg_exp.json",
935 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_number_real_pos_exponent.json",
936 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_number_simple_int.json",
937 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_number_simple_real.json",
938 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_object.json",
939 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_object_basic.json",
940 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_object_duplicated_key.json",
941 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_object_duplicated_key_and_value.json",
942 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_object_empty.json",
943 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_object_empty_key.json",
944 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_object_escaped_null_in_key.json",
945 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_object_extreme_numbers.json",
946 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_object_long_strings.json",
947 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_object_simple.json",
948 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_object_string_unicode.json",
949 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_object_with_newlines.json",
950 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_string_1_2_3_bytes_UTF-8_sequences.json",
951 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_string_accepted_surrogate_pair.json",
952 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_string_accepted_surrogate_pairs.json",
953 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_string_allowed_escapes.json",
954 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_string_backslash_and_u_escaped_zero.json",
955 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_string_backslash_doublequotes.json",
956 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_string_comments.json",
957 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_string_double_escape_a.json",
958 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_string_double_escape_n.json",
959 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_string_escaped_control_character.json",
960 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_string_escaped_noncharacter.json",
961 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_string_in_array.json",
962 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_string_in_array_with_leading_space.json",
963 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_string_last_surrogates_1_and_2.json",
964 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_string_nbsp_uescaped.json",
965 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_string_nonCharacterInUTF-8_U+10FFFF.json",
966 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_string_nonCharacterInUTF-8_U+FFFF.json",
967 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_string_null_escape.json",
968 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_string_one-byte-utf-8.json",
969 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_string_pi.json",
970 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_string_reservedCharacterInUTF-8_U+1BFFF.json",
971 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_string_simple_ascii.json",
972 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_string_space.json",
973 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_string_surrogates_U+1D11E_MUSICAL_SYMBOL_G_CLEF.json",
974 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_string_three-byte-utf-8.json",
975 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_string_two-byte-utf-8.json",
976 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_string_u+2028_line_sep.json",
977 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_string_u+2029_par_sep.json",
978 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_string_uEscape.json",
979 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_string_uescaped_newline.json",
980 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_string_unescaped_char_delete.json",
981 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_string_unicode.json",
982 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_string_unicodeEscapedBackslash.json",
983 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_string_unicode_2.json",
984 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_string_unicode_U+10FFFE_nonchar.json",
985 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_string_unicode_U+1FFFE_nonchar.json",
986 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_string_unicode_U+200B_ZERO_WIDTH_SPACE.json",
987 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_string_unicode_U+2064_invisible_plus.json",
988 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_string_unicode_U+FDD0_nonchar.json",
989 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_string_unicode_U+FFFE_nonchar.json",
990 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_string_unicode_escaped_double_quote.json",
991 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_string_utf8.json",
992 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_string_with_del_character.json",
993 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_structure_lonely_false.json",
994 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_structure_lonely_int.json",
995 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_structure_lonely_negative_real.json",
996 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_structure_lonely_null.json",
997 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_structure_lonely_string.json",
998 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_structure_lonely_true.json",
999 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_structure_string_empty.json",
1000 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_structure_trailing_newline.json",
1001 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_structure_true_in_array.json",
1002 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_structure_whitespace_array.json"
1003 }
1004 )
1005 {
1006 CAPTURE(filename)
1007 std::ifstream f(filename);
1008 json _;
1009 CHECK_NOTHROW(_ = json::parse(f));
1010 std::ifstream f2(filename);
1011 CHECK(json::accept(f2));
1012 }
1013 }
1014
1015 SECTION("n")
1016 {
1017 for (const auto* filename :
1018 {
1019 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_array_1_true_without_comma.json",
1020 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_array_a_invalid_utf8.json",
1021 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_array_colon_instead_of_comma.json",
1022 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_array_comma_after_close.json",
1023 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_array_comma_and_number.json",
1024 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_array_double_comma.json",
1025 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_array_double_extra_comma.json",
1026 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_array_extra_close.json",
1027 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_array_extra_comma.json",
1028 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_array_incomplete.json",
1029 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_array_incomplete_invalid_value.json",
1030 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_array_inner_array_no_comma.json",
1031 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_array_invalid_utf8.json",
1032 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_array_items_separated_by_semicolon.json",
1033 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_array_just_comma.json",
1034 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_array_just_minus.json",
1035 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_array_missing_value.json",
1036 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_array_newlines_unclosed.json",
1037 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_array_number_and_comma.json",
1038 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_array_number_and_several_commas.json",
1039 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_array_spaces_vertical_tab_formfeed.json",
1040 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_array_star_inside.json",
1041 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_array_unclosed.json",
1042 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_array_unclosed_trailing_comma.json",
1043 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_array_unclosed_with_new_lines.json",
1044 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_array_unclosed_with_object_inside.json",
1045 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_incomplete_false.json",
1046 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_incomplete_null.json",
1047 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_incomplete_true.json",
1048 //TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_multidigit_number_then_00.json",
1049 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_number_++.json",
1050 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_number_+1.json",
1051 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_number_+Inf.json",
1052 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_number_-01.json",
1053 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_number_-1.0..json",
1054 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_number_-2..json",
1055 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_number_-NaN.json",
1056 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_number_.-1.json",
1057 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_number_.2e-3.json",
1058 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_number_0.1.2.json",
1059 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_number_0.3e+.json",
1060 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_number_0.3e.json",
1061 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_number_0.e1.json",
1062 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_number_0_capital_E+.json",
1063 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_number_0_capital_E.json",
1064 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_number_0e+.json",
1065 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_number_0e.json",
1066 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_number_1.0e+.json",
1067 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_number_1.0e-.json",
1068 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_number_1.0e.json",
1069 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_number_1_000.json",
1070 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_number_1eE2.json",
1071 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_number_2.e+3.json",
1072 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_number_2.e-3.json",
1073 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_number_2.e3.json",
1074 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_number_9.e+.json",
1075 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_number_Inf.json",
1076 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_number_NaN.json",
1077 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_number_U+FF11_fullwidth_digit_one.json",
1078 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_number_expression.json",
1079 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_number_hex_1_digit.json",
1080 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_number_hex_2_digits.json",
1081 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_number_infinity.json",
1082 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_number_invalid+-.json",
1083 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_number_invalid-negative-real.json",
1084 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_number_invalid-utf-8-in-bigger-int.json",
1085 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_number_invalid-utf-8-in-exponent.json",
1086 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_number_invalid-utf-8-in-int.json",
1087 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_number_minus_infinity.json",
1088 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_number_minus_sign_with_trailing_garbage.json",
1089 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_number_minus_space_1.json",
1090 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_number_neg_int_starting_with_zero.json",
1091 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_number_neg_real_without_int_part.json",
1092 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_number_neg_with_garbage_at_end.json",
1093 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_number_real_garbage_after_e.json",
1094 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_number_real_with_invalid_utf8_after_e.json",
1095 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_number_real_without_fractional_part.json",
1096 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_number_starting_with_dot.json",
1097 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_number_with_alpha.json",
1098 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_number_with_alpha_char.json",
1099 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_number_with_leading_zero.json",
1100 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_object_bad_value.json",
1101 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_object_bracket_key.json",
1102 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_object_comma_instead_of_colon.json",
1103 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_object_double_colon.json",
1104 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_object_emoji.json",
1105 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_object_garbage_at_end.json",
1106 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_object_key_with_single_quotes.json",
1107 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_object_lone_continuation_byte_in_key_and_trailing_comma.json",
1108 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_object_missing_colon.json",
1109 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_object_missing_key.json",
1110 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_object_missing_semicolon.json",
1111 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_object_missing_value.json",
1112 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_object_no-colon.json",
1113 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_object_non_string_key.json",
1114 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_object_non_string_key_but_huge_number_instead.json",
1115 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_object_repeated_null_null.json",
1116 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_object_several_trailing_commas.json",
1117 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_object_single_quote.json",
1118 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_object_trailing_comma.json",
1119 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_object_trailing_comment.json",
1120 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_object_trailing_comment_open.json",
1121 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_object_trailing_comment_slash_open.json",
1122 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_object_trailing_comment_slash_open_incomplete.json",
1123 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_object_two_commas_in_a_row.json",
1124 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_object_unquoted_key.json",
1125 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_object_unterminated-value.json",
1126 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_object_with_single_string.json",
1127 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_object_with_trailing_garbage.json",
1128 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_single_space.json",
1129 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_string_1_surrogate_then_escape.json",
1130 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_string_1_surrogate_then_escape_u.json",
1131 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_string_1_surrogate_then_escape_u1.json",
1132 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_string_1_surrogate_then_escape_u1x.json",
1133 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_string_accentuated_char_no_quotes.json",
1134 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_string_backslash_00.json",
1135 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_string_escape_x.json",
1136 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_string_escaped_backslash_bad.json",
1137 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_string_escaped_ctrl_char_tab.json",
1138 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_string_escaped_emoji.json",
1139 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_string_incomplete_escape.json",
1140 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_string_incomplete_escaped_character.json",
1141 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_string_incomplete_surrogate.json",
1142 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_string_incomplete_surrogate_escape_invalid.json",
1143 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_string_invalid-utf-8-in-escape.json",
1144 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_string_invalid_backslash_esc.json",
1145 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_string_invalid_unicode_escape.json",
1146 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_string_invalid_utf8_after_escape.json",
1147 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_string_leading_uescaped_thinspace.json",
1148 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_string_no_quotes_with_bad_escape.json",
1149 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_string_single_doublequote.json",
1150 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_string_single_quote.json",
1151 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_string_single_string_no_double_quotes.json",
1152 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_string_start_escape_unclosed.json",
1153 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_string_unescaped_crtl_char.json",
1154 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_string_unescaped_newline.json",
1155 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_string_unescaped_tab.json",
1156 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_string_unicode_CapitalU.json",
1157 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_string_with_trailing_garbage.json",
1158 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_structure_U+2060_word_joined.json",
1159 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_structure_UTF8_BOM_no_data.json",
1160 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_structure_angle_bracket_..json",
1161 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_structure_angle_bracket_null.json",
1162 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_structure_array_trailing_garbage.json",
1163 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_structure_array_with_extra_array_close.json",
1164 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_structure_array_with_unclosed_string.json",
1165 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_structure_ascii-unicode-identifier.json",
1166 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_structure_capitalized_True.json",
1167 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_structure_close_unopened_array.json",
1168 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_structure_comma_instead_of_closing_brace.json",
1169 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_structure_double_array.json",
1170 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_structure_end_array.json",
1171 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_structure_incomplete_UTF8_BOM.json",
1172 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_structure_lone-invalid-utf-8.json",
1173 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_structure_lone-open-bracket.json",
1174 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_structure_no_data.json",
1175 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_structure_null-byte-outside-string.json",
1176 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_structure_number_with_trailing_garbage.json",
1177 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_structure_object_followed_by_closing_object.json",
1178 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_structure_object_unclosed_no_value.json",
1179 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_structure_object_with_comment.json",
1180 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_structure_object_with_trailing_garbage.json",
1181 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_structure_open_array_apostrophe.json",
1182 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_structure_open_array_comma.json",
1183 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_structure_open_array_open_object.json",
1184 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_structure_open_array_open_string.json",
1185 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_structure_open_array_string.json",
1186 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_structure_open_object.json",
1187 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_structure_open_object_close_array.json",
1188 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_structure_open_object_comma.json",
1189 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_structure_open_object_open_array.json",
1190 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_structure_open_object_open_string.json",
1191 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_structure_open_object_string_with_apostrophes.json",
1192 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_structure_open_open.json",
1193 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_structure_single_eacute.json",
1194 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_structure_single_star.json",
1195 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_structure_trailing_#.json",
1196 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_structure_uescaped_LF_before_string.json",
1197 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_structure_unclosed_array.json",
1198 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_structure_unclosed_array_partial_null.json",
1199 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_structure_unclosed_array_unfinished_false.json",
1200 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_structure_unclosed_array_unfinished_true.json",
1201 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_structure_unclosed_object.json",
1202 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_structure_unicode-identifier.json",
1203 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_structure_whitespace_U+2060_word_joiner.json",
1204 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_structure_whitespace_formfeed.json"
1205 }
1206 )
1207 {
1208 CAPTURE(filename)
1209 std::ifstream f(filename);
1210 json _;
1211 CHECK_THROWS_AS(_ = json::parse(f), json::parse_error&);
1212 std::ifstream f2(filename);
1213 CHECK(!json::accept(f2));
1214 }
1215 }
1216
1217 SECTION("n (previously overflowed)")
1218 {
1219 for (const auto* filename :
1220 {
1221 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_structure_100000_opening_arrays.json",
1222 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_structure_open_array_object.json"
1223 }
1224 )
1225 {
1226 CAPTURE(filename)
1227 std::ifstream f(filename);
1228 CHECK(!json::accept(f));
1229 }
1230 }
1231
1232 SECTION("i -> y")
1233 {
1234 for (const auto* filename :
1235 {
1236 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/i_number_double_huge_neg_exp.json",
1237 //TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/i_number_huge_exp.json",
1238 //TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/i_number_neg_int_huge_exp.json",
1239 //TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/i_number_pos_double_huge_exp.json",
1240 //TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/i_number_real_neg_overflow.json",
1241 //TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/i_number_real_pos_overflow.json",
1242 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/i_number_real_underflow.json",
1243 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/i_number_too_big_neg_int.json",
1244 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/i_number_too_big_pos_int.json",
1245 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/i_number_very_big_negative_int.json",
1246 //TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/i_object_key_lone_2nd_surrogate.json",
1247 //TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/i_string_1st_surrogate_but_2nd_missing.json",
1248 //TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/i_string_1st_valid_surrogate_2nd_invalid.json",
1249 //TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/i_string_UTF-16LE_with_BOM.json",
1250 //TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/i_string_UTF-8_invalid_sequence.json",
1251 //TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/i_string_UTF8_surrogate_U+D800.json",
1252 //TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/i_string_incomplete_surrogate_and_escape_valid.json",
1253 //TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/i_string_incomplete_surrogate_pair.json",
1254 //TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/i_string_incomplete_surrogates_escape_valid.json",
1255 //TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/i_string_invalid_lonely_surrogate.json",
1256 //TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/i_string_invalid_surrogate.json",
1257 //TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/i_string_invalid_utf-8.json",
1258 //TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/i_string_inverted_surrogates_U+1D11E.json",
1259 //TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/i_string_iso_latin_1.json",
1260 //TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/i_string_lone_second_surrogate.json",
1261 //TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/i_string_lone_utf8_continuation_byte.json",
1262 //TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/i_string_not_in_unicode_range.json",
1263 //TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/i_string_overlong_sequence_2_bytes.json",
1264 //TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/i_string_overlong_sequence_6_bytes.json",
1265 //TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/i_string_overlong_sequence_6_bytes_null.json",
1266 //TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/i_string_truncated-utf-8.json",
1267 //TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/i_string_utf16BE_no_BOM.json",
1268 //TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/i_string_utf16LE_no_BOM.json",
1269 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/i_structure_500_nested_arrays.json",
1270 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/i_structure_UTF-8_BOM_empty_object.json"
1271 }
1272 )
1273 {
1274 CAPTURE(filename)
1275 std::ifstream f(filename);
1276 json _;
1277 CHECK_NOTHROW(_ = json::parse(f));
1278 std::ifstream f2(filename);
1279 CHECK(json::accept(f2));
1280 }
1281 }
1282
1283 SECTION("i -> n")
1284 {
1285 for (const auto* filename :
1286 {
1287 //TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/i_number_double_huge_neg_exp.json",
1288 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/i_number_huge_exp.json",
1289 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/i_number_neg_int_huge_exp.json",
1290 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/i_number_pos_double_huge_exp.json",
1291 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/i_number_real_neg_overflow.json",
1292 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/i_number_real_pos_overflow.json",
1293 //TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/i_number_real_underflow.json",
1294 //TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/i_number_too_big_neg_int.json",
1295 //TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/i_number_too_big_pos_int.json",
1296 //TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/i_number_very_big_negative_int.json",
1297 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/i_object_key_lone_2nd_surrogate.json",
1298 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/i_string_1st_surrogate_but_2nd_missing.json",
1299 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/i_string_1st_valid_surrogate_2nd_invalid.json",
1300 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/i_string_UTF-16LE_with_BOM.json",
1301 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/i_string_UTF-8_invalid_sequence.json",
1302 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/i_string_UTF8_surrogate_U+D800.json",
1303 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/i_string_incomplete_surrogate_and_escape_valid.json",
1304 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/i_string_incomplete_surrogate_pair.json",
1305 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/i_string_incomplete_surrogates_escape_valid.json",
1306 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/i_string_invalid_lonely_surrogate.json",
1307 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/i_string_invalid_surrogate.json",
1308 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/i_string_invalid_utf-8.json",
1309 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/i_string_inverted_surrogates_U+1D11E.json",
1310 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/i_string_iso_latin_1.json",
1311 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/i_string_lone_second_surrogate.json",
1312 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/i_string_lone_utf8_continuation_byte.json",
1313 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/i_string_not_in_unicode_range.json",
1314 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/i_string_overlong_sequence_2_bytes.json",
1315 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/i_string_overlong_sequence_6_bytes.json",
1316 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/i_string_overlong_sequence_6_bytes_null.json",
1317 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/i_string_truncated-utf-8.json",
1318 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/i_string_utf16BE_no_BOM.json",
1319 TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/i_string_utf16LE_no_BOM.json",
1320 //TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/i_structure_500_nested_arrays.json",
1321 //TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/i_structure_UTF-8_BOM_empty_object.json"
1322 }
1323 )
1324 {
1325 CAPTURE(filename)
1326 std::ifstream f(filename);
1327 json _;
1328 CHECK_THROWS_AS(_ = json::parse(f), json::exception&); // could be parse_error or out_of_range
1329 std::ifstream f2(filename);
1330 CHECK(!json::accept(f2));
1331 }
1332 }
1333 }
1334 }
1335
1336 namespace
1337 {
1338 std::string trim(const std::string& str);
1339
1340 // from https://stackoverflow.com/a/25829178/266378
trim(const std::string & str)1341 std::string trim(const std::string& str)
1342 {
1343 size_t first = str.find_first_not_of(' ');
1344 if (std::string::npos == first)
1345 {
1346 return str;
1347 }
1348 size_t last = str.find_last_not_of(' ');
1349 return str.substr(first, (last - first + 1));
1350 }
1351 } // namespace
1352
1353 TEST_CASE("Big List of Naughty Strings")
1354 {
1355 // test from https://github.com/minimaxir/big-list-of-naughty-strings
1356 SECTION("parsing blns.json")
1357 {
1358 std::ifstream f(TEST_DATA_DIRECTORY "/big-list-of-naughty-strings/blns.json");
1359 json j;
1360 CHECK_NOTHROW(f >> j);
1361 }
1362
1363 // check if parsed strings roundtrip
1364 // https://www.reddit.com/r/cpp/comments/5qpbie/json_form_modern_c_version_210/dd12mpq/
1365 SECTION("roundtripping")
1366 {
1367 std::ifstream f(TEST_DATA_DIRECTORY "/big-list-of-naughty-strings/blns.json");
1368 std::string line;
1369
1370 // read lines one by one, bail out on error or eof
1371 while (getline(f, line))
1372 {
1373 // trim whitespace
1374 line = trim(line);
1375
1376 // remove trailing comma
1377 line = line.substr(0, line.find_last_of(','));
1378
1379 // discard lines without at least two characters (quotes)
1380 if (line.size() < 2)
1381 {
1382 continue;
1383 }
1384
1385 // check roundtrip
1386 CAPTURE(line)
1387 json j = json::parse(line);
1388 CHECK(j.dump() == line);
1389 }
1390 }
1391 }
1392