Commit a78c8e3a authored by abolz's avatar abolz

Add more tests (which need to be fixed)

parent cb009f30
......@@ -401,6 +401,178 @@ static void TestParseDouble() {
TEST_DOUBLE(fullPrecision, "2.48e-324", 2.48e-324);
TEST_DOUBLE(fullPrecision, "2.5e-324", 2.5e-324);
#if 0
// Test (length + exponent) overflow
TEST_DOUBLE(fullPrecision, "0e+2147483647", 0.0);
TEST_DOUBLE(fullPrecision, "0e-2147483648", 0.0);
TEST_DOUBLE(fullPrecision, "1e-2147483648", 0.0);
TEST_DOUBLE(fullPrecision, "0e+9223372036854775807", 0.0);
TEST_DOUBLE(fullPrecision, "0e-9223372036854775808", 0.0);
#endif
#if 0
// Slightly above max-normal
// Fails with "normal" precision
TEST_DOUBLE(fullPrecision, "1.7976931348623158e+308", 1.7976931348623158e+308);
#endif
#if 0
TEST_DOUBLE(fullPrecision,
"17976931348623157081452742373170435679807056752584499659891747680315726"
"07800285387605895586327668781715404589535143824642343213268894641827684"
"67546703537516986049910576551282076245490090389328944075868508455133942"
"30458323690322294816580855933212334827479782620414472316873817718091929"
"9881250404026184124858368",
std::numeric_limits<double>::max());
TEST_DOUBLE(fullPrecision,
"243546080556034731077856379609316893158278902575447060151047"
"212703405344938119816206067372775299130836050315842578309818"
"316450894337978612745889730079163798234256495613858256849283"
"467066859489192118352020514036083287319232435355752493038825"
"828481044358810649108367633313557305310641892225870327827273"
"41408256.000000",
2.4354608055603473e+307);
// 9007199254740991 * 2^971 (max normal)
TEST_DOUBLE(fullPrecision,
"1.797693134862315708145274237317043567980705675258449965989174768031572607800285"
"38760589558632766878171540458953514382464234321326889464182768467546703537516986"
"04991057655128207624549009038932894407586850845513394230458323690322294816580855"
"9332123348274797826204144723168738177180919299881250404026184124858368e+308",
1.797693134862315708e+308 // 0x1.fffffffffffffp1023
);
TEST_DOUBLE(fullPrecision,
"0.00000000000000000000000000000000000000000000000000000000000"
"0000000000000000000000000000000000000000000000000000000000000"
"0000000000000000000000000000000000000000000000000000000000000"
"0000000000000000000000000000000000000000000000000000000000000"
"0000000000000000000000000000000000000000000000000000000000000"
"0000000000000000000024703282292062327208828439643411068618252"
"9901307162382212792841250337753635104375932649918180817996189"
"8982823477228588654633283551779698981993873980053909390631503"
"5659515570226392290858392449105184435931802849936536152500319"
"3704576782492193656236698636584807570015857692699037063119282"
"7955855133292783433840935197801553124659726357957462276646527"
"2827220056374006485499977096599470454020828166226237857393450"
"7363390079677619305775067401763246736009689513405355374585166"
"6113422376667860416215968046191446729184030053005753084904876"
"5391711386591646239524912623653881879636239373280423891018672"
"3484976682350898633885879256283027559956575244555072551893136"
"9083625477918694866799496832404970582102851318545139621383772"
"2826145437693412532098591327667236328125",
0.0);
// 9007199254740991 * 2^-1074 = (2^53 - 1) * 2^-1074
TEST_DOUBLE(fullPrecision,
"4.450147717014402272114819593418263951869639092703291296046852219449644444042153"
"89103305904781627017582829831782607924221374017287738918929105531441481564124348"
"67599762821265346585071045737627442980259622449029037796981144446145705102663115"
"10031828794952795966823603998647925096578034214163701381261333311989876551545144"
"03152612538132666529513060001849177663286607555958373922409899478075565940981010"
"21612198814605258742579179000071675999344145086087205681577915435923018910334964"
"86942061405218289243144579760516365090360651414037721744226256159024466852576737"
"24464300755133324500796506867194913776884780053099639677097589658441378944337966"
"21993967316936280457084866613206797017728916080020698679408551343728867675409720"
"757232455434770912461317493580281734466552734375e-308",
4.450147717014402272e-308 // 0x1.fffffffffffffp-1022
);
// 9007199254740990 * 2^-1074
TEST_DOUBLE(fullPrecision,
"4.450147717014401778049173752171719775300846224481918930987049605124880018456471"
"39035755177760751831052846195619008686241717547743167145836439860405887584484471"
"19639655002484083577939142623582164522087943959208000909794783876158397872163051"
"22622675229968408654350206725478309956546318828765627255022767720818849892988457"
"26333908582101604036318532842699932130356061901518261174396928478121372742040102"
"17446565569357687263889031732270082446958029584739170416643195242132750803227473"
"16608838720742955671061336566907126801014814608027120593609275183716632624844904"
"31985250929886016737037234388448352929102742708402644340627409931664203093081360"
"70794835812045179006047003875039546061891526346421705014598610179523165038319441"
"51446491086954182492263498716056346893310546875e-308",
4.450147717014401778e-308 // 0x1.ffffffffffffep-1022
);
// half way between the two numbers above.
// round to nearest even.
TEST_DOUBLE(fullPrecision,
"4.450147717014402025081996672794991863585242658592605113516950912287262231249312"
"64069530541271189424317838013700808305231545782515453032382772695923684574304409"
"93619708911874715081505094180604803751173783204118519353387964161152051487413083"
"16327252012460602310586905362063117526562176521464664318142050516404363222266800"
"64743260560117135282915796422274554896821334728738317548403413978098469341510556"
"19529382191981473003234105366170879223151087335413188049110555339027884856781219"
"01775450062980622457102958163711745945687733011032421168917765671370549738710820"
"78224775842509670618916870627821633352993761380751142008862499795052791018709663"
"46394401564490729731565935244123171539810221213221201847003580761626016356864581"
"1358486831521563686919762403704226016998291015625e-308",
4.450147717014401778e-308 // 0x1.ffffffffffffep-1022
);
TEST_DOUBLE(fullPrecision,
"4.450147717014402025081996672794991863585242658592605113516950912287262231249312"
"64069530541271189424317838013700808305231545782515453032382772695923684574304409"
"93619708911874715081505094180604803751173783204118519353387964161152051487413083"
"16327252012460602310586905362063117526562176521464664318142050516404363222266800"
"64743260560117135282915796422274554896821334728738317548403413978098469341510556"
"19529382191981473003234105366170879223151087335413188049110555339027884856781219"
"01775450062980622457102958163711745945687733011032421168917765671370549738710820"
"78224775842509670618916870627821633352993761380751142008862499795052791018709663"
"46394401564490729731565935244123171539810221213221201847003580761626016356864581"
"13584868315215636869197624037042260169982910156250000000000000000000000000000000"
"00000000000000000000000000000000000000000000000000000000000000000000000000000000"
"00000000000000000000000000000000000000000000000000000000000000000000000000000000e-308",
4.450147717014401778e-308 // 0x1.ffffffffffffep-1022
);
// ... round up
TEST_DOUBLE(fullPrecision,
"4.450147717014402025081996672794991863585242658592605113516950912287262231249312"
"64069530541271189424317838013700808305231545782515453032382772695923684574304409"
"93619708911874715081505094180604803751173783204118519353387964161152051487413083"
"16327252012460602310586905362063117526562176521464664318142050516404363222266800"
"64743260560117135282915796422274554896821334728738317548403413978098469341510556"
"19529382191981473003234105366170879223151087335413188049110555339027884856781219"
"01775450062980622457102958163711745945687733011032421168917765671370549738710820"
"78224775842509670618916870627821633352993761380751142008862499795052791018709663"
"46394401564490729731565935244123171539810221213221201847003580761626016356864581"
"13584868315215636869197624037042260169982910156250000000000000000000000000000000"
"00000000000000000000000000000000000000000000000000000000000000000000000000000000"
"00000000000000000000000000000000000000000000000000000000000000000000000000000001e-308",
4.450147717014402272e-308 // 0x1.fffffffffffffp-1022
);
// ... round down
TEST_DOUBLE(fullPrecision,
"4.450147717014402025081996672794991863585242658592605113516950912287262231249312"
"64069530541271189424317838013700808305231545782515453032382772695923684574304409"
"93619708911874715081505094180604803751173783204118519353387964161152051487413083"
"16327252012460602310586905362063117526562176521464664318142050516404363222266800"
"64743260560117135282915796422274554896821334728738317548403413978098469341510556"
"19529382191981473003234105366170879223151087335413188049110555339027884856781219"
"01775450062980622457102958163711745945687733011032421168917765671370549738710820"
"78224775842509670618916870627821633352993761380751142008862499795052791018709663"
"46394401564490729731565935244123171539810221213221201847003580761626016356864581"
"13584868315215636869197624037042260169982910156249999999999999999999999999999999"
"99999999999999999999999999999999999999999999999999999999999999999999999999999999"
"99999999999999999999999999999999999999999999999999999999999999999999999999999999e-308",
4.450147717014401778e-308 // 0x1.ffffffffffffep-1022
);
// Slightly below half way between max-normal and infinity.
// Should round down.
TEST_DOUBLE(fullPrecision,
"1.797693134862315807937289714053034150799341327100378269361737789804449682927647"
"50946649017977587207096330286416692887910946555547851940402630657488671505820681"
"90890200070838367627385484581771153176447573027006985557136695962284291481986083"
"49364752927190741684443655107043427115596995080930428801779041744977919999999999"
"99999999999999999999999999999999999999999999999999999999999999999999999999999999"
"99999999999999999999999999999999999999999999999999999999999999999999999999999999"
"99999999999999999999999999999999999999999999999999999999999999999999999999999999"
"99999999999999999999999999999999999999999999999999999999999999999999999999999999"
"99999999999999999999999999999999999999999999999999999999999999999999999999999999"
"99999999999999999999999999999999999999999999999999999999999999999999999999999999"
"99999999999999999999999999999999999999999999999999999999999999999999999999999999"
"99999999999999999999999999999999999999999999999999999999999999999999999999999999"
"99999999999999999999999999999999999999999999999999999999999999999999999999999999"
"99999999999999999999999999999999999999999999999999999999999999999999999999999999"
"99999999999999999999999999999999999999999999999999999999999999999999999999999999"
"99999999999999999999999999999999999999999999999999999999999999999999999999999999e+308",
1.797693134862315708e+308 // 0x1.fffffffffffffp1023
);
#endif
#undef TEST_DOUBLE
}
......@@ -499,6 +671,22 @@ TEST(Reader, ParseNumber_Error) {
"03685473724737236837236775297525854775297525472975254737236873720170151235473783"
"7236737247372368772473723683723456789012E66", 0, 283);
#if 0
// Test (length + exponent) overflow
TEST_NUMBER_ERROR(kParseErrorNumberTooBig, "1e+2147483647", 0, 13);
TEST_NUMBER_ERROR(kParseErrorNumberTooBig, "1e+9223372036854775807", 0, 22);
TEST_NUMBER_ERROR(kParseErrorNumberTooBig, "1e+10000", 0, 8);
TEST_NUMBER_ERROR(kParseErrorNumberTooBig, "1e+50000", 0, 8);
#endif
// 9007199254740992 * 2^971 ("infinity")
TEST_NUMBER_ERROR(kParseErrorNumberTooBig,
"1.797693134862315907729305190789024733617976978942306572734300811577326758055009"
"63132708477322407536021120113879871393357658789768814416622492847430639474124377"
"76789342486548527630221960124609411945308295208500576883815068234246288147391311"
"0540827237163350510684586298239947245938479716304835356329624224137216e+308", 0, 315);
#if 0
// Half way between max-normal and infinity
// Should round to infinity in nearest-even mode.
TEST_NUMBER_ERROR(kParseErrorNumberTooBig,
......@@ -533,7 +721,7 @@ TEST(Reader, ParseNumber_Error) {
"00000000000000000000000000000000000000000000000000000000000000000000000000000000"
"00000000000000000000000000000000000000000000000000000000000000000000000000000000"
"00000000000000000000000000000000000000000000000000000000000000000000000000000001e+308", 0, 1125);
#endif
#undef TEST_NUMBER_ERROR
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment