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