conformance fixes
[libc-test.git] / src / functional / strtod_simple.c
blob53cf93e3a7ce65fa2a9d9d2eeb3076967158f681
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <math.h>
4 #include "test.h"
6 /* r = place to store result
7 * f = function call to test (or any expression)
8 * x = expected result
9 * m = message to print on failure (with formats for r & x)
12 #define TEST(r, f, x, m) ( \
13 ((r) = (f)) == (x) || \
14 (t_error("%s failed (" m ")\n", #f, r, x, r-x), 0) )
16 int main(void)
18 int i;
19 double d, d2;
20 char buf[1000];
22 for (i=0; i<100; i++) {
23 d = sin(i);
24 snprintf(buf, sizeof buf, "%.300f", d);
25 TEST(d2, strtod(buf, 0), d, "round trip fail %a != %a (%a)");
28 TEST(d, strtod("0x1p4", 0), 16.0, "hex float %a != %a");
29 TEST(d, strtod("0x1.1p4", 0), 17.0, "hex float %a != %a");
30 return t_status;