Consolidate Linux recvfrom implementation
[glibc.git] / stdlib / tst-strtod3.c
blob23abec1896896276d02810437bad0bbea99b1f69
1 #include <locale.h>
2 #include <stdio.h>
3 #include <stdlib.h>
4 #include <string.h>
6 static const struct
8 const char *in;
9 const char *out;
10 double expected;
11 } tests[] =
13 { "000,,,e1", ",,,e1", 0.0 },
14 { "000e1", "", 0.0 },
15 { "000,1e1", ",1e1", 0.0 }
17 #define NTESTS (sizeof (tests) / sizeof (tests[0]))
20 static int
21 do_test (void)
23 if (setlocale (LC_ALL, "en_US.ISO-8859-1") == NULL)
25 puts ("could not set locale");
26 return 1;
29 int status = 0;
31 for (int i = 0; i < NTESTS; ++i)
33 char *ep;
34 double r = __strtod_internal (tests[i].in, &ep, 1);
36 if (strcmp (ep, tests[i].out) != 0)
38 printf ("%d: got rest string \"%s\", expected \"%s\"\n",
39 i, ep, tests[i].out);
40 status = 1;
43 if (r != tests[i].expected)
45 printf ("%d: got wrong results %g, expected %g\n",
46 i, r, tests[i].expected);
47 status = 1;
51 return status;
54 #define TEST_FUNCTION do_test ()
55 #include "../test-skeleton.c"