TaggedOpenLibrary constants off by one fix.
[AROS.git] / test / clib / strtod.c
blobfedec9ed2015a85c7877cd2ab0cbbda0c1d89259
1 #include <stdlib.h>
2 #include <stdio.h>
4 const char * strings [] =
6 "1e1",
7 "1.2e2",
8 ".1e3",
9 ".e4",
10 "exp",
11 "e",
12 "12e ",
13 "12.1ef",
14 "12.e1",
15 "12.e",
16 "10.",
17 "10e+2",
18 "1000e-2",
19 "20e+ ",
20 "20e- ",
21 "-exp",
22 "+dummy",
23 "+10",
24 "-12.1e",
25 "-.e+4",
26 "-.1e+3",
27 NULL
30 const double results [] =
32 10.0,
33 120.0,
34 100.0,
35 0.0,
36 0.0,
37 0.0,
38 12.0,
39 12.1,
40 120,
41 12,
42 10,
43 1000,
44 10,
45 20,
46 20,
49 10.0,
50 -12.1,
52 -100.0,
55 const int ptroffset [] =
80 int main()
82 char * float_end = NULL;
83 double f = 0;
84 int i = 0;
85 const char * str = NULL;
87 while((str = strings[i]) != NULL)
89 f = strtod(str, &float_end);
90 if (f != results[i])
91 printf("RESULT FAILURE @ %s, should be %f was %f\n", str, results[i], f);
92 if ((float_end - str) != ptroffset[i])
93 printf("OFFSET FAILURE @ %s, should be %d was %d\n", str, ptroffset[i], (float_end - str));
94 i++;