-#define TEST(r, f, x, m) ( \
- ((r) = (f)) == (x) || \
- (error("%s failed (" m ")\n", #f, r, x, r-x), 0) )
-
-void test_strtod_simple(void) {
- int i;
- double d, d2;
- char buf[1000];
-
- for (i=0; i<100; i++) {
- d = sin(i);
- snprintf(buf, sizeof buf, "%.300f", d);
- TEST(d2, strtod(buf, 0), d, "round trip fail %a != %a (%a)");
- }
-
- TEST(d, strtod("0x1p4", 0), 16.0, "hex float %a != %a");
- TEST(d, strtod("0x1.1p4", 0), 17.0, "hex float %a != %a");
-}
-
-#define length(x) (sizeof(x) / sizeof(*(x)))
-
-/* TODO: float exceptions, rounding mode, endptr check */
-
-static struct {
- char *s;
- long double f;
-} tl[] = {
- {"12.345", 12.345L},
- {"1.2345e1", 12.345L},
- // 2^-16445 * 0.5 - eps
- {".1822599765941237301264202966809709908199525407846781671860490243514185844316698e-4950", 0},
- // 2^-16445 * 0.5 + eps
- {".1822599765941237301264202966809709908199525407846781671860490243514185844316699e-4950", 0x1p-16445L},
- // 2^-16445 * 1.5 - eps
- {".5467799297823711903792608900429129724598576223540345015581470730542557532950096e-4950", 0x1p-16445L},
- // 2^-16445 * 1.5 + eps
- {".5467799297823711903792608900429129724598576223540345015581470730542557532950097e-4950", 0x1p-16444L},
- // 2^-16382 + 2^-16446 - eps
- {".3362103143112093506444937793915876332724499641527442230928779770593420866576777e-4931", 0x1p-16382L},
- // 2^-16382 + 2^-16446 + eps
- {".3362103143112093506444937793915876332724499641527442230928779770593420866576778e-4931", 0x1.0000000000000002p-16382L},
- // 2^16384 - 2^16319 - eps
- {"118973149535723176505351158982948.86679662540046955672e4900", 0x1.fffffffffffffffep16383L},
- // 2^16384 - 2^16319 + eps
- {"118973149535723176505351158982948.86679662540046955673e4900", INFINITY},
-};