nostrdb

an unfairly fast embedded nostr database backed by lmdb
git clone git://jb55.com/nostrdb
Log | Files | Refs | Submodules | README | LICENSE

grisu3_test_dblcnv.c (20839B)


      1 /*
      2  * Test cases from Googles Double Conversion Library
      3  *
      4  * https://github.com/google/double-conversion/blob/master/test/cctest/test-strtod.cc
      5  *
      6  * Added extra tests for grisu parse print roundtrip and negative sign.
      7  */
      8 
      9 #include <string.h>
     10 #include <stdio.h>
     11 #include <math.h>
     12 
     13 #include "grisu3_print.h"
     14 #include "grisu3_parse.h"
     15 
     16 #define BEGIN_TEST(name) int test_ ## name() {                              \
     17         int fail = 0; char *id = #name; double v; char *vector;             \
     18         char buf[1001];
     19 
     20 #define END_TEST() return fail; }
     21 
     22 
     23 void check_double(double x1, double x2, char *id, int line, int *fail)
     24 {
     25     char tmp[50];
     26     const char *k;
     27     int n;
     28     int failed = 0;
     29     double v;
     30 
     31     if (x1 != x2) {
     32         failed = 1;
     33         fprintf(stderr, "%d: fail (%s): %.17g != %.17g\n",
     34             line, id, x1, x2);
     35     } else {
     36 #if 1
     37         n = grisu3_print_double(x1, tmp);
     38         if (n >= GRISU3_PRINT_MAX) { /* Leave space for zterm. */
     39             failed = 1;
     40             fprintf(stderr, "%d: fail (%s): print length exceeded max: %d, input: %.17g\n",
     41                     line, id, n, x1);
     42         } else if ((int)strlen(tmp) != n) {
     43             failed = 1;
     44             fprintf(stderr, "%d: fail (%s): print length does not match strlen of output, input: %.17g, got: %s\n",
     45                     line, id, x1, tmp);
     46         } else if (!isinf(x1)) {
     47             /* We do expect print/parse to handle inf. */
     48             k = grisu3_parse_double(tmp, n, &v);
     49             if (k == 0 || k == tmp) {
     50                 failed = 1;
     51                 fprintf(stderr, "%d: fail (%s): roundtrip parse failed "
     52                         "input: %g, printed value %s\n",
     53                         line, id, x1, tmp);
     54             } else if (x1 != v) {
     55                 failed = 1;
     56                 fprintf(stderr, "%d: fail (%s): print/parse roundtrip mismatch for "
     57                         "input: %.17g, got %.17g\n",
     58                         line, id, x1, v);
     59             }
     60         }
     61 #endif
     62     }
     63     *fail += failed;
     64 }
     65 
     66 #define CHECK_EQ(v1, v2) check_double((v1), (v2), id, __LINE__, &fail)
     67 
     68 #define StringToVector(f) f
     69 
     70 #define Strtod(f, e) (sprintf(buf, "%se%d", f, e),                          \
     71         grisu3_parse_double(buf, strlen(buf), &v), v)
     72 
     73 #define StrtodChar(f, e) (sprintf(buf, "%se%d", f, e),                      \
     74         grisu3_parse_double(buf, strlen(buf), &v), v)
     75 
     76 #define double_infinity grisu3_double_infinity
     77 
     78 BEGIN_TEST(Strtod)
     79   vector = StringToVector("0");
     80   CHECK_EQ(0.0, Strtod(vector, 1));
     81   CHECK_EQ(0.0, Strtod(vector, 2));
     82   CHECK_EQ(0.0, Strtod(vector, -2));
     83   CHECK_EQ(0.0, Strtod(vector, -999));
     84   CHECK_EQ(0.0, Strtod(vector, +999));
     85 
     86   vector = StringToVector("1");
     87   CHECK_EQ(1.0, Strtod(vector, 0));
     88   CHECK_EQ(10.0, Strtod(vector, 1));
     89   CHECK_EQ(100.0, Strtod(vector, 2));
     90   CHECK_EQ(1e20, Strtod(vector, 20));
     91   CHECK_EQ(1e22, Strtod(vector, 22));
     92   CHECK_EQ(1e23, Strtod(vector, 23));
     93 
     94   CHECK_EQ(1e35, Strtod(vector, 35));
     95   CHECK_EQ(1e36, Strtod(vector, 36));
     96   CHECK_EQ(1e37, Strtod(vector, 37));
     97   CHECK_EQ(1e-1, Strtod(vector, -1));
     98   CHECK_EQ(1e-2, Strtod(vector, -2));
     99   CHECK_EQ(1e-5, Strtod(vector, -5));
    100   CHECK_EQ(1e-20, Strtod(vector, -20));
    101   CHECK_EQ(1e-22, Strtod(vector, -22));
    102   CHECK_EQ(1e-23, Strtod(vector, -23));
    103   CHECK_EQ(1e-25, Strtod(vector, -25));
    104   CHECK_EQ(1e-39, Strtod(vector, -39));
    105 
    106   vector = StringToVector("2");
    107   CHECK_EQ(2.0, Strtod(vector, 0));
    108   CHECK_EQ(20.0, Strtod(vector, 1));
    109   CHECK_EQ(200.0, Strtod(vector, 2));
    110   CHECK_EQ(2e20, Strtod(vector, 20));
    111   CHECK_EQ(2e22, Strtod(vector, 22));
    112   CHECK_EQ(2e23, Strtod(vector, 23));
    113   CHECK_EQ(2e35, Strtod(vector, 35));
    114   CHECK_EQ(2e36, Strtod(vector, 36));
    115   CHECK_EQ(2e37, Strtod(vector, 37));
    116   CHECK_EQ(2e-1, Strtod(vector, -1));
    117   CHECK_EQ(2e-2, Strtod(vector, -2));
    118   CHECK_EQ(2e-5, Strtod(vector, -5));
    119   CHECK_EQ(2e-20, Strtod(vector, -20));
    120   CHECK_EQ(2e-22, Strtod(vector, -22));
    121   CHECK_EQ(2e-23, Strtod(vector, -23));
    122   CHECK_EQ(2e-25, Strtod(vector, -25));
    123   CHECK_EQ(2e-39, Strtod(vector, -39));
    124 
    125   vector = StringToVector("9");
    126   CHECK_EQ(9.0, Strtod(vector, 0));
    127   CHECK_EQ(90.0, Strtod(vector, 1));
    128   CHECK_EQ(900.0, Strtod(vector, 2));
    129   CHECK_EQ(9e20, Strtod(vector, 20));
    130   CHECK_EQ(9e22, Strtod(vector, 22));
    131   CHECK_EQ(9e23, Strtod(vector, 23));
    132   CHECK_EQ(9e35, Strtod(vector, 35));
    133   CHECK_EQ(9e36, Strtod(vector, 36));
    134   CHECK_EQ(9e37, Strtod(vector, 37));
    135   CHECK_EQ(9e-1, Strtod(vector, -1));
    136   CHECK_EQ(9e-2, Strtod(vector, -2));
    137   CHECK_EQ(9e-5, Strtod(vector, -5));
    138   CHECK_EQ(9e-20, Strtod(vector, -20));
    139   CHECK_EQ(9e-22, Strtod(vector, -22));
    140   CHECK_EQ(9e-23, Strtod(vector, -23));
    141   CHECK_EQ(9e-25, Strtod(vector, -25));
    142   CHECK_EQ(9e-39, Strtod(vector, -39));
    143 
    144   vector = StringToVector("12345");
    145   CHECK_EQ(12345.0, Strtod(vector, 0));
    146   CHECK_EQ(123450.0, Strtod(vector, 1));
    147   CHECK_EQ(1234500.0, Strtod(vector, 2));
    148   CHECK_EQ(12345e20, Strtod(vector, 20));
    149   CHECK_EQ(12345e22, Strtod(vector, 22));
    150   CHECK_EQ(12345e23, Strtod(vector, 23));
    151   CHECK_EQ(12345e30, Strtod(vector, 30));
    152   CHECK_EQ(12345e31, Strtod(vector, 31));
    153   CHECK_EQ(12345e32, Strtod(vector, 32));
    154   CHECK_EQ(12345e35, Strtod(vector, 35));
    155   CHECK_EQ(12345e36, Strtod(vector, 36));
    156   CHECK_EQ(12345e37, Strtod(vector, 37));
    157   CHECK_EQ(12345e-1, Strtod(vector, -1));
    158   CHECK_EQ(12345e-2, Strtod(vector, -2));
    159   CHECK_EQ(12345e-5, Strtod(vector, -5));
    160   CHECK_EQ(12345e-20, Strtod(vector, -20));
    161   CHECK_EQ(12345e-22, Strtod(vector, -22));
    162   CHECK_EQ(12345e-23, Strtod(vector, -23));
    163   CHECK_EQ(12345e-25, Strtod(vector, -25));
    164   CHECK_EQ(12345e-39, Strtod(vector, -39));
    165 
    166   vector = StringToVector("12345678901234");
    167   CHECK_EQ(12345678901234.0, Strtod(vector, 0));
    168   CHECK_EQ(123456789012340.0, Strtod(vector, 1));
    169   CHECK_EQ(1234567890123400.0, Strtod(vector, 2));
    170   CHECK_EQ(12345678901234e20, Strtod(vector, 20));
    171   CHECK_EQ(12345678901234e22, Strtod(vector, 22));
    172   CHECK_EQ(12345678901234e23, Strtod(vector, 23));
    173   CHECK_EQ(12345678901234e30, Strtod(vector, 30));
    174   CHECK_EQ(12345678901234e31, Strtod(vector, 31));
    175   CHECK_EQ(12345678901234e32, Strtod(vector, 32));
    176   CHECK_EQ(12345678901234e35, Strtod(vector, 35));
    177   CHECK_EQ(12345678901234e36, Strtod(vector, 36));
    178   CHECK_EQ(12345678901234e37, Strtod(vector, 37));
    179   CHECK_EQ(12345678901234e-1, Strtod(vector, -1));
    180   CHECK_EQ(12345678901234e-2, Strtod(vector, -2));
    181   CHECK_EQ(12345678901234e-5, Strtod(vector, -5));
    182   CHECK_EQ(12345678901234e-20, Strtod(vector, -20));
    183   CHECK_EQ(12345678901234e-22, Strtod(vector, -22));
    184   CHECK_EQ(12345678901234e-23, Strtod(vector, -23));
    185   CHECK_EQ(12345678901234e-25, Strtod(vector, -25));
    186   CHECK_EQ(12345678901234e-39, Strtod(vector, -39));
    187 
    188   vector = StringToVector("123456789012345");
    189   CHECK_EQ(123456789012345.0, Strtod(vector, 0));
    190   CHECK_EQ(1234567890123450.0, Strtod(vector, 1));
    191   CHECK_EQ(12345678901234500.0, Strtod(vector, 2));
    192   CHECK_EQ(123456789012345e20, Strtod(vector, 20));
    193   CHECK_EQ(123456789012345e22, Strtod(vector, 22));
    194   CHECK_EQ(123456789012345e23, Strtod(vector, 23));
    195   CHECK_EQ(123456789012345e35, Strtod(vector, 35));
    196   CHECK_EQ(123456789012345e36, Strtod(vector, 36));
    197   CHECK_EQ(123456789012345e37, Strtod(vector, 37));
    198   CHECK_EQ(123456789012345e39, Strtod(vector, 39));
    199   CHECK_EQ(123456789012345e-1, Strtod(vector, -1));
    200   CHECK_EQ(123456789012345e-2, Strtod(vector, -2));
    201   CHECK_EQ(123456789012345e-5, Strtod(vector, -5));
    202   CHECK_EQ(123456789012345e-20, Strtod(vector, -20));
    203   CHECK_EQ(123456789012345e-22, Strtod(vector, -22));
    204   CHECK_EQ(123456789012345e-23, Strtod(vector, -23));
    205   CHECK_EQ(123456789012345e-25, Strtod(vector, -25));
    206   CHECK_EQ(123456789012345e-39, Strtod(vector, -39));
    207   CHECK_EQ(0.0, StrtodChar("0", 12345));
    208 
    209   CHECK_EQ(0.0, StrtodChar("", 1324));
    210   CHECK_EQ(0.0, StrtodChar("000000000", 123));
    211   CHECK_EQ(0.0, StrtodChar("2", -324));
    212   CHECK_EQ(4e-324, StrtodChar("3", -324));
    213 
    214   // It would be more readable to put non-zero literals on the left side (i.e.
    215   //   CHECK_EQ(1e-325, StrtodChar("1", -325))), but then Gcc complains that
    216   // they are truncated to zero.
    217   CHECK_EQ(0.0, StrtodChar("1", -325));
    218   CHECK_EQ(0.0, StrtodChar("1", -325));
    219   CHECK_EQ(0.0, StrtodChar("20000", -328));
    220   CHECK_EQ(40000e-328, StrtodChar("30000", -328));
    221   CHECK_EQ(0.0, StrtodChar("10000", -329));
    222   CHECK_EQ(0.0, StrtodChar("90000", -329));
    223   CHECK_EQ(0.0, StrtodChar("000000001", -325));
    224   CHECK_EQ(0.0, StrtodChar("000000001", -325));
    225   CHECK_EQ(0.0, StrtodChar("0000000020000", -328));
    226   CHECK_EQ(40000e-328, StrtodChar("00000030000", -328));
    227   CHECK_EQ(0.0, StrtodChar("0000000010000", -329));
    228   CHECK_EQ(0.0, StrtodChar("0000000090000", -329));
    229 
    230 
    231   // It would be more readable to put the literals (and not double_infinity)
    232   // on the left side (i.e. CHECK_EQ(1e309, StrtodChar("1", 309))), but then Gcc
    233   // complains that the floating constant exceeds range of 'double'.
    234 
    235   CHECK_EQ(double_infinity, StrtodChar("1", 309));
    236 
    237   CHECK_EQ(1e308, StrtodChar("1", 308));
    238   CHECK_EQ(1234e305, StrtodChar("1234", 305));
    239   CHECK_EQ(1234e304, StrtodChar("1234", 304));
    240 
    241   CHECK_EQ(double_infinity, StrtodChar("18", 307));
    242   CHECK_EQ(17e307, StrtodChar("17", 307));
    243 
    244   CHECK_EQ(double_infinity, StrtodChar("0000001", 309));
    245 
    246   CHECK_EQ(1e308, StrtodChar("00000001", 308));
    247 
    248   CHECK_EQ(1234e305, StrtodChar("00000001234", 305));
    249   CHECK_EQ(1234e304, StrtodChar("000000001234", 304));
    250   CHECK_EQ(double_infinity, StrtodChar("0000000018", 307));
    251   CHECK_EQ(17e307, StrtodChar("0000000017", 307));
    252   CHECK_EQ(double_infinity, StrtodChar("1000000", 303));
    253   CHECK_EQ(1e308, StrtodChar("100000", 303));
    254   CHECK_EQ(1234e305, StrtodChar("123400000", 300));
    255   CHECK_EQ(1234e304, StrtodChar("123400000", 299));
    256   CHECK_EQ(double_infinity, StrtodChar("180000000", 300));
    257   CHECK_EQ(17e307, StrtodChar("170000000", 300));
    258   CHECK_EQ(double_infinity, StrtodChar("00000001000000", 303));
    259   CHECK_EQ(1e308, StrtodChar("000000000000100000", 303));
    260   CHECK_EQ(1234e305, StrtodChar("00000000123400000", 300));
    261   CHECK_EQ(1234e304, StrtodChar("0000000123400000", 299));
    262   CHECK_EQ(double_infinity, StrtodChar("00000000180000000", 300));
    263   CHECK_EQ(17e307, StrtodChar("00000000170000000", 300));
    264   CHECK_EQ(1.7976931348623157E+308, StrtodChar("17976931348623157", 292));
    265   CHECK_EQ(1.7976931348623158E+308, StrtodChar("17976931348623158", 292));
    266   CHECK_EQ(double_infinity, StrtodChar("17976931348623159", 292));
    267 
    268   // The following number is the result of 89255.0/1e-22. Both floating-point
    269   // numbers can be accurately represented with doubles. However on Linux,x86
    270   // the floating-point stack is set to 80bits and the double-rounding
    271   // introduces an error.
    272   CHECK_EQ(89255e-22, StrtodChar("89255", -22));
    273 
    274   // Some random values.
    275   CHECK_EQ(358416272e-33, StrtodChar("358416272", -33));
    276   CHECK_EQ(104110013277974872254e-225,
    277            StrtodChar("104110013277974872254", -225));
    278 
    279   CHECK_EQ(123456789e108, StrtodChar("123456789", 108));
    280   CHECK_EQ(123456789e109, StrtodChar("123456789", 109));
    281   CHECK_EQ(123456789e110, StrtodChar("123456789", 110));
    282   CHECK_EQ(123456789e111, StrtodChar("123456789", 111));
    283   CHECK_EQ(123456789e112, StrtodChar("123456789", 112));
    284   CHECK_EQ(123456789e113, StrtodChar("123456789", 113));
    285   CHECK_EQ(123456789e114, StrtodChar("123456789", 114));
    286   CHECK_EQ(123456789e115, StrtodChar("123456789", 115));
    287 
    288   CHECK_EQ(1234567890123456789012345e108,
    289            StrtodChar("1234567890123456789012345", 108));
    290   CHECK_EQ(1234567890123456789012345e109,
    291            StrtodChar("1234567890123456789012345", 109));
    292   CHECK_EQ(1234567890123456789012345e110,
    293            StrtodChar("1234567890123456789012345", 110));
    294   CHECK_EQ(1234567890123456789012345e111,
    295            StrtodChar("1234567890123456789012345", 111));
    296   CHECK_EQ(1234567890123456789012345e112,
    297            StrtodChar("1234567890123456789012345", 112));
    298   CHECK_EQ(1234567890123456789012345e113,
    299            StrtodChar("1234567890123456789012345", 113));
    300   CHECK_EQ(1234567890123456789012345e114,
    301            StrtodChar("1234567890123456789012345", 114));
    302   CHECK_EQ(1234567890123456789012345e115,
    303            StrtodChar("1234567890123456789012345", 115));
    304   CHECK_EQ(1234567890123456789052345e108,
    305            StrtodChar("1234567890123456789052345", 108));
    306   CHECK_EQ(1234567890123456789052345e109,
    307            StrtodChar("1234567890123456789052345", 109));
    308   CHECK_EQ(1234567890123456789052345e110,
    309            StrtodChar("1234567890123456789052345", 110));
    310   CHECK_EQ(1234567890123456789052345e111,
    311            StrtodChar("1234567890123456789052345", 111));
    312   CHECK_EQ(1234567890123456789052345e112,
    313            StrtodChar("1234567890123456789052345", 112));
    314   CHECK_EQ(1234567890123456789052345e113,
    315            StrtodChar("1234567890123456789052345", 113));
    316   CHECK_EQ(1234567890123456789052345e114,
    317            StrtodChar("1234567890123456789052345", 114));
    318   CHECK_EQ(1234567890123456789052345e115,
    319            StrtodChar("1234567890123456789052345", 115));
    320   CHECK_EQ(5.445618932859895e-255,
    321            StrtodChar("5445618932859895362967233318697132813618813095743952975"
    322                       "4392982234069699615600475529427176366709107287468930197"
    323                       "8628345413991790019316974825934906752493984055268219809"
    324                       "5012176093045431437495773903922425632551857520884625114"
    325                       "6241265881735209066709685420744388526014389929047617597"
    326                       "0302268848374508109029268898695825171158085457567481507"
    327                       "4162979705098246243690189880319928315307816832576838178"
    328                       "2563074014542859888710209237525873301724479666744537857"
    329                       "9026553346649664045621387124193095870305991178772256504"
    330                       "4368663670643970181259143319016472430928902201239474588"
    331                       "1392338901353291306607057623202353588698746085415097902"
    332                       "6640064319118728664842287477491068264828851624402189317"
    333                       "2769161449825765517353755844373640588822904791244190695"
    334                       "2998382932630754670573838138825217065450843010498555058"
    335                       "88186560731", -1035));
    336 
    337   // Boundary cases. Boundaries themselves should round to even.
    338   //
    339   // 0x1FFFFFFFFFFFF * 2^3 = 72057594037927928
    340   //                   next: 72057594037927936
    341   //               boundary: 72057594037927932  should round up.
    342   CHECK_EQ(72057594037927928.0, StrtodChar("72057594037927928", 0));
    343   CHECK_EQ(72057594037927936.0, StrtodChar("72057594037927936", 0));
    344   CHECK_EQ(72057594037927936.0, StrtodChar("72057594037927932", 0));
    345   CHECK_EQ(72057594037927928.0, StrtodChar("7205759403792793199999", -5));
    346   CHECK_EQ(72057594037927936.0, StrtodChar("7205759403792793200001", -5));
    347 
    348   // 0x1FFFFFFFFFFFF * 2^10 = 9223372036854774784
    349   //                    next: 9223372036854775808
    350   //                boundary: 9223372036854775296 should round up.
    351   CHECK_EQ(9223372036854774784.0, StrtodChar("9223372036854774784", 0));
    352   CHECK_EQ(9223372036854775808.0, StrtodChar("9223372036854775808", 0));
    353   CHECK_EQ(9223372036854775808.0, StrtodChar("9223372036854775296", 0));
    354 
    355   CHECK_EQ(9223372036854774784.0, StrtodChar("922337203685477529599999", -5));
    356   CHECK_EQ(9223372036854775808.0, StrtodChar("922337203685477529600001", -5));
    357 
    358   // 0x1FFFFFFFFFFFF * 2^50 = 10141204801825834086073718800384
    359   //                    next: 10141204801825835211973625643008
    360   //                boundary: 10141204801825834649023672221696 should round up.
    361   //
    362   CHECK_EQ(10141204801825834086073718800384.0,
    363            StrtodChar("10141204801825834086073718800384", 0));
    364   CHECK_EQ(10141204801825835211973625643008.0,
    365            StrtodChar("10141204801825835211973625643008", 0));
    366   CHECK_EQ(10141204801825835211973625643008.0,
    367            StrtodChar("10141204801825834649023672221696", 0));
    368   CHECK_EQ(10141204801825834086073718800384.0,
    369            StrtodChar("1014120480182583464902367222169599999", -5));
    370   CHECK_EQ(10141204801825835211973625643008.0,
    371            StrtodChar("1014120480182583464902367222169600001", -5));
    372   // 0x1FFFFFFFFFFFF * 2^99 = 5708990770823838890407843763683279797179383808
    373   //                    next: 5708990770823839524233143877797980545530986496
    374   //                boundary: 5708990770823839207320493820740630171355185152
    375   // The boundary should round up.
    376   CHECK_EQ(5708990770823838890407843763683279797179383808.0,
    377            StrtodChar("5708990770823838890407843763683279797179383808", 0));
    378   CHECK_EQ(5708990770823839524233143877797980545530986496.0,
    379            StrtodChar("5708990770823839524233143877797980545530986496", 0));
    380   CHECK_EQ(5708990770823839524233143877797980545530986496.0,
    381            StrtodChar("5708990770823839207320493820740630171355185152", 0));
    382   CHECK_EQ(5708990770823838890407843763683279797179383808.0,
    383            StrtodChar("5708990770823839207320493820740630171355185151999", -3));
    384   CHECK_EQ(5708990770823839524233143877797980545530986496.0,
    385            StrtodChar("5708990770823839207320493820740630171355185152001", -3));
    386 
    387   // The following test-cases got some public attention in early 2011 when they
    388   // sent Java and PHP into an infinite loop.
    389   CHECK_EQ(2.225073858507201e-308, StrtodChar("22250738585072011", -324));
    390   CHECK_EQ(2.22507385850720138309e-308,
    391            StrtodChar("22250738585072011360574097967091319759348195463516456480"
    392                       "23426109724822222021076945516529523908135087914149158913"
    393                       "03962110687008643869459464552765720740782062174337998814"
    394                       "10632673292535522868813721490129811224514518898490572223"
    395                       "07285255133155755015914397476397983411801999323962548289"
    396                       "01710708185069063066665599493827577257201576306269066333"
    397                       "26475653000092458883164330377797918696120494973903778297"
    398                       "04905051080609940730262937128958950003583799967207254304"
    399                       "36028407889577179615094551674824347103070260914462157228"
    400                       "98802581825451803257070188608721131280795122334262883686"
    401                       "22321503775666622503982534335974568884423900265498198385"
    402                       "48794829220689472168983109969836584681402285424333066033"
    403                       "98508864458040010349339704275671864433837704860378616227"
    404                       "71738545623065874679014086723327636718751", -1076));
    405 END_TEST()
    406 
    407 
    408 /* Non-google test */
    409 BEGIN_TEST(grisu3_print_double)
    410   vector = "13";
    411   CHECK_EQ(13e-2, Strtod(vector, -2));
    412   CHECK_EQ(13e-3, Strtod(vector, -3));
    413 
    414   vector = "-13";
    415   CHECK_EQ(-13e-2, Strtod(vector, -2));
    416   CHECK_EQ(-13e-3, Strtod(vector, -3));
    417   vector = "-1";
    418   CHECK_EQ(-1e-2, Strtod(vector, -2));
    419   CHECK_EQ(-1e-3, Strtod(vector, -3));
    420 
    421   CHECK_EQ(-1e1, StrtodChar("-1", 1));
    422   CHECK_EQ(-1e+1, StrtodChar("-1", 1));
    423   CHECK_EQ(-1e-0, StrtodChar("-1", -0));
    424   CHECK_EQ(-1e-1, StrtodChar("-1", -1));
    425   CHECK_EQ(-1e-2, StrtodChar("-1", -2));
    426   CHECK_EQ(-1e-3, StrtodChar("-1", -3));
    427   CHECK_EQ(-1e-4, StrtodChar("-1", -4));
    428 
    429   CHECK_EQ(-12e1, StrtodChar("-12", 1));
    430   CHECK_EQ(-12e+1, StrtodChar("-12", 1));
    431   CHECK_EQ(-12e-0, StrtodChar("-12", -0));
    432   CHECK_EQ(-12e-1, StrtodChar("-12", -1));
    433   CHECK_EQ(-12e-2, StrtodChar("-12", -2));
    434   CHECK_EQ(-12e-3, StrtodChar("-12", -3));
    435   CHECK_EQ(-12e-4, StrtodChar("-12", -4));
    436 
    437   CHECK_EQ(-123e1, StrtodChar("-123", 1));
    438   CHECK_EQ(-123e+1, StrtodChar("-123", 1));
    439   CHECK_EQ(-123e-0, StrtodChar("-123", -0));
    440   CHECK_EQ(-123e-1, StrtodChar("-123", -1));
    441   CHECK_EQ(-123e-2, StrtodChar("-123", -2));
    442   CHECK_EQ(-123e-3, StrtodChar("-123", -3));
    443   CHECK_EQ(-123e-4, StrtodChar("-123", -4));
    444 
    445   CHECK_EQ(-1234e1, StrtodChar("-1234", 1));
    446   CHECK_EQ(-1234e+1, StrtodChar("-1234", 1));
    447   CHECK_EQ(-1234e-0, StrtodChar("-1234", -0));
    448   CHECK_EQ(-1234e-1, StrtodChar("-1234", -1));
    449   CHECK_EQ(-1234e-2, StrtodChar("-1234", -2));
    450   CHECK_EQ(-1234e-3, StrtodChar("-1234", -3));
    451   CHECK_EQ(-1234e-4, StrtodChar("-1234", -4));
    452 
    453   CHECK_EQ(-12345e1, StrtodChar("-12345", 1));
    454   CHECK_EQ(-12345e+1, StrtodChar("-12345", 1));
    455   CHECK_EQ(-12345e-0, StrtodChar("-12345", -0));
    456   CHECK_EQ(-12345e-1, StrtodChar("-12345", -1));
    457   CHECK_EQ(-12345e-2, StrtodChar("-12345", -2));
    458   CHECK_EQ(-12345e-3, StrtodChar("-12345", -3));
    459   CHECK_EQ(-12345e-4, StrtodChar("-12345", -4));
    460 
    461   CHECK_EQ(-12345e-5, StrtodChar("-12345", -5));
    462   CHECK_EQ(-12345e-6, StrtodChar("-12345", -6));
    463   CHECK_EQ(-12345e-7, StrtodChar("-12345", -7));
    464   CHECK_EQ(-12345e-8, StrtodChar("-12345", -8));
    465   CHECK_EQ(-12345e-9, StrtodChar("-12345", -9));
    466   CHECK_EQ(-12345e-10, StrtodChar("-12345", -10));
    467 END_TEST()
    468 
    469 int main()
    470 {
    471     int fail = 0;
    472 
    473     fail += test_Strtod();
    474     fail += test_grisu3_print_double();
    475 
    476     if (fail) {
    477         fprintf(stderr, "FAILURE\n");
    478         return -1;
    479     }
    480     fprintf(stderr, "SUCCESS\n");
    481     return 0;
    482 }