28 RAPIDJSON_DIAG_OFF(effc++)
29 RAPIDJSON_DIAG_OFF(
float-equal)
30 RAPIDJSON_DIAG_OFF(missing-noreturn)
32 RAPIDJSON_DIAG_OFF(dangling-
else)
37 RAPIDJSON_DIAG_OFF(variadic-macros)
38 RAPIDJSON_DIAG_OFF(c++98-compat-pedantic)
71 bool Int(
int i) { actual_ = i; step_++;
return true; }
80 bool Uint(
unsigned i) { actual_ = i; step_++;
return true; }
107 bool Double(
double d) { actual_ = d; step_++;
return true; }
114 #define TEST_INTEGER(Handler, str, x) \ 116 StringStream s(str); \ 119 reader.Parse(s, h); \ 120 EXPECT_EQ(1u, h.step_); \ 121 EXPECT_EQ(x, h.actual_); \ 146 for (
unsigned i = 0; i < 100000; i++) {
168 for (
unsigned i = 0; i < 100000; i++) {
178 if (u.i < -
int64_t(2147483648u)) {
187 template<
bool fullPrecision>
188 static void TestParseDouble() {
189 #define TEST_DOUBLE(fullPrecision, str, x) \ 191 StringStream s(str); \ 192 ParseDoubleHandler h; \ 194 ASSERT_EQ(kParseErrorNone, reader.Parse<fullPrecision ? kParseFullPrecisionFlag : 0>(s, h).Code()); \ 195 EXPECT_EQ(1u, h.step_); \ 196 internal::Double e(x), a(h.actual_); \ 197 if (fullPrecision) { \ 198 EXPECT_EQ(e.Uint64Value(), a.Uint64Value()); \ 199 if (e.Uint64Value() != a.Uint64Value()) \ 200 printf(" String: %s\n Actual: %.17g\nExpected: %.17g\n", str, h.actual_, x); \ 203 EXPECT_EQ(e.Sign(), a.Sign()); \ 204 EXPECT_DOUBLE_EQ(x, h.actual_); \ 224 TEST_DOUBLE(fullPrecision,
"1.234E+10", 1.234E+10);
225 TEST_DOUBLE(fullPrecision,
"1.234E-10", 1.234E-10);
226 TEST_DOUBLE(fullPrecision,
"1.79769e+308", 1.79769e+308);
227 TEST_DOUBLE(fullPrecision,
"2.22507e-308", 2.22507e-308);
228 TEST_DOUBLE(fullPrecision,
"-1.79769e+308", -1.79769e+308);
229 TEST_DOUBLE(fullPrecision,
"-2.22507e-308", -2.22507e-308);
230 TEST_DOUBLE(fullPrecision,
"4.9406564584124654e-324", 4.9406564584124654e-324);
231 TEST_DOUBLE(fullPrecision,
"2.2250738585072009e-308", 2.2250738585072009e-308);
232 TEST_DOUBLE(fullPrecision,
"2.2250738585072014e-308", 2.2250738585072014e-308);
233 TEST_DOUBLE(fullPrecision,
"1.7976931348623157e+308", 1.7976931348623157e+308);
235 TEST_DOUBLE(fullPrecision,
"18446744073709551616", 18446744073709551616.0);
236 TEST_DOUBLE(fullPrecision,
"-9223372036854775809", -9223372036854775809.0);
237 TEST_DOUBLE(fullPrecision,
"0.9868011474609375", 0.9868011474609375);
239 TEST_DOUBLE(fullPrecision,
"45913141877270640000.0", 45913141877270640000.0);
240 TEST_DOUBLE(fullPrecision,
"2.2250738585072011e-308", 2.2250738585072011e-308);
241 TEST_DOUBLE(fullPrecision,
"1e-00011111111111", 0.0);
242 TEST_DOUBLE(fullPrecision,
"-1e-00011111111111", -0.0);
246 TEST_DOUBLE(fullPrecision,
"1.00000000001e-2147483638", 0.0);
247 TEST_DOUBLE(fullPrecision,
"0.017976931348623157e+310", 1.7976931348623157e+308);
248 TEST_DOUBLE(fullPrecision,
"128.74836467836484838364836483643636483648e-336", 0.0);
254 TEST_DOUBLE(fullPrecision,
"2.2250738585072012e-308", 2.2250738585072014e-308);
258 TEST_DOUBLE(fullPrecision,
"2.22507385850720113605740979670913197593481954635164564e-308", 2.2250738585072009e-308);
259 TEST_DOUBLE(fullPrecision,
"2.22507385850720113605740979670913197593481954635164565e-308", 2.2250738585072014e-308);
263 TEST_DOUBLE(fullPrecision,
"0.999999999999999944488848768742172978818416595458984375", 1.0);
264 TEST_DOUBLE(fullPrecision,
"0.999999999999999944488848768742172978818416595458984374", 0.99999999999999989);
265 TEST_DOUBLE(fullPrecision,
"0.999999999999999944488848768742172978818416595458984376", 1.0);
267 TEST_DOUBLE(fullPrecision,
"1.00000000000000011102230246251565404236316680908203125", 1.0);
268 TEST_DOUBLE(fullPrecision,
"1.00000000000000011102230246251565404236316680908203124", 1.0);
269 TEST_DOUBLE(fullPrecision,
"1.00000000000000011102230246251565404236316680908203126", 1.00000000000000022);
273 TEST_DOUBLE(fullPrecision,
"72057594037927928.0", 72057594037927928.0);
274 TEST_DOUBLE(fullPrecision,
"72057594037927936.0", 72057594037927936.0);
275 TEST_DOUBLE(fullPrecision,
"72057594037927932.0", 72057594037927936.0);
276 TEST_DOUBLE(fullPrecision,
"7205759403792793199999e-5", 72057594037927928.0);
277 TEST_DOUBLE(fullPrecision,
"7205759403792793200001e-5", 72057594037927936.0);
279 TEST_DOUBLE(fullPrecision,
"9223372036854774784.0", 9223372036854774784.0);
280 TEST_DOUBLE(fullPrecision,
"9223372036854775808.0", 9223372036854775808.0);
281 TEST_DOUBLE(fullPrecision,
"9223372036854775296.0", 9223372036854775808.0);
282 TEST_DOUBLE(fullPrecision,
"922337203685477529599999e-5", 9223372036854774784.0);
283 TEST_DOUBLE(fullPrecision,
"922337203685477529600001e-5", 9223372036854775808.0);
285 TEST_DOUBLE(fullPrecision,
"10141204801825834086073718800384", 10141204801825834086073718800384.0);
286 TEST_DOUBLE(fullPrecision,
"10141204801825835211973625643008", 10141204801825835211973625643008.0);
287 TEST_DOUBLE(fullPrecision,
"10141204801825834649023672221696", 10141204801825835211973625643008.0);
288 TEST_DOUBLE(fullPrecision,
"1014120480182583464902367222169599999e-5", 10141204801825834086073718800384.0);
289 TEST_DOUBLE(fullPrecision,
"1014120480182583464902367222169600001e-5", 10141204801825835211973625643008.0);
291 TEST_DOUBLE(fullPrecision,
"5708990770823838890407843763683279797179383808", 5708990770823838890407843763683279797179383808.0);
292 TEST_DOUBLE(fullPrecision,
"5708990770823839524233143877797980545530986496", 5708990770823839524233143877797980545530986496.0);
293 TEST_DOUBLE(fullPrecision,
"5708990770823839207320493820740630171355185152", 5708990770823839524233143877797980545530986496.0);
294 TEST_DOUBLE(fullPrecision,
"5708990770823839207320493820740630171355185151999e-3", 5708990770823838890407843763683279797179383808.0);
295 TEST_DOUBLE(fullPrecision,
"5708990770823839207320493820740630171355185152001e-3", 5708990770823839524233143877797980545530986496.0);
300 for (
int i = 1; i < 309; i++)
308 "2.22507385850720113605740979670913197593481954635164564802342610972482222202107694551652952390813508" 309 "7914149158913039621106870086438694594645527657207407820621743379988141063267329253552286881372149012" 310 "9811224514518898490572223072852551331557550159143974763979834118019993239625482890171070818506906306" 311 "6665599493827577257201576306269066333264756530000924588831643303777979186961204949739037782970490505" 312 "1080609940730262937128958950003583799967207254304360284078895771796150945516748243471030702609144621" 313 "5722898802581825451803257070188608721131280795122334262883686223215037756666225039825343359745688844" 314 "2390026549819838548794829220689472168983109969836584681402285424333066033985088644580400103493397042" 315 "7567186443383770486037861622771738545623065874679014086723327636718751234567890123456789012345678901" 317 2.2250738585072014e-308);
320 static const unsigned count = 100;
325 for (
uint64_t exp = 0; exp < 2047; exp++) {
327 for (
unsigned i = 0; i <
count; i++) {
344 printf(
" String: %s\n Actual: %.17g\nExpected: %.17g\n", buffer, h.
actual_, d.
Value());
355 TEST_DOUBLE(fullPrecision,
"7.450580596923828e-9", 7.450580596923828e-9);
358 for (
int i = 0; i < 324; i++) {
371 printf(
" String: %s\n Actual: %.17g\nExpected: %.17g\n", buffer, h.
actual_, d.
Value());
387 TEST_DOUBLE(fullPrecision,
"128.74836467836484838364836483643636483648e-336", 0.0);
391 "6223372036854775296.1701512723685473547372536854755293372036854685477" 392 "529752233737201701512337200972013723685473123372036872036854236854737" 393 "247372368372367752975258547752975254729752547372368737201701512354737" 394 "83723677529752585477247372368372368547354737253685475529752",
395 6223372036854775808.0);
402 TEST_DOUBLE(fullPrecision,
"0e+9223372036854775807", 0.0);
403 TEST_DOUBLE(fullPrecision,
"0e-9223372036854775808", 0.0);
411 TEST_DOUBLE(fullPrecision,
"2.4703282292062327e-324", 0.0);
412 TEST_DOUBLE(fullPrecision,
"2.4703282292062328e-324", 5e-324);
417 TEST_DOUBLE(fullPrecision,
"1.7976931348623158e+308", 1.7976931348623158e+308);
420 "17976931348623157081452742373170435679807056752584499659891747680315726" 421 "07800285387605895586327668781715404589535143824642343213268894641827684" 422 "67546703537516986049910576551282076245490090389328944075868508455133942" 423 "30458323690322294816580855933212334827479782620414472316873817718091929" 424 "9881250404026184124858368",
425 std::numeric_limits<double>::max());
428 "243546080556034731077856379609316893158278902575447060151047" 429 "212703405344938119816206067372775299130836050315842578309818" 430 "316450894337978612745889730079163798234256495613858256849283" 431 "467066859489192118352020514036083287319232435355752493038825" 432 "828481044358810649108367633313557305310641892225870327827273" 434 2.4354608055603473e+307);
437 "1.797693134862315708145274237317043567980705675258449965989174768031572607800285" 438 "38760589558632766878171540458953514382464234321326889464182768467546703537516986" 439 "04991057655128207624549009038932894407586850845513394230458323690322294816580855" 440 "9332123348274797826204144723168738177180919299881250404026184124858368e+308",
441 1.797693134862315708e+308
447 "0.00000000000000000000000000000000000000000000000000000000000" 448 "0000000000000000000000000000000000000000000000000000000000000" 449 "0000000000000000000000000000000000000000000000000000000000000" 450 "0000000000000000000000000000000000000000000000000000000000000" 451 "0000000000000000000000000000000000000000000000000000000000000" 452 "0000000000000000000024703282292062327208828439643411068618252" 453 "9901307162382212792841250337753635104375932649918180817996189" 454 "8982823477228588654633283551779698981993873980053909390631503" 455 "5659515570226392290858392449105184435931802849936536152500319" 456 "3704576782492193656236698636584807570015857692699037063119282" 457 "7955855133292783433840935197801553124659726357957462276646527" 458 "2827220056374006485499977096599470454020828166226237857393450" 459 "7363390079677619305775067401763246736009689513405355374585166" 460 "6113422376667860416215968046191446729184030053005753084904876" 461 "5391711386591646239524912623653881879636239373280423891018672" 462 "3484976682350898633885879256283027559956575244555072551893136" 463 "9083625477918694866799496832404970582102851318545139621383772" 464 "2826145437693412532098591327667236328125",
469 "4.450147717014402272114819593418263951869639092703291296046852219449644444042153" 470 "89103305904781627017582829831782607924221374017287738918929105531441481564124348" 471 "67599762821265346585071045737627442980259622449029037796981144446145705102663115" 472 "10031828794952795966823603998647925096578034214163701381261333311989876551545144" 473 "03152612538132666529513060001849177663286607555958373922409899478075565940981010" 474 "21612198814605258742579179000071675999344145086087205681577915435923018910334964" 475 "86942061405218289243144579760516365090360651414037721744226256159024466852576737" 476 "24464300755133324500796506867194913776884780053099639677097589658441378944337966" 477 "21993967316936280457084866613206797017728916080020698679408551343728867675409720" 478 "757232455434770912461317493580281734466552734375e-308",
479 4.450147717014402272e-308
483 "4.450147717014401778049173752171719775300846224481918930987049605124880018456471" 484 "39035755177760751831052846195619008686241717547743167145836439860405887584484471" 485 "19639655002484083577939142623582164522087943959208000909794783876158397872163051" 486 "22622675229968408654350206725478309956546318828765627255022767720818849892988457" 487 "26333908582101604036318532842699932130356061901518261174396928478121372742040102" 488 "17446565569357687263889031732270082446958029584739170416643195242132750803227473" 489 "16608838720742955671061336566907126801014814608027120593609275183716632624844904" 490 "31985250929886016737037234388448352929102742708402644340627409931664203093081360" 491 "70794835812045179006047003875039546061891526346421705014598610179523165038319441" 492 "51446491086954182492263498716056346893310546875e-308",
493 4.450147717014401778e-308
498 "4.450147717014402025081996672794991863585242658592605113516950912287262231249312" 499 "64069530541271189424317838013700808305231545782515453032382772695923684574304409" 500 "93619708911874715081505094180604803751173783204118519353387964161152051487413083" 501 "16327252012460602310586905362063117526562176521464664318142050516404363222266800" 502 "64743260560117135282915796422274554896821334728738317548403413978098469341510556" 503 "19529382191981473003234105366170879223151087335413188049110555339027884856781219" 504 "01775450062980622457102958163711745945687733011032421168917765671370549738710820" 505 "78224775842509670618916870627821633352993761380751142008862499795052791018709663" 506 "46394401564490729731565935244123171539810221213221201847003580761626016356864581" 507 "1358486831521563686919762403704226016998291015625e-308",
508 4.450147717014401778e-308
511 "4.450147717014402025081996672794991863585242658592605113516950912287262231249312" 512 "64069530541271189424317838013700808305231545782515453032382772695923684574304409" 513 "93619708911874715081505094180604803751173783204118519353387964161152051487413083" 514 "16327252012460602310586905362063117526562176521464664318142050516404363222266800" 515 "64743260560117135282915796422274554896821334728738317548403413978098469341510556" 516 "19529382191981473003234105366170879223151087335413188049110555339027884856781219" 517 "01775450062980622457102958163711745945687733011032421168917765671370549738710820" 518 "78224775842509670618916870627821633352993761380751142008862499795052791018709663" 519 "46394401564490729731565935244123171539810221213221201847003580761626016356864581" 520 "13584868315215636869197624037042260169982910156250000000000000000000000000000000" 521 "00000000000000000000000000000000000000000000000000000000000000000000000000000000" 522 "00000000000000000000000000000000000000000000000000000000000000000000000000000000e-308",
523 4.450147717014401778e-308
530 "4.450147717014402025081996672794991863585242658592605113516950912287262231249312" 531 "64069530541271189424317838013700808305231545782515453032382772695923684574304409" 532 "93619708911874715081505094180604803751173783204118519353387964161152051487413083" 533 "16327252012460602310586905362063117526562176521464664318142050516404363222266800" 534 "64743260560117135282915796422274554896821334728738317548403413978098469341510556" 535 "19529382191981473003234105366170879223151087335413188049110555339027884856781219" 536 "01775450062980622457102958163711745945687733011032421168917765671370549738710820" 537 "78224775842509670618916870627821633352993761380751142008862499795052791018709663" 538 "46394401564490729731565935244123171539810221213221201847003580761626016356864581" 539 "13584868315215636869197624037042260169982910156250000000000000000000000000000000" 540 "00000000000000000000000000000000000000000000000000000000000000000000000000000000" 541 "00000000000000000000000000000000000000000000000000000000000000000000000000000001e-308",
542 4.450147717014402272e-308
547 "4.450147717014402025081996672794991863585242658592605113516950912287262231249312" 548 "64069530541271189424317838013700808305231545782515453032382772695923684574304409" 549 "93619708911874715081505094180604803751173783204118519353387964161152051487413083" 550 "16327252012460602310586905362063117526562176521464664318142050516404363222266800" 551 "64743260560117135282915796422274554896821334728738317548403413978098469341510556" 552 "19529382191981473003234105366170879223151087335413188049110555339027884856781219" 553 "01775450062980622457102958163711745945687733011032421168917765671370549738710820" 554 "78224775842509670618916870627821633352993761380751142008862499795052791018709663" 555 "46394401564490729731565935244123171539810221213221201847003580761626016356864581" 556 "13584868315215636869197624037042260169982910156249999999999999999999999999999999" 557 "99999999999999999999999999999999999999999999999999999999999999999999999999999999" 558 "99999999999999999999999999999999999999999999999999999999999999999999999999999999e-308",
559 4.450147717014401778e-308
564 "1.797693134862315807937289714053034150799341327100378269361737789804449682927647" 565 "50946649017977587207096330286416692887910946555547851940402630657488671505820681" 566 "90890200070838367627385484581771153176447573027006985557136695962284291481986083" 567 "49364752927190741684443655107043427115596995080930428801779041744977919999999999" 568 "99999999999999999999999999999999999999999999999999999999999999999999999999999999" 569 "99999999999999999999999999999999999999999999999999999999999999999999999999999999" 570 "99999999999999999999999999999999999999999999999999999999999999999999999999999999" 571 "99999999999999999999999999999999999999999999999999999999999999999999999999999999" 572 "99999999999999999999999999999999999999999999999999999999999999999999999999999999" 573 "99999999999999999999999999999999999999999999999999999999999999999999999999999999" 574 "99999999999999999999999999999999999999999999999999999999999999999999999999999999" 575 "99999999999999999999999999999999999999999999999999999999999999999999999999999999" 576 "99999999999999999999999999999999999999999999999999999999999999999999999999999999" 577 "99999999999999999999999999999999999999999999999999999999999999999999999999999999" 578 "99999999999999999999999999999999999999999999999999999999999999999999999999999999" 579 "99999999999999999999999999999999999999999999999999999999999999999999999999999999e+308",
580 1.797693134862315708e+308
588 TestParseDouble<false>();
592 TestParseDouble<true>();
596 static unsigned count = 1000000;
601 for (
unsigned i = 0; i <
count; i++) {
622 double ulp =
static_cast<double>(bias1 >= bias2 ? bias1 - bias2 : bias2 - bias1);
623 ulpMax = (std::max)(ulpMax, ulp);
626 printf(
"ULP Average = %g, Max = %g \n", ulpSum /
count, ulpMax);
629 template<
bool fullPrecision>
630 static void TestParseNumberError() {
631 #define TEST_NUMBER_ERROR(errorCode, str, errorOffset, streamPos) \ 634 ASSERT_LT(std::strlen(str), 2048u); \ 635 sprintf(buffer, "%s", str); \ 636 InsituStringStream s(buffer); \ 637 BaseReaderHandler<> h; \ 639 EXPECT_FALSE(reader.Parse<fullPrecision ? kParseFullPrecisionFlag : 0>(s, h)); \ 640 EXPECT_EQ(errorCode, reader.GetParseErrorCode());\ 641 EXPECT_EQ(errorOffset, reader.GetErrorOffset());\ 642 EXPECT_EQ(streamPos, s.Tell());\ 649 for (
int i = 1; i < 310; i++)
678 "88474320368547737236837236775298547354737253685475547552933720368546854775297525" 679 "29337203685468547770151233720097201372368547312337203687203685423685123372036872" 680 "03685473724737236837236775297525854775297525472975254737236873720170151235473783" 681 "7236737247372368772473723683723456789012E66", 0, 283);
693 "1.797693134862315907729305190789024733617976978942306572734300811577326758055009" 694 "63132708477322407536021120113879871393357658789768814416622492847430639474124377" 695 "76789342486548527630221960124609411945308295208500576883815068234246288147391311" 696 "0540827237163350510684586298239947245938479716304835356329624224137216e+308", 0, 315);
705 "1.797693134862315807937289714053034150799341327100378269361737789804449682927647" 706 "50946649017977587207096330286416692887910946555547851940402630657488671505820681" 707 "90890200070838367627385484581771153176447573027006985557136695962284291481986083" 708 "49364752927190741684443655107043427115596995080930428801779041744977920000000000" 709 "00000000000000000000000000000000000000000000000000000000000000000000000000000000" 710 "00000000000000000000000000000000000000000000000000000000000000000000000000000000" 711 "00000000000000000000000000000000000000000000000000000000000000000000000000000000" 712 "00000000000000000000000000000000000000000000000000000000000000000000000000000000" 713 "00000000000000000000000000000000000000000000000000000000000000000000000000000000" 714 "00000000000000000000000000000000000000000000000000000000000000000000000000000000" 715 "00000000000000000000000000000000000000000000000000000000000000000000000000000000" 716 "00000000000000000000000000000000000000000000000000000000000000000000000000000000" 717 "00000000000000000000000000000000000000000000000000000000000000000000000000000000" 718 "00000000000000000000000000000000000000000000000000000000000000000000000000000000e+308", 0, 1125);
721 "1.797693134862315807937289714053034150799341327100378269361737789804449682927647" 722 "50946649017977587207096330286416692887910946555547851940402630657488671505820681" 723 "90890200070838367627385484581771153176447573027006985557136695962284291481986083" 724 "49364752927190741684443655107043427115596995080930428801779041744977920000000000" 725 "00000000000000000000000000000000000000000000000000000000000000000000000000000000" 726 "00000000000000000000000000000000000000000000000000000000000000000000000000000000" 727 "00000000000000000000000000000000000000000000000000000000000000000000000000000000" 728 "00000000000000000000000000000000000000000000000000000000000000000000000000000000" 729 "00000000000000000000000000000000000000000000000000000000000000000000000000000000" 730 "00000000000000000000000000000000000000000000000000000000000000000000000000000000" 731 "00000000000000000000000000000000000000000000000000000000000000000000000000000000" 732 "00000000000000000000000000000000000000000000000000000000000000000000000000000000" 733 "00000000000000000000000000000000000000000000000000000000000000000000000000000000" 734 "00000000000000000000000000000000000000000000000000000000000000000000000000000000" 735 "00000000000000000000000000000000000000000000000000000000000000000000000000000001e+308", 0, 1205);
739 "10000000000000000000000000000000000000000000000000000000000000000000000000000000" 740 "00000000000000000000000000000000000000000000000000000000000000000000000000000000" 741 "00000000000000000000000000000000000000000000000000000000000000000000000000000000" 742 "0000000000000000000000000000000000000000000000000000000000000000000001", 0, 310);
744 #undef TEST_NUMBER_ERROR 748 TestParseNumberError<false>();
752 TestParseNumberError<true>();
755 template <
typename Encoding>
768 memcpy(const_cast<typename Encoding::Ch*>(str_), str, (length + 1) *
sizeof(
typename Encoding::Ch));
783 #define TEST_STRING(Encoding, e, x) \ 785 Encoding::Ch* buffer = StrDup(x); \ 786 GenericInsituStringStream<Encoding> is(buffer); \ 787 ParseStringHandler<Encoding> h; \ 788 GenericReader<Encoding, Encoding> reader; \ 789 reader.Parse<kParseInsituFlag | kParseValidateEncodingFlag>(is, h); \ 790 EXPECT_EQ(0, StrCmp<Encoding::Ch>(e, h.str_)); \ 791 EXPECT_EQ(StrLen(e), h.length_); \ 793 GenericStringStream<Encoding> s(x); \ 794 ParseStringHandler<Encoding> h2; \ 795 GenericReader<Encoding, Encoding> reader2; \ 796 reader2.Parse(s, h2); \ 797 EXPECT_EQ(0, StrCmp<Encoding::Ch>(e, h2.str_)); \ 798 EXPECT_EQ(StrLen(e), h2.length_); \ 805 #define ARRAY(...) { __VA_ARGS__ } 806 #define TEST_STRINGARRAY(Encoding, utype, array, x) \ 808 static const utype ue[] = array; \ 809 static const Encoding::Ch* e = reinterpret_cast<const Encoding::Ch *>(&ue[0]); \ 810 TEST_STRING(Encoding, e, x); \ 813 #define TEST_STRINGARRAY2(Encoding, utype, earray, xarray) \ 815 static const utype ue[] = earray; \ 816 static const utype xe[] = xarray; \ 817 static const Encoding::Ch* e = reinterpret_cast<const Encoding::Ch *>(&ue[0]); \ 818 static const Encoding::Ch* x = reinterpret_cast<const Encoding::Ch *>(&xe[0]); \ 819 TEST_STRING(Encoding, e, x); \ 843 TEST_STRINGARRAY2(
UTF32<>,
unsigned,
ARRAY(
'H',
'e',
'l',
'l',
'o',
'\0'),
ARRAY(
'\"',
'H',
'e',
'l',
'l',
'o',
'\"',
'\0'));
844 TEST_STRINGARRAY2(
UTF32<>,
unsigned,
ARRAY(
'H',
'e',
'l',
'l',
'o',
'\n',
'W',
'o',
'r',
'l',
'd',
'\0'),
ARRAY(
'\"',
'H',
'e',
'l',
'l',
'o',
'\\',
'n',
'W',
'o',
'r',
'l',
'd',
'\"',
'\0'));
845 TEST_STRINGARRAY2(
UTF32<>,
unsigned,
ARRAY(
'\"',
'\\',
'/',
'\b',
'\f',
'\n',
'\r',
'\t',
'\0'),
ARRAY(
'\"',
'\\',
'\"',
'\\',
'\\',
'/',
'\\',
'b',
'\\',
'f',
'\\',
'n',
'\\',
'r',
'\\',
't',
'\"',
'\0'));
846 TEST_STRINGARRAY2(
UTF32<>,
unsigned,
ARRAY(0x00024, 0x0000),
ARRAY(
'\"',
'\\',
'u',
'0',
'0',
'2',
'4',
'\"',
'\0'));
847 TEST_STRINGARRAY2(
UTF32<>,
unsigned,
ARRAY(0x000A2, 0x0000),
ARRAY(
'\"',
'\\',
'u',
'0',
'0',
'A',
'2',
'\"',
'\0'));
848 TEST_STRINGARRAY2(
UTF32<>,
unsigned,
ARRAY(0x020AC, 0x0000),
ARRAY(
'\"',
'\\',
'u',
'2',
'0',
'A',
'C',
'\"',
'\0'));
849 TEST_STRINGARRAY2(
UTF32<>,
unsigned,
ARRAY(0x1D11E, 0x0000),
ARRAY(
'\"',
'\\',
'u',
'D',
'8',
'3',
'4',
'\\',
'u',
'D',
'D',
'1',
'E',
'\"',
'\0'));
851 #undef TEST_STRINGARRAY 858 const char e[] =
"Hello\0World";
868 const char* x =
"\"Hello\"";
869 const wchar_t* e = L
"Hello";
879 const char* x =
"\"Hello\"";
880 const wchar_t* e = L
"Hello";
898 template <
typename Encoding>
903 reader.template Parse<kParseValidateEncodingFlag>(s, h);
908 #define TEST_STRING_ERROR(errorCode, str, errorOffset, streamPos)\ 910 GenericStringStream<UTF8<> > s(str);\ 911 BaseReaderHandler<UTF8<> > h;\ 912 GenericReader<UTF8<> , UTF8<> > reader;\ 913 reader.Parse<kParseValidateEncodingFlag>(s, h);\ 914 EXPECT_EQ(errorCode, reader.GetParseErrorCode());\ 915 EXPECT_EQ(errorOffset, reader.GetErrorOffset());\ 916 EXPECT_EQ(streamPos, s.Tell());\ 919 #define ARRAY(...) { __VA_ARGS__ } 920 #define TEST_STRINGENCODING_ERROR(Encoding, TargetEncoding, utype, array) \ 922 static const utype ue[] = array; \ 923 static const Encoding::Ch* e = reinterpret_cast<const Encoding::Ch *>(&ue[0]); \ 924 EXPECT_EQ(kParseErrorStringInvalidEncoding, TestString<Encoding>(e));\ 926 GenericStringStream<Encoding> s(e);\ 927 BaseReaderHandler<TargetEncoding> h;\ 928 GenericReader<Encoding, TargetEncoding> reader;\ 930 EXPECT_EQ(kParseErrorStringInvalidEncoding, reader.GetParseErrorCode());\ 956 char e[] = {
'[',
'\"', 0,
'\"',
']',
'\0' };
957 for (
unsigned char c = 0x80u; c <= 0xBFu; c++) {
958 e[2] =
static_cast<char>(c);
962 std::cout << static_cast<unsigned>(c) << std::endl;
968 char e[] = {
'[',
'\"', 0,
' ',
'\"',
']',
'\0' };
969 for (
unsigned c = 0xC0u; c <= 0xFFu; c++) {
970 e[2] =
static_cast<char>(c);
990 TEST_STRINGENCODING_ERROR(
UTF8<>,
UTF16<>,
unsigned char,
ARRAY(
'[',
'\"', 0xE0u, 0x80u, 0xAFu,
'\"',
']',
'\0'));
991 TEST_STRINGENCODING_ERROR(
UTF8<>,
UTF16<>,
unsigned char,
ARRAY(
'[',
'\"', 0xF0u, 0x80u, 0x80u, 0xAFu,
'\"',
']',
'\0'));
995 TEST_STRINGENCODING_ERROR(
UTF8<>,
UTF16<>,
unsigned char,
ARRAY(
'[',
'\"', 0xE0u, 0x9Fu, 0xBFu,
'\"',
']',
'\0'));
996 TEST_STRINGENCODING_ERROR(
UTF8<>,
UTF16<>,
unsigned char,
ARRAY(
'[',
'\"', 0xF0u, 0x8Fu, 0xBFu, 0xBFu,
'\"',
']',
'\0'));
1000 TEST_STRINGENCODING_ERROR(
UTF8<>,
UTF16<>,
unsigned char,
ARRAY(
'[',
'\"', 0xE0u, 0x80u, 0x80u,
'\"',
']',
'\0'));
1001 TEST_STRINGENCODING_ERROR(
UTF8<>,
UTF16<>,
unsigned char,
ARRAY(
'[',
'\"', 0xF0u, 0x80u, 0x80u, 0x80u,
'\"',
']',
'\0'));
1006 TEST_STRINGENCODING_ERROR(
UTF8<>,
UTF16<>,
unsigned char,
ARRAY(
'[',
'\"', 0xEDu, 0xA0u, 0x80u,
'\"',
']',
'\0'));
1007 TEST_STRINGENCODING_ERROR(
UTF8<>,
UTF16<>,
unsigned char,
ARRAY(
'[',
'\"', 0xEDu, 0xADu, 0xBFu,
'\"',
']',
'\0'));
1008 TEST_STRINGENCODING_ERROR(
UTF8<>,
UTF16<>,
unsigned char,
ARRAY(
'[',
'\"', 0xEDu, 0xAEu, 0x80u,
'\"',
']',
'\0'));
1009 TEST_STRINGENCODING_ERROR(
UTF8<>,
UTF16<>,
unsigned char,
ARRAY(
'[',
'\"', 0xEDu, 0xAFu, 0xBFu,
'\"',
']',
'\0'));
1010 TEST_STRINGENCODING_ERROR(
UTF8<>,
UTF16<>,
unsigned char,
ARRAY(
'[',
'\"', 0xEDu, 0xB0u, 0x80u,
'\"',
']',
'\0'));
1011 TEST_STRINGENCODING_ERROR(
UTF8<>,
UTF16<>,
unsigned char,
ARRAY(
'[',
'\"', 0xEDu, 0xBEu, 0x80u,
'\"',
']',
'\0'));
1012 TEST_STRINGENCODING_ERROR(
UTF8<>,
UTF16<>,
unsigned char,
ARRAY(
'[',
'\"', 0xEDu, 0xBFu, 0xBFu,
'\"',
']',
'\0'));
1027 #undef TEST_STRINGARRAY_ERROR 1030 template <
unsigned count>
1063 #define TEST_ARRAY_ERROR(errorCode, str, errorOffset) \ 1065 int streamPos = errorOffset; \ 1066 char buffer[1001]; \ 1067 strncpy(buffer, str, 1000); \ 1068 InsituStringStream s(buffer); \ 1069 BaseReaderHandler<> h; \ 1070 GenericReader<UTF8<>, UTF8<>, CrtAllocator> reader; \ 1071 EXPECT_FALSE(reader.Parse(s, h)); \ 1072 EXPECT_EQ(errorCode, reader.GetParseErrorCode());\ 1073 EXPECT_EQ(errorOffset, reader.GetErrorOffset());\ 1074 EXPECT_EQ(streamPos, s.Tell());\ 1086 #undef TEST_ARRAY_ERROR 1103 case 10:
EXPECT_EQ(123, i); step_++;
return true;
1104 case 15:
EXPECT_EQ(1, i); step_++;
return true;
1105 case 16:
EXPECT_EQ(2, i); step_++;
return true;
1106 case 17:
EXPECT_EQ(3, i); step_++;
return true;
1110 bool Uint(
unsigned i) {
return Int(static_cast<int>(i)); }
1114 case 1:
EXPECT_STREQ(
"hello", str); step_++;
return true;
1115 case 2:
EXPECT_STREQ(
"world", str); step_++;
return true;
1120 case 11:
EXPECT_STREQ(
"pi", str); step_++;
return true;
1134 const char*
json =
"{ \"hello\" : \"world\", \"t\" : true , \"f\" : false, \"n\": null, \"i\":123, \"pi\": 3.1416, \"a\":[1, 2, 3] } ";
1187 template <
unsigned parseFlags>
1201 TestMultipleRoot<kParseStopWhenDoneFlag>();
1205 TestMultipleRoot<kParseIterativeFlag | kParseStopWhenDoneFlag>();
1208 template <
unsigned parseFlags>
1210 char* buffer = strdup(
"{}[] a");
1224 TestInsituMultipleRoot<kParseStopWhenDoneFlag>();
1228 TestInsituMultipleRoot<kParseIterativeFlag | kParseStopWhenDoneFlag>();
1231 #define TEST_ERROR(errorCode, str, errorOffset) \ 1233 int streamPos = errorOffset; \ 1234 char buffer[1001]; \ 1235 strncpy(buffer, str, 1000); \ 1236 InsituStringStream s(buffer); \ 1237 BaseReaderHandler<> h; \ 1239 EXPECT_FALSE(reader.Parse(s, h)); \ 1240 EXPECT_EQ(errorCode, reader.GetParseErrorCode());\ 1241 EXPECT_EQ(errorOffset, reader.GetErrorOffset());\ 1242 EXPECT_EQ(streamPos, s.Tell());\ 1304 const char* expected =
"ABCDE";
1305 for (
size_t i = 0; i < 5; i++) {
1313 template <
typename Encoding>
1322 size_t Tell()
const {
return static_cast<size_t>(src_ - head_); }
1343 template <
typename Encoding>
1345 enum { copyOptimization = 1 };
1352 const char*
json =
"{ \"hello\" : \"world\", \"t\" : true , \"f\" : false, \"n\": null, \"i\":123, \"pi\": 3.1416, \"a\":[1, 2, 3] } ";
1370 return c == std::char_traits<char>::eof() ?
'\0' :
static_cast<Ch>(c);
1375 return c == std::char_traits<char>::eof() ?
'\0' :
static_cast<Ch>(c);
1378 size_t Tell()
const {
return static_cast<size_t>(is_.tellg()); }
1393 const char*
json =
"[1,2,3,4]";
1395 std::stringstream ss(
json);
1400 reader.
Parse(is, h);
1406 #define TESTERRORHANDLING(text, errorCode, offset)\ 1408 int streamPos = offset; \ 1409 StringStream json(text); \ 1410 BaseReaderHandler<> handler; \ 1412 reader.Parse<kParseIterativeFlag>(json, handler); \ 1413 EXPECT_TRUE(reader.HasParseError()); \ 1414 EXPECT_EQ(errorCode, reader.GetParseErrorCode()); \ 1415 EXPECT_EQ(offset, reader.GetErrorOffset()); \ 1416 EXPECT_EQ(streamPos, json.Tell()); \ 1453 template<
typename Encoding = UTF8<> >
1471 const static size_t LogCapacity = 256;
1503 Logs[LogCount++] = LOG_ENDOBJECT |
static_cast<uint32_t>(c);
1512 Logs[LogCount++] = LOG_ENDARRAY |
static_cast<uint32_t>(c);
1519 StringStream is(
"[1, {\"k\": [1, 2]}, null, false, true, \"string\", 1.2]");
1548 for (
size_t i = 0; i < handler.
LogCount; ++i) {
1583 for (
size_t i = 0; i < handler.
LogCount; ++i) {
1610 StringStream is(
"[1, {\"k\": [1, 2]}, null, false, true, \"string\", 1.2]");
1615 size_t oldLogCount = handler.
LogCount;
1616 EXPECT_TRUE(oldLogCount <
sizeof(e) /
sizeof(
int)) <<
"overrun";
1619 EXPECT_EQ(handler.
LogCount, oldLogCount + 1) <<
"handler should be invoked exactly once each time";
1620 EXPECT_EQ(e[oldLogCount], handler.
Logs[oldLogCount]) <<
"wrong event returned";
1624 EXPECT_EQ(
sizeof(e) /
sizeof(
int), handler.
LogCount) <<
"handler invoked wrong number of times";
1627 size_t oldLogCount = handler.
LogCount;
1629 EXPECT_EQ(handler.
LogCount, oldLogCount) <<
"parse-next past complete should not invoke handler";
1705 StringStream is(
"[null, true, -1, 1, -1234567890123456789, 1234567890123456789, 3.14, \"s\", { \"a\" : 1 }]");
1713 bool Int(
int) {
return e != 2; }
1714 bool Uint(
unsigned) {
return e != 3; }
1727 #define TEST_TERMINATION(e, json)\ 1730 TerminateHandler<e> h;\ 1731 StringStream is(json);\ 1732 EXPECT_FALSE(reader.Parse(is, h));\ 1733 EXPECT_EQ(kParseErrorTermination, reader.GetParseErrorCode());\ 1758 "// Here is a one-line comment.\n" 1759 "{// And here's another one\n" 1760 " /*And here's an in-line one.*/\"hello\" : \"world\"," 1761 " \"t\" :/* And one with '*' symbol*/true ," 1762 "/* A multiline comment\n" 1764 " \"f\" : false, \"n\": null, \"i\":123, \"pi\": 3.1416, \"a\":[1, 2, 3]" 1765 "}/*And the last one to be sure */";
1775 const char*
json =
"{/**/\"hello\" : \"world\", \"t\" : true, \"f\" : false, \"n\": null, \"i\":123, \"pi\": 3.1416, \"a\":[1, 2, 3] }";
1785 const char*
json =
"{//\n\"hello\" : \"world\", \"t\" : true, \"f\" : false, \"n\": null, \"i\":123, \"pi\": 3.1416, \"a\":[1, 2, 3] }";
1796 "{/* first comment *//* second */\n" 1797 "/* third */ /*fourth*/// last one\n" 1798 "\"hello\" : \"world\", \"t\" : true, \"f\" : false, \"n\": null, \"i\":123, \"pi\": 3.1416, \"a\":[1, 2, 3] }";
1809 const char*
json =
"{/* Inline comment. */\"hello\" : \"world\", \"t\" : true, \"f\" : false, \"n\": null, \"i\":123, \"pi\": 3.1416, \"a\":[1, 2, 3] }";
1819 "{\"hello\" : /* Multiline comment starts here\n" 1821 " and ends here */\"world\", \"t\" :true , \"f\" : false, \"n\": null, \"i\":123, \"pi\": 3.1416, \"a\":[1, 2, 3] }";
1831 const char*
json =
"{// One-line comment\n\"hello\" : \"world\", \"t\" : true , \"f\" : false, \"n\": null, \"i\":123, \"pi\": 3.1416, \"a\":[1, 2, 3] }";
1840 const char*
json =
"{\"hello\" : \"world\" // EOF is here -->\0 \n}";
1850 const char*
json =
"{\"hello\" : \"world\" /* EOF is here -->\0 */}";
1860 const char*
json =
"{\"hello\" : \"world\" /* *\0 */}";
1870 const char*
json =
"{\"hello\" : \"world\" /! }";
1882 bool Int(
int) {
return true; }
1883 bool Uint(
unsigned) {
return true; }
1891 EXPECT_TRUE(strncmp(str, expected_, length) == 0);
1902 : expected_(expected)
1903 , expected_len_(strlen(expected)) {}
1911 const char*
json =
"{ \"pi\": 3.1416 } ";
1926 const char*
json =
"{ \"gigabyte\": 1.0e9 } ";
1933 char*
json =
StrDup(
"{ \"gigabyte\": 1.0e9 } ");
1941 const char*
json =
"{ \"pi\": 314.159e-2 } ";
1948 char*
json =
StrDup(
"{ \"gigabyte\": 314.159e-2 } ");
1956 const char*
json =
"{ \"negative\": -1.54321 } ";
1963 char*
json =
StrDup(
"{ \"negative\": -1.54321 } ");
1971 const char*
json =
"{ \"pi\": 314.159e-2 } ";
1972 std::stringstream ss(
json);
1980 template <
unsigned extraFlags>
1990 const char*
json =
"{ \"hello\" : \"world\", \"t\" : true , \"f\" : false," 1991 "\"n\": null, \"i\":123, \"pi\": 3.1416, \"a\":[1, 2, 3],}";
2000 const char*
json =
"{ \"hello\" : \"world\", \"t\" : true , \"f\" : false," 2001 "\"n\": null, \"i\":123, \"pi\": 3.1416, \"a\":[1, 2, 3\n,\n]\n,\n} ";
2010 const char*
json =
"{ \"hello\" : \"world\", \"t\" : true , \"f\" : false, \"n\": null," 2011 "\"i\":123, \"pi\": 3.1416, \"a\":[1, 2, 3/*test*/,/*test*/]/*test*/,/*test*/}";
2021 TestTrailingCommas<kParseNoFlags>();
2025 TestTrailingCommas<kParseIterativeFlag>();
2028 template <
unsigned extraFlags>
2041 const char*
json =
"{ \"hello\" : \"world\", \"t\" : true , \"f\" : false," 2042 "\"n\": null, \"i\":123, \"pi\": 3.1416, \"a\":[1, 2, 3,],,}";
2054 TestMultipleTrailingCommaErrors<kParseNoFlags>();
2058 TestMultipleTrailingCommaErrors<kParseIterativeFlag>();
2061 template <
unsigned extraFlags>
2086 TestEmptyExceptForCommaErrors<kParseNoFlags>();
2090 TestEmptyExceptForCommaErrors<kParseIterativeFlag>();
2093 template <
unsigned extraFlags>
2116 TestTrailingCommaHandlerTermination<kParseNoFlags>();
2120 TestTrailingCommaHandlerTermination<kParseIterativeFlag>();
2124 #define TEST_NAN_INF(str, x) \ 2127 StringStream s(str); \ 2128 ParseDoubleHandler h; \ 2130 ASSERT_EQ(kParseErrorNone, reader.Parse<kParseNanAndInfFlag>(s, h).Code()); \ 2131 EXPECT_EQ(1u, h.step_); \ 2132 internal::Double e(x), a(h.actual_); \ 2133 EXPECT_EQ(e.IsNan(), a.IsNan()); \ 2134 EXPECT_EQ(e.IsInf(), a.IsInf()); \ 2136 EXPECT_EQ(e.Sign(), a.Sign()); \ 2139 const char* json = "{ \"naninfdouble\": " str " } "; \ 2140 StringStream s(json); \ 2141 NumbersAsStringsHandler h(str); \ 2143 EXPECT_TRUE(reader.Parse<kParseNumbersAsStringsFlag|kParseNanAndInfFlag>(s, h)); \ 2146 char* json = StrDup("{ \"naninfdouble\": " str " } "); \ 2147 InsituStringStream s(json); \ 2148 NumbersAsStringsHandler h(str); \ 2150 EXPECT_TRUE(reader.Parse<kParseInsituFlag|kParseNumbersAsStringsFlag|kParseNanAndInfFlag>(s, h)); \ 2154 #define TEST_NAN_INF_ERROR(errorCode, str, errorOffset) \ 2156 int streamPos = errorOffset; \ 2157 char buffer[1001]; \ 2158 strncpy(buffer, str, 1000); \ 2159 InsituStringStream s(buffer); \ 2160 BaseReaderHandler<> h; \ 2162 EXPECT_FALSE(reader.Parse<kParseNanAndInfFlag>(s, h)); \ 2163 EXPECT_EQ(errorCode, reader.GetParseErrorCode());\ 2164 EXPECT_EQ(errorOffset, reader.GetErrorOffset());\ 2165 EXPECT_EQ(streamPos, s.Tell());\ 2168 double nan = std::numeric_limits<double>::quiet_NaN();
2169 double inf = std::numeric_limits<double>::infinity();
2186 #undef TEST_NAN_INF_ERROR bool EndArray(SizeType c)
#define TEST_INTEGER(Handler, str, x)
BasicIStreamWrapper< std::istream > IStreamWrapper
const Encoding::Ch * str_
char * u64toa(uint64_t value, char *buffer)
#define TEST_NAN_INF_ERROR(errorCode, str, errorOffset)
#define TEST_ERROR(errorCode, str, errorOffset)
void TestEmptyExceptForCommaErrors()
bool EndObject(SizeType memberCount)
uint64_t Uint64Value() const
Miss fraction part in number.
RAPIDJSON_NAMESPACE_BEGIN typedef unsigned SizeType
Size type (for string lengths, array sizes, etc.)
Iterative(constant complexity in terms of function call stack size) parsing.
bool String(const char *, SizeType, bool)
#define EXPECT_TRUE(condition)
static const uint32_t LOG_BOOL
#define EXPECT_STREQ(s1, s2)
#define RAPIDJSON_UINT64_C2(high32, low32)
Construct a 64-bit literal by a pair of 32-bit integer.
static const uint32_t LOG_NULL
ParseEmptyObjectHandler()
#define TEST_NUMBER_ERROR(errorCode, str, errorOffset, streamPos)
#define TEST_TERMINATION(e, json)
static const uint32_t LOG_STARTOBJECT
ParseErrorCode Code() const
Get the error code.
Missing a colon after a name of object member.
CustomStringStream(const Ch *src)
Missing a comma or ']' after an array element.
bool RawNumber(const char *str, SizeType length, bool)
Missing a closing quotation mark in string.
void TestInsituMultipleRoot()
bool String(const char *, SizeType, bool)
static const uint32_t LOG_DOUBLE
Allow trailing commas at the end of objects and arrays.
ParseErrorCode
Error code of parsing.
IterativeParsingReaderHandler()
void copy(key &AA, const key &A)
static const uint32_t LOG_KEY
Provides additional information for stream.
static const uint32_t LOG_ENDARRAY
Incorrect hex digit after \u escape in string.
static const uint32_t LOG_STARTARRAY
bool Key(const char *, SizeType, bool)
Parse all numbers (ints/doubles) as strings.
After parsing a complete JSON root from stream, stop further processing the rest of stream...
static const uint32_t LOG_INT
ParseResult Parse(InputStream &is, Handler &handler)
Parse JSON text.
bool String(const typename Encoding::Ch *str, size_t length, bool copy)
Missing a name for object member.
#define ASSERT_EQ(val1, val2)
Default parse flags. Can be customized by defining RAPIDJSON_PARSE_DEFAULT_FLAGS. ...
#define TEST_STRINGARRAY(Encoding, utype, array, x)
Default implementation of Handler.
Parse number in full precision (but slower).
bool RawNumber(const char *, SizeType, bool)
mdb_size_t count(MDB_cursor *cur)
Number too big to be stored in double.
Represents an in-memory input byte stream.
#define TEST_ARRAY_ERROR(errorCode, str, errorOffset)
bool HasParseError() const
Whether a parse error has occurred in the last parsing.
bool Key(const Ch *, SizeType, bool)
Concept for encoding of Unicode characters.
bool String(const char *str, size_t, bool)
static const uint32_t LOG_ENDOBJECT
void TestTrailingCommas()
#define TEST_DOUBLE(fullPrecision, str, x)
void TestTrailingCommaHandlerTermination()
Ch * StrDup(const Ch *str)
unsigned __int64 uint64_t
#define TESTERRORHANDLING(text, errorCode, offset)
Invalid encoding in string.
bool IterativeParseNext(InputStream &is, Handler &handler)
Parse one token from JSON text.
Missing a comma or '}' after an object member.
#define TEST_STRINGENCODING_ERROR(Encoding, TargetEncoding, utype, array)
bool RawNumber(const Ch *, SizeType, bool)
char * u32toa(uint32_t value, char *buffer)
#define TEST_STRING_ERROR(errorCode, str, errorOffset, streamPos)
uint32_t Logs[LogCapacity]
const GenericPointer< typename T::ValueType > T2 T::AllocatorType & a
bool IsError() const
Whether the result is an error.
int StrCmp(const Ch *s1, const Ch *s2)
IStreamWrapper(std::istream &is)
#define TEST_STRINGARRAY2(Encoding, utype, earray, xarray)
bool EndObject(SizeType c)
void SkipWhitespace(InputStream &is)
Skip the JSON white spaces in a stream.
Invalid escape character in string.
void IterativeParseInit()
Initialize JSON text token-by-token parsing.
void TestMultipleTrailingCommaErrors()
FloatingPoint< double > Double
ParseErrorCode GetParseErrorCode() const
Get the ParseErrorCode of last parsing.
ParseMultipleRootHandler()
void * memcpy(void *a, const void *b, size_t c)
unsigned StrLen(const Ch *s)
#define TEST_NAN_INF(str, x)
Validate encoding of JSON strings.
The document root must not follow by other values.
Result of parsing (wraps ParseErrorCode)
static const uint32_t LOG_STRING
connection< TProtocol > & operator=(const connection< TProtocol > &obj)
#define EXPECT_DOUBLE_EQ(val1, val2)
#define EXPECT_FALSE(condition)
bool EndArray(SizeType elementCount)
NumbersAsStringsHandler(const char *expected)
bool Key(const char *, SizeType, bool)
bool String(const Ch *, SizeType, bool)
#define TEST_STRING(Encoding, e, x)
char * i64toa(int64_t value, char *buffer)
error
Tracks LMDB error codes.
char * i32toa(int32_t value, char *buffer)
#define EXPECT_EQ(val1, val2)
RAPIDJSON_FORCEINLINE bool IterativeParseComplete() const
Check if token-by-token parsing JSON text is complete.
#define RAPIDJSON_ASSERT(x)
Assertion.
char * dtoa(double value, char *buffer, int maxDecimalPlaces=324)
In-situ(destructive) parsing.
ParseErrorCode TestString(const typename Encoding::Ch *str)
The surrogate pair in string is invalid.
Allow one-line (//) and multi-line (/**/) comments.
size_t Offset() const
Get the error offset, if IsError(), 0 otherwise.