rj_schema 0.1.4 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ext/rj_schema/extconf.rb +1 -1
- data/ext/rj_schema/rapidjson/include/rapidjson/allocators.h +14 -1
- data/ext/rj_schema/rapidjson/include/rapidjson/document.h +8 -20
- data/ext/rj_schema/rapidjson/include/rapidjson/encodings.h +29 -29
- data/ext/rj_schema/rapidjson/include/rapidjson/internal/biginteger.h +1 -1
- data/ext/rj_schema/rapidjson/include/rapidjson/internal/diyfp.h +24 -11
- data/ext/rj_schema/rapidjson/include/rapidjson/internal/itoa.h +1 -2
- data/ext/rj_schema/rapidjson/include/rapidjson/internal/meta.h +7 -2
- data/ext/rj_schema/rapidjson/include/rapidjson/internal/regex.h +5 -7
- data/ext/rj_schema/rapidjson/include/rapidjson/internal/strtod.h +59 -38
- data/ext/rj_schema/rapidjson/include/rapidjson/istreamwrapper.h +1 -3
- data/ext/rj_schema/rapidjson/include/rapidjson/pointer.h +2 -8
- data/ext/rj_schema/rapidjson/include/rapidjson/prettywriter.h +12 -12
- data/ext/rj_schema/rapidjson/include/rapidjson/rapidjson.h +15 -13
- data/ext/rj_schema/rapidjson/include/rapidjson/reader.h +27 -19
- data/ext/rj_schema/rapidjson/include/rapidjson/schema.h +15 -6
- data/ext/rj_schema/rapidjson/include/rapidjson/writer.h +4 -10
- data/ext/rj_schema/rapidjson/test/perftest/schematest.cpp +7 -0
- data/ext/rj_schema/rapidjson/test/unittest/allocatorstest.cpp +12 -14
- data/ext/rj_schema/rapidjson/test/unittest/bigintegertest.cpp +5 -0
- data/ext/rj_schema/rapidjson/test/unittest/istreamwrappertest.cpp +2 -2
- data/ext/rj_schema/rapidjson/test/unittest/prettywritertest.cpp +29 -0
- data/ext/rj_schema/rapidjson/test/unittest/readertest.cpp +303 -8
- data/ext/rj_schema/rapidjson/test/unittest/schematest.cpp +36 -2
- data/ext/rj_schema/rapidjson/test/unittest/simdtest.cpp +2 -2
- data/ext/rj_schema/rj_schema.cpp +46 -26
- data/lib/rj_schema.rb +1 -1
- metadata +3 -3
@@ -120,6 +120,11 @@ TEST(BigInteger, LeftShift) {
|
|
120
120
|
EXPECT_TRUE(BIGINTEGER_LITERAL("4537899042132549697536") == a);
|
121
121
|
a <<= 99;
|
122
122
|
EXPECT_TRUE(BIGINTEGER_LITERAL("2876235222267216943024851750785644982682875244576768") == a);
|
123
|
+
|
124
|
+
a = 1;
|
125
|
+
a <<= 64; // a.count_ != 1
|
126
|
+
a <<= 256; // interShift == 0
|
127
|
+
EXPECT_TRUE(BIGINTEGER_LITERAL("2135987035920910082395021706169552114602704522356652769947041607822219725780640550022962086936576") == a);
|
123
128
|
}
|
124
129
|
|
125
130
|
TEST(BigInteger, Compare) {
|
@@ -20,7 +20,7 @@
|
|
20
20
|
#include <sstream>
|
21
21
|
#include <fstream>
|
22
22
|
|
23
|
-
#
|
23
|
+
#if defined(_MSC_VER) && !defined(__clang__)
|
24
24
|
RAPIDJSON_DIAG_PUSH
|
25
25
|
RAPIDJSON_DIAG_OFF(4702) // unreachable code
|
26
26
|
#endif
|
@@ -176,6 +176,6 @@ TEST(IStreamWrapper, wfstream) {
|
|
176
176
|
|
177
177
|
#endif
|
178
178
|
|
179
|
-
#
|
179
|
+
#if defined(_MSC_VER) && !defined(__clang__)
|
180
180
|
RAPIDJSON_DIAG_POP
|
181
181
|
#endif
|
@@ -339,6 +339,35 @@ TEST(PrettyWriter, MoveCtor) {
|
|
339
339
|
}
|
340
340
|
#endif
|
341
341
|
|
342
|
+
TEST(PrettyWriter, Issue_1336) {
|
343
|
+
#define T(meth, val, expected) \
|
344
|
+
{ \
|
345
|
+
StringBuffer buffer; \
|
346
|
+
PrettyWriter<StringBuffer> writer(buffer); \
|
347
|
+
writer.meth(val); \
|
348
|
+
\
|
349
|
+
EXPECT_STREQ(expected, buffer.GetString()); \
|
350
|
+
EXPECT_TRUE(writer.IsComplete()); \
|
351
|
+
}
|
352
|
+
|
353
|
+
T(Bool, false, "false");
|
354
|
+
T(Bool, true, "true");
|
355
|
+
T(Int, 0, "0");
|
356
|
+
T(Uint, 0, "0");
|
357
|
+
T(Int64, 0, "0");
|
358
|
+
T(Uint64, 0, "0");
|
359
|
+
T(Double, 0, "0.0");
|
360
|
+
T(String, "Hello", "\"Hello\"");
|
361
|
+
#undef T
|
362
|
+
|
363
|
+
StringBuffer buffer;
|
364
|
+
PrettyWriter<StringBuffer> writer(buffer);
|
365
|
+
writer.Null();
|
366
|
+
|
367
|
+
EXPECT_STREQ("null", buffer.GetString());
|
368
|
+
EXPECT_TRUE(writer.IsComplete());
|
369
|
+
}
|
370
|
+
|
342
371
|
#ifdef __clang__
|
343
372
|
RAPIDJSON_DIAG_POP
|
344
373
|
#endif
|
@@ -207,6 +207,7 @@ static void TestParseDouble() {
|
|
207
207
|
|
208
208
|
TEST_DOUBLE(fullPrecision, "0.0", 0.0);
|
209
209
|
TEST_DOUBLE(fullPrecision, "-0.0", -0.0); // For checking issue #289
|
210
|
+
TEST_DOUBLE(fullPrecision, "0e100", 0.0); // For checking issue #1249
|
210
211
|
TEST_DOUBLE(fullPrecision, "1.0", 1.0);
|
211
212
|
TEST_DOUBLE(fullPrecision, "-1.0", -1.0);
|
212
213
|
TEST_DOUBLE(fullPrecision, "1.5", 1.5);
|
@@ -242,7 +243,9 @@ static void TestParseDouble() {
|
|
242
243
|
TEST_DOUBLE(fullPrecision, "1e-214748363", 0.0); // Maximum supported negative exponent
|
243
244
|
TEST_DOUBLE(fullPrecision, "1e-214748364", 0.0);
|
244
245
|
TEST_DOUBLE(fullPrecision, "1e-21474836311", 0.0);
|
246
|
+
TEST_DOUBLE(fullPrecision, "1.00000000001e-2147483638", 0.0);
|
245
247
|
TEST_DOUBLE(fullPrecision, "0.017976931348623157e+310", 1.7976931348623157e+308); // Max double in another form
|
248
|
+
TEST_DOUBLE(fullPrecision, "128.74836467836484838364836483643636483648e-336", 0.0); // Issue #1251
|
246
249
|
|
247
250
|
// Since
|
248
251
|
// abs((2^-1022 - 2^-1074) - 2.2250738585072012e-308) = 3.109754131239141401123495768877590405345064751974375599... x 10^-324
|
@@ -376,6 +379,208 @@ static void TestParseDouble() {
|
|
376
379
|
d = d.Value() * 0.5;
|
377
380
|
}
|
378
381
|
}
|
382
|
+
|
383
|
+
// Issue 1249
|
384
|
+
TEST_DOUBLE(fullPrecision, "0e100", 0.0);
|
385
|
+
|
386
|
+
// Issue 1251
|
387
|
+
TEST_DOUBLE(fullPrecision, "128.74836467836484838364836483643636483648e-336", 0.0);
|
388
|
+
|
389
|
+
// Issue 1256
|
390
|
+
TEST_DOUBLE(fullPrecision,
|
391
|
+
"6223372036854775296.1701512723685473547372536854755293372036854685477"
|
392
|
+
"529752233737201701512337200972013723685473123372036872036854236854737"
|
393
|
+
"247372368372367752975258547752975254729752547372368737201701512354737"
|
394
|
+
"83723677529752585477247372368372368547354737253685475529752",
|
395
|
+
6223372036854775808.0);
|
396
|
+
|
397
|
+
#if 0
|
398
|
+
// Test (length + exponent) overflow
|
399
|
+
TEST_DOUBLE(fullPrecision, "0e+2147483647", 0.0);
|
400
|
+
TEST_DOUBLE(fullPrecision, "0e-2147483648", 0.0);
|
401
|
+
TEST_DOUBLE(fullPrecision, "1e-2147483648", 0.0);
|
402
|
+
TEST_DOUBLE(fullPrecision, "0e+9223372036854775807", 0.0);
|
403
|
+
TEST_DOUBLE(fullPrecision, "0e-9223372036854775808", 0.0);
|
404
|
+
#endif
|
405
|
+
|
406
|
+
if (fullPrecision)
|
407
|
+
{
|
408
|
+
TEST_DOUBLE(fullPrecision, "1e-325", 0.0);
|
409
|
+
TEST_DOUBLE(fullPrecision, "1e-324", 0.0);
|
410
|
+
TEST_DOUBLE(fullPrecision, "2e-324", 0.0);
|
411
|
+
TEST_DOUBLE(fullPrecision, "2.4703282292062327e-324", 0.0);
|
412
|
+
TEST_DOUBLE(fullPrecision, "2.4703282292062328e-324", 5e-324);
|
413
|
+
TEST_DOUBLE(fullPrecision, "2.48e-324",5e-324);
|
414
|
+
TEST_DOUBLE(fullPrecision, "2.5e-324", 5e-324);
|
415
|
+
|
416
|
+
// Slightly above max-normal
|
417
|
+
TEST_DOUBLE(fullPrecision, "1.7976931348623158e+308", 1.7976931348623158e+308);
|
418
|
+
|
419
|
+
TEST_DOUBLE(fullPrecision,
|
420
|
+
"17976931348623157081452742373170435679807056752584499659891747680315726"
|
421
|
+
"07800285387605895586327668781715404589535143824642343213268894641827684"
|
422
|
+
"67546703537516986049910576551282076245490090389328944075868508455133942"
|
423
|
+
"30458323690322294816580855933212334827479782620414472316873817718091929"
|
424
|
+
"9881250404026184124858368",
|
425
|
+
std::numeric_limits<double>::max());
|
426
|
+
|
427
|
+
TEST_DOUBLE(fullPrecision,
|
428
|
+
"243546080556034731077856379609316893158278902575447060151047"
|
429
|
+
"212703405344938119816206067372775299130836050315842578309818"
|
430
|
+
"316450894337978612745889730079163798234256495613858256849283"
|
431
|
+
"467066859489192118352020514036083287319232435355752493038825"
|
432
|
+
"828481044358810649108367633313557305310641892225870327827273"
|
433
|
+
"41408256.000000",
|
434
|
+
2.4354608055603473e+307);
|
435
|
+
// 9007199254740991 * 2^971 (max normal)
|
436
|
+
TEST_DOUBLE(fullPrecision,
|
437
|
+
"1.797693134862315708145274237317043567980705675258449965989174768031572607800285"
|
438
|
+
"38760589558632766878171540458953514382464234321326889464182768467546703537516986"
|
439
|
+
"04991057655128207624549009038932894407586850845513394230458323690322294816580855"
|
440
|
+
"9332123348274797826204144723168738177180919299881250404026184124858368e+308",
|
441
|
+
1.797693134862315708e+308 // 0x1.fffffffffffffp1023
|
442
|
+
);
|
443
|
+
#if 0
|
444
|
+
// TODO:
|
445
|
+
// Should work at least in full-precision mode...
|
446
|
+
TEST_DOUBLE(fullPrecision,
|
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",
|
465
|
+
0.0);
|
466
|
+
#endif
|
467
|
+
// 9007199254740991 * 2^-1074 = (2^53 - 1) * 2^-1074
|
468
|
+
TEST_DOUBLE(fullPrecision,
|
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 // 0x1.fffffffffffffp-1022
|
480
|
+
);
|
481
|
+
// 9007199254740990 * 2^-1074
|
482
|
+
TEST_DOUBLE(fullPrecision,
|
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 // 0x1.ffffffffffffep-1022
|
494
|
+
);
|
495
|
+
// half way between the two numbers above.
|
496
|
+
// round to nearest even.
|
497
|
+
TEST_DOUBLE(fullPrecision,
|
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 // 0x1.ffffffffffffep-1022
|
509
|
+
);
|
510
|
+
TEST_DOUBLE(fullPrecision,
|
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 // 0x1.ffffffffffffep-1022
|
524
|
+
);
|
525
|
+
#if 0
|
526
|
+
// ... round up
|
527
|
+
// TODO:
|
528
|
+
// Should work at least in full-precision mode...
|
529
|
+
TEST_DOUBLE(fullPrecision,
|
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 // 0x1.fffffffffffffp-1022
|
543
|
+
);
|
544
|
+
#endif
|
545
|
+
// ... round down
|
546
|
+
TEST_DOUBLE(fullPrecision,
|
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 // 0x1.ffffffffffffep-1022
|
560
|
+
);
|
561
|
+
// Slightly below half way between max-normal and infinity.
|
562
|
+
// Should round down.
|
563
|
+
TEST_DOUBLE(fullPrecision,
|
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 // 0x1.fffffffffffffp1023
|
581
|
+
);
|
582
|
+
}
|
583
|
+
|
379
584
|
#undef TEST_DOUBLE
|
380
585
|
}
|
381
586
|
|
@@ -421,15 +626,17 @@ TEST(Reader, ParseNumber_NormalPrecisionError) {
|
|
421
626
|
printf("ULP Average = %g, Max = %g \n", ulpSum / count, ulpMax);
|
422
627
|
}
|
423
628
|
|
424
|
-
|
629
|
+
template<bool fullPrecision>
|
630
|
+
static void TestParseNumberError() {
|
425
631
|
#define TEST_NUMBER_ERROR(errorCode, str, errorOffset, streamPos) \
|
426
632
|
{ \
|
427
|
-
char buffer[
|
633
|
+
char buffer[2048]; \
|
634
|
+
ASSERT_LT(std::strlen(str), 2048u); \
|
428
635
|
sprintf(buffer, "%s", str); \
|
429
636
|
InsituStringStream s(buffer); \
|
430
637
|
BaseReaderHandler<> h; \
|
431
638
|
Reader reader; \
|
432
|
-
EXPECT_FALSE(reader.Parse(s, h)); \
|
639
|
+
EXPECT_FALSE(reader.Parse<fullPrecision ? kParseFullPrecisionFlag : 0>(s, h)); \
|
433
640
|
EXPECT_EQ(errorCode, reader.GetParseErrorCode());\
|
434
641
|
EXPECT_EQ(errorOffset, reader.GetErrorOffset());\
|
435
642
|
EXPECT_EQ(streamPos, s.Tell());\
|
@@ -442,7 +649,7 @@ TEST(Reader, ParseNumber_Error) {
|
|
442
649
|
for (int i = 1; i < 310; i++)
|
443
650
|
n1e309[i] = '0';
|
444
651
|
n1e309[310] = '\0';
|
445
|
-
TEST_NUMBER_ERROR(kParseErrorNumberTooBig, n1e309, 0,
|
652
|
+
TEST_NUMBER_ERROR(kParseErrorNumberTooBig, n1e309, 0, 310);
|
446
653
|
}
|
447
654
|
TEST_NUMBER_ERROR(kParseErrorNumberTooBig, "1e309", 0, 5);
|
448
655
|
|
@@ -454,9 +661,97 @@ TEST(Reader, ParseNumber_Error) {
|
|
454
661
|
TEST_NUMBER_ERROR(kParseErrorNumberMissExponent, "1e", 2, 2);
|
455
662
|
TEST_NUMBER_ERROR(kParseErrorNumberMissExponent, "1e_", 2, 2);
|
456
663
|
|
664
|
+
// Issue 849
|
665
|
+
TEST_NUMBER_ERROR(kParseErrorNumberTooBig, "1.8e308", 0, 7);
|
666
|
+
TEST_NUMBER_ERROR(kParseErrorNumberTooBig, "5e308", 0, 5);
|
667
|
+
TEST_NUMBER_ERROR(kParseErrorNumberTooBig, "1e309", 0, 5);
|
668
|
+
TEST_NUMBER_ERROR(kParseErrorNumberTooBig, "1.0e310", 0, 7);
|
669
|
+
TEST_NUMBER_ERROR(kParseErrorNumberTooBig, "1.00e310", 0, 8);
|
670
|
+
TEST_NUMBER_ERROR(kParseErrorNumberTooBig, "-1.8e308", 0, 8);
|
671
|
+
TEST_NUMBER_ERROR(kParseErrorNumberTooBig, "-1e309", 0, 6);
|
672
|
+
|
673
|
+
// Issue 1253
|
674
|
+
TEST_NUMBER_ERROR(kParseErrorNumberTooBig, "2e308", 0, 5);
|
675
|
+
|
676
|
+
// Issue 1259
|
677
|
+
TEST_NUMBER_ERROR(kParseErrorNumberTooBig,
|
678
|
+
"88474320368547737236837236775298547354737253685475547552933720368546854775297525"
|
679
|
+
"29337203685468547770151233720097201372368547312337203687203685423685123372036872"
|
680
|
+
"03685473724737236837236775297525854775297525472975254737236873720170151235473783"
|
681
|
+
"7236737247372368772473723683723456789012E66", 0, 283);
|
682
|
+
|
683
|
+
#if 0
|
684
|
+
// Test (length + exponent) overflow
|
685
|
+
TEST_NUMBER_ERROR(kParseErrorNumberTooBig, "1e+2147483647", 0, 13);
|
686
|
+
TEST_NUMBER_ERROR(kParseErrorNumberTooBig, "1e+9223372036854775807", 0, 22);
|
687
|
+
TEST_NUMBER_ERROR(kParseErrorNumberTooBig, "1e+10000", 0, 8);
|
688
|
+
TEST_NUMBER_ERROR(kParseErrorNumberTooBig, "1e+50000", 0, 8);
|
689
|
+
#endif
|
690
|
+
|
691
|
+
// 9007199254740992 * 2^971 ("infinity")
|
692
|
+
TEST_NUMBER_ERROR(kParseErrorNumberTooBig,
|
693
|
+
"1.797693134862315907729305190789024733617976978942306572734300811577326758055009"
|
694
|
+
"63132708477322407536021120113879871393357658789768814416622492847430639474124377"
|
695
|
+
"76789342486548527630221960124609411945308295208500576883815068234246288147391311"
|
696
|
+
"0540827237163350510684586298239947245938479716304835356329624224137216e+308", 0, 315);
|
697
|
+
|
698
|
+
// TODO:
|
699
|
+
// These tests (currently) fail in normal-precision mode
|
700
|
+
if (fullPrecision)
|
701
|
+
{
|
702
|
+
// Half way between max-normal and infinity
|
703
|
+
// Should round to infinity in nearest-even mode.
|
704
|
+
TEST_NUMBER_ERROR(kParseErrorNumberTooBig,
|
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);
|
719
|
+
// ...round up
|
720
|
+
TEST_NUMBER_ERROR(kParseErrorNumberTooBig,
|
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);
|
736
|
+
}
|
737
|
+
|
738
|
+
TEST_NUMBER_ERROR(kParseErrorNumberTooBig,
|
739
|
+
"10000000000000000000000000000000000000000000000000000000000000000000000000000000"
|
740
|
+
"00000000000000000000000000000000000000000000000000000000000000000000000000000000"
|
741
|
+
"00000000000000000000000000000000000000000000000000000000000000000000000000000000"
|
742
|
+
"0000000000000000000000000000000000000000000000000000000000000000000001", 0, 310);
|
743
|
+
|
457
744
|
#undef TEST_NUMBER_ERROR
|
458
745
|
}
|
459
746
|
|
747
|
+
TEST(Reader, ParseNumberError_NormalPrecisionDouble) {
|
748
|
+
TestParseNumberError<false>();
|
749
|
+
}
|
750
|
+
|
751
|
+
TEST(Reader, ParseNumberError_FullPrecisionDouble) {
|
752
|
+
TestParseNumberError<true>();
|
753
|
+
}
|
754
|
+
|
460
755
|
template <typename Encoding>
|
461
756
|
struct ParseStringHandler : BaseReaderHandler<Encoding, ParseStringHandler<Encoding> > {
|
462
757
|
ParseStringHandler() : str_(0), length_(0), copy_() {}
|
@@ -1311,20 +1606,20 @@ TEST(Reader, IterativePullParsing_General) {
|
|
1311
1606
|
handler.LOG_DOUBLE,
|
1312
1607
|
handler.LOG_ENDARRAY | 7
|
1313
1608
|
};
|
1314
|
-
|
1609
|
+
|
1315
1610
|
StringStream is("[1, {\"k\": [1, 2]}, null, false, true, \"string\", 1.2]");
|
1316
1611
|
Reader reader;
|
1317
|
-
|
1612
|
+
|
1318
1613
|
reader.IterativeParseInit();
|
1319
1614
|
while (!reader.IterativeParseComplete()) {
|
1320
1615
|
size_t oldLogCount = handler.LogCount;
|
1321
1616
|
EXPECT_TRUE(oldLogCount < sizeof(e) / sizeof(int)) << "overrun";
|
1322
|
-
|
1617
|
+
|
1323
1618
|
EXPECT_TRUE(reader.IterativeParseNext<kParseDefaultFlags>(is, handler)) << "parse fail";
|
1324
1619
|
EXPECT_EQ(handler.LogCount, oldLogCount + 1) << "handler should be invoked exactly once each time";
|
1325
1620
|
EXPECT_EQ(e[oldLogCount], handler.Logs[oldLogCount]) << "wrong event returned";
|
1326
1621
|
}
|
1327
|
-
|
1622
|
+
|
1328
1623
|
EXPECT_FALSE(reader.HasParseError());
|
1329
1624
|
EXPECT_EQ(sizeof(e) / sizeof(int), handler.LogCount) << "handler invoked wrong number of times";
|
1330
1625
|
|
@@ -20,6 +20,9 @@
|
|
20
20
|
#ifdef __clang__
|
21
21
|
RAPIDJSON_DIAG_PUSH
|
22
22
|
RAPIDJSON_DIAG_OFF(variadic-macros)
|
23
|
+
#elif defined(_MSC_VER)
|
24
|
+
RAPIDJSON_DIAG_PUSH
|
25
|
+
RAPIDJSON_DIAG_OFF(4822) // local class member function does not have a body
|
23
26
|
#endif
|
24
27
|
|
25
28
|
using namespace rapidjson;
|
@@ -1046,6 +1049,33 @@ TEST(SchemaValidator, Object_Required) {
|
|
1046
1049
|
"}}");
|
1047
1050
|
}
|
1048
1051
|
|
1052
|
+
TEST(SchemaValidator, Object_Required_PassWithDefault) {
|
1053
|
+
Document sd;
|
1054
|
+
sd.Parse(
|
1055
|
+
"{"
|
1056
|
+
" \"type\": \"object\","
|
1057
|
+
" \"properties\" : {"
|
1058
|
+
" \"name\": { \"type\": \"string\", \"default\": \"William Shakespeare\" },"
|
1059
|
+
" \"email\" : { \"type\": \"string\", \"default\": \"\" },"
|
1060
|
+
" \"address\" : { \"type\": \"string\" },"
|
1061
|
+
" \"telephone\" : { \"type\": \"string\" }"
|
1062
|
+
" },"
|
1063
|
+
" \"required\":[\"name\", \"email\"]"
|
1064
|
+
"}");
|
1065
|
+
SchemaDocument s(sd);
|
1066
|
+
|
1067
|
+
VALIDATE(s, "{ \"email\" : \"bill@stratford-upon-avon.co.uk\", \"address\" : \"Henley Street, Stratford-upon-Avon, Warwickshire, England\", \"authorship\" : \"in question\"}", true);
|
1068
|
+
INVALIDATE(s, "{ \"name\": \"William Shakespeare\", \"address\" : \"Henley Street, Stratford-upon-Avon, Warwickshire, England\" }", "", "required", "",
|
1069
|
+
"{ \"required\": {"
|
1070
|
+
" \"instanceRef\": \"#\", \"schemaRef\": \"#\","
|
1071
|
+
" \"missing\": [\"email\"]"
|
1072
|
+
"}}");
|
1073
|
+
INVALIDATE(s, "{}", "", "required", "",
|
1074
|
+
"{ \"required\": {"
|
1075
|
+
" \"instanceRef\": \"#\", \"schemaRef\": \"#\","
|
1076
|
+
" \"missing\": [\"email\"]"
|
1077
|
+
"}}");
|
1078
|
+
}
|
1049
1079
|
|
1050
1080
|
TEST(SchemaValidator, Object_PropertiesRange) {
|
1051
1081
|
Document sd;
|
@@ -1732,7 +1762,7 @@ private:
|
|
1732
1762
|
typename DocumentType::AllocatorType documentAllocator_;
|
1733
1763
|
typename SchemaDocumentType::AllocatorType schemaAllocator_;
|
1734
1764
|
char documentBuffer_[16384];
|
1735
|
-
char schemaBuffer_[
|
1765
|
+
char schemaBuffer_[128u * 1024];
|
1736
1766
|
};
|
1737
1767
|
|
1738
1768
|
TEST(SchemaValidator, TestSuite) {
|
@@ -2007,6 +2037,10 @@ TEST(SchemaValidator, Ref_remote) {
|
|
2007
2037
|
TEST(SchemaValidator, Ref_remote_issue1210) {
|
2008
2038
|
class SchemaDocumentProvider : public IRemoteSchemaDocumentProvider {
|
2009
2039
|
SchemaDocument** collection;
|
2040
|
+
|
2041
|
+
SchemaDocumentProvider(const SchemaDocumentProvider&);
|
2042
|
+
SchemaDocumentProvider& operator=(const SchemaDocumentProvider&);
|
2043
|
+
|
2010
2044
|
public:
|
2011
2045
|
SchemaDocumentProvider(SchemaDocument** collection) : collection(collection) { }
|
2012
2046
|
virtual const SchemaDocument* GetRemoteDocument(const char* uri, SizeType length) {
|
@@ -2033,6 +2067,6 @@ TEST(SchemaValidator, Ref_remote_issue1210) {
|
|
2033
2067
|
VALIDATE(sx, "{\"country\":\"US\"}", true);
|
2034
2068
|
}
|
2035
2069
|
|
2036
|
-
#
|
2070
|
+
#if defined(_MSC_VER) || defined(__clang__)
|
2037
2071
|
RAPIDJSON_DIAG_POP
|
2038
2072
|
#endif
|