From ddac2c50eeb94a0ef53d7a39d5c13fc4e03df771 Mon Sep 17 00:00:00 2001 From: Nigel Tao Date: Tue, 15 Sep 2020 21:17:33 +1000 Subject: [PATCH] Add more {parse,render}_number_f64 test cases --- script/print-render-number-f64-tests.go | 7 ++ test/c/std/json.c | 139 +++++++++++++++++++++++- 2 files changed, 145 insertions(+), 1 deletion(-) diff --git a/script/print-render-number-f64-tests.go b/script/print-render-number-f64-tests.go index 29fa3bc4..63bcae10 100644 --- a/script/print-render-number-f64-tests.go +++ b/script/print-render-number-f64-tests.go @@ -132,8 +132,10 @@ var u64TestCases = []uint64{ 0x0000000000000001, 0x0000000000000002, 0x0000000000000003, + 0x000730D67819E8D2, 0x000FFFFFFFFFFFFF, 0x0010000000000000, + 0x0031FA182C40C60D, 0x369C314ABE948EB1, 0x3F88000000000000, 0x3FD0000000000000, @@ -172,6 +174,11 @@ var u64TestCases = []uint64{ 0x44B52D02C7E14AF6, 0x46293E5939A08CEA, 0x54B249AD2594C37D, + 0x7BBA44DF832B8D46, + 0x7BF06B0BB1FB384C, + 0x7C2485CE9E7A065F, + 0x7FAC7B1F3CAC7433, + 0x7FE1CCF385EBC8A0, 0x7FEFFFFFFFFFFFFF, 0x7FF0000000000000, 0x7FFFFFFFFFFFFFFF, diff --git a/test/c/std/json.c b/test/c/std/json.c index c1433997..c1ca60c6 100644 --- a/test/c/std/json.c +++ b/test/c/std/json.c @@ -967,8 +967,10 @@ test_wuffs_strconv_parse_number_f64_regular() { {.want = 0x0000000000000001, .str = "4.9406564584124654e-324"}, {.want = 0x0000000000000002, .str = "9.8813129168249309e-324"}, {.want = 0x0000000000000003, .str = "1.4821969375237396e-323"}, + {.want = 0x000730D67819E8D2, .str = "1e-308"}, {.want = 0x000FFFFFFFFFFFFF, .str = "2.2250738585072009E-308"}, {.want = 0x0010000000000000, .str = "2.2250738585072014E-308"}, + {.want = 0x0031FA182C40C60D, .str = "1e-307"}, {.want = 0x369C314ABE948EB1, .str = "0.0000000000000000000000000000000000000000000012345678900000"}, {.want = 0x3F88000000000000, .str = "0.01171875"}, @@ -1028,12 +1030,18 @@ test_wuffs_strconv_parse_number_f64_regular() { {.want = 0x46293E5939A08CEA, .str = "1e30"}, {.want = 0x54B249AD2594C37D, .str = "+1E+100"}, {.want = 0x54B249AD2594C37D, .str = "+_1_E_+_1_0_0_"}, + {.want = 0x7BBA44DF832B8D46, .str = "1e+288"}, + {.want = 0x7BF06B0BB1FB384C, .str = "1e+289"}, + {.want = 0x7C2485CE9E7A065F, .str = "1e+290"}, + {.want = 0x7FAC7B1F3CAC7433, .str = "9999999999999999999e+288"}, + {.want = 0x7FE1CCF385EBC8A0, .str = "9999999999999999999e+289"}, {.want = 0x7FEFFFFFFFFFFFFF, .str = "1.7976931348623157e308"}, {.want = 0x7FF0000000000000, .str = "1.8e308"}, {.want = 0x7FF0000000000000, .str = "1e+316"}, {.want = 0x7FF0000000000000, .str = "10000000000000000000000000000000000000000000e+308"}, {.want = 0x7FF0000000000000, .str = "1e999"}, + {.want = 0x7FF0000000000000, .str = "9999999999999999999e+290"}, {.want = 0x7FF0000000000000, .str = "__InFinity__"}, {.want = 0x7FF0000000000000, .str = "inf"}, {.want = 0x7FFFFFFFFFFFFFFF, .str = "+nan"}, @@ -1081,7 +1089,7 @@ test_wuffs_strconv_parse_number_f64_regular() { ? wuffs_base__ieee_754_bit_representation__from_f64_to_u64(r.value) : fail; if (have != test_cases[tc].want) { - RETURN_FAIL("\"%s\": have 0x%" PRIX64 ", want 0x%" PRIX64, + RETURN_FAIL("\"%s\": have 0x%016" PRIX64 ", want 0x%016" PRIX64, test_cases[tc].str, have, test_cases[tc].want); } } @@ -1357,6 +1365,21 @@ test_wuffs_strconv_render_number_f64() { .want_3f = "0.000", .want_4g = "1.482e-323", }, + { + .x = 0x000730D67819E8D2, + .want__e = "1e-308", + .want__f = "0.000000000000000000000000000000000000000000000000" + "00000000000000000000000000000000000000000000000000" + "00000000000000000000000000000000000000000000000000" + "00000000000000000000000000000000000000000000000000" + "00000000000000000000000000000000000000000000000000" + "00000000000000000000000000000000000000000000000000" + "0000000001", + .want_0g = "1e-308", + .want_2e = "1.00e-308", + .want_3f = "0.000", + .want_4g = "1e-308", + }, { .x = 0x000FFFFFFFFFFFFF, .want__e = "2.225073858507201e-308", @@ -1387,6 +1410,21 @@ test_wuffs_strconv_render_number_f64() { .want_3f = "0.000", .want_4g = "2.225e-308", }, + { + .x = 0x0031FA182C40C60D, + .want__e = "1e-307", + .want__f = "0.000000000000000000000000000000000000000000000000" + "00000000000000000000000000000000000000000000000000" + "00000000000000000000000000000000000000000000000000" + "00000000000000000000000000000000000000000000000000" + "00000000000000000000000000000000000000000000000000" + "00000000000000000000000000000000000000000000000000" + "000000001", + .want_0g = "1e-307", + .want_2e = "1.00e-307", + .want_3f = "0.000", + .want_4g = "1e-307", + }, { .x = 0x369C314ABE948EB1, .want__e = "1.23456789e-45", @@ -1878,6 +1916,105 @@ test_wuffs_strconv_render_number_f64() { "4.000", .want_4g = "1e+100", }, + { + .x = 0x7BBA44DF832B8D46, + .want__e = "1e+288", + .want__f = "10000000000000000000000000000000000000000000000000" + "00000000000000000000000000000000000000000000000000" + "00000000000000000000000000000000000000000000000000" + "00000000000000000000000000000000000000000000000000" + "00000000000000000000000000000000000000000000000000" + "000000000000000000000000000000000000000", + .want_0g = "1e+288", + .want_2e = "1.00e+288", + .want_3f = "10000000000000000076304735395750356605147783355117" + "10750780086664439969510636494954611131549135839186" + "51398345555539522089568786054480958499982972526059" + "48732710873996264866061464425509888400169173946264" + "49536395208620267012778077787723395914064607119962" + "069483324573977857832138825282954985472.000", + .want_4g = "1e+288", + }, + { + .x = 0x7BF06B0BB1FB384C, + .want__e = "1e+289", + .want__f = "10000000000000000000000000000000000000000000000000" + "00000000000000000000000000000000000000000000000000" + "00000000000000000000000000000000000000000000000000" + "00000000000000000000000000000000000000000000000000" + "00000000000000000000000000000000000000000000000000" + "0000000000000000000000000000000000000000", + .want_0g = "1e+289", + .want_2e = "1.00e+289", + .want_3f = "10000000000000000617278335278671568869943723109630" + "11258310052850538813376539671558942539170944464796" + "69431045845149126131034590785433956171738211535366" + "98722855425910210916188218613474303381375362727338" + "59602462772449948462578903480308154011242367042019" + "1213257583185130503608895092113260150784.000", + .want_4g = "1e+289", + }, + { + .x = 0x7C2485CE9E7A065F, + .want__e = "1e+290", + .want__f = "10000000000000000000000000000000000000000000000000" + "00000000000000000000000000000000000000000000000000" + "00000000000000000000000000000000000000000000000000" + "00000000000000000000000000000000000000000000000000" + "00000000000000000000000000000000000000000000000000" + "00000000000000000000000000000000000000000", + .want_0g = "1e+290", + .want_2e = "1.00e+290", + .want_3f = "10000000000000000617278335278671568869943723109630" + "11258310052850538813376539671558942539170944464796" + "69431045845149126131034590785433956171738211535366" + "98722855425910210916188218613474303381375362727338" + "59602462772449948462578903480308154011242367042019" + "12132575831851305036088950921132601507840.000", + .want_4g = "1e+290", + }, + { + .x = 0x7FAC7B1F3CAC7433, + .want__e = "1e+307", + .want__f = "10000000000000000000000000000000000000000000000000" + "00000000000000000000000000000000000000000000000000" + "00000000000000000000000000000000000000000000000000" + "00000000000000000000000000000000000000000000000000" + "00000000000000000000000000000000000000000000000000" + "00000000000000000000000000000000000000000000000000" + "00000000", + .want_0g = "1e+307", + .want_2e = "1.00e+307", + .want_3f = "99999999999999998603105976025645777170026418381263" + "63875249660735883565852672743849064846414228960666" + "78637928039265461539335317285025210333627595237061" + "53970107306916646893751785690398510731463396416232" + "66071126720011020169553304018596457812688561947201" + "17148846117292182213906692985128212200267666775002" + "1070848.000", + .want_4g = "1e+307", + }, + { + .x = 0x7FE1CCF385EBC8A0, + .want__e = "1e+308", + .want__f = "10000000000000000000000000000000000000000000000000" + "00000000000000000000000000000000000000000000000000" + "00000000000000000000000000000000000000000000000000" + "00000000000000000000000000000000000000000000000000" + "00000000000000000000000000000000000000000000000000" + "00000000000000000000000000000000000000000000000000" + "000000000", + .want_0g = "1e+308", + .want_2e = "1.00e+308", + .want_3f = "10000000000000000109790636294404554174049230967731" + "18463368106829031575854049114915371633289784946888" + "99061249669721172515611590283743140088328307009198" + "14604603127166450293302718569748969958855904333838" + "44661650011784268976262129451776280911957867074581" + "22783970171784415105291802893207873272974885715430" + "223118336.000", + .want_4g = "1e+308", + }, { .x = 0x7FEFFFFFFFFFFFFF, .want__e = "1.7976931348623157e+308",