Remove unnecessary Alpha support.
[glibc.git] / stdlib / tst-strtod5.c
blob337c7469891b0c4c10aedcc1338c67cae53a13a5
1 #include <locale.h>
2 #include <stdio.h>
3 #include <stdlib.h>
4 #include <string.h>
5 #include <math.h>
7 #define NBSP "\xc2\xa0"
9 static const struct
11 const char *in;
12 int group;
13 double expected;
14 } tests[] =
16 { "0", 0, 0.0 },
17 { "000", 0, 0.0 },
18 { "-0", 0, -0.0 },
19 { "-000", 0, -0.0 },
20 { "0,", 0, 0.0 },
21 { "-0,", 0, -0.0 },
22 { "0,0", 0, 0.0 },
23 { "-0,0", 0, -0.0 },
24 { "0e-10", 0, 0.0 },
25 { "-0e-10", 0, -0.0 },
26 { "0,e-10", 0, 0.0 },
27 { "-0,e-10", 0, -0.0 },
28 { "0,0e-10", 0, 0.0 },
29 { "-0,0e-10", 0, -0.0 },
30 { "0e-1000000", 0, 0.0 },
31 { "-0e-1000000", 0, -0.0 },
32 { "0,0e-1000000", 0, 0.0 },
33 { "-0,0e-1000000", 0, -0.0 },
34 { "0", 1, 0.0 },
35 { "000", 1, 0.0 },
36 { "-0", 1, -0.0 },
37 { "-000", 1, -0.0 },
38 { "0e-10", 1, 0.0 },
39 { "-0e-10", 1, -0.0 },
40 { "0e-1000000", 1, 0.0 },
41 { "-0e-1000000", 1, -0.0 },
42 { "000"NBSP"000"NBSP"000", 1, 0.0 },
43 { "-000"NBSP"000"NBSP"000", 1, -0.0 }
45 #define NTESTS (sizeof (tests) / sizeof (tests[0]))
48 static int
49 do_test (void)
51 if (setlocale (LC_ALL, "cs_CZ.UTF-8") == NULL)
53 puts ("could not set locale");
54 return 1;
57 int status = 0;
59 for (int i = 0; i < NTESTS; ++i)
61 char *ep;
62 double r;
64 if (tests[i].group)
65 r = __strtod_internal (tests[i].in, &ep, 1);
66 else
67 r = strtod (tests[i].in, &ep);
69 if (*ep != '\0')
71 printf ("%d: got rest string \"%s\", expected \"\"\n", i, ep);
72 status = 1;
75 if (r != tests[i].expected
76 || copysign (10.0, r) != copysign (10.0, tests[i].expected))
78 printf ("%d: got wrong results %g, expected %g\n",
79 i, r, tests[i].expected);
80 status = 1;
84 return status;
87 #define TEST_FUNCTION do_test ()
88 #include "../test-skeleton.c"