malloc/Makefile: Split and sort tests
[glibc.git] / stdlib / tst-strtod4.c
blob6cc4e843c78a4ac08593b93704f837673d4b6a90
1 #include <locale.h>
2 #include <stdio.h>
3 #include <stdlib.h>
4 #include <string.h>
6 #define NNBSP "\xe2\x80\xaf"
8 static const struct
10 const char *in;
11 const char *out;
12 double expected;
13 } tests[] =
15 { "000"NNBSP"000"NNBSP"000", "", 0.0 },
16 { "1"NNBSP"000"NNBSP"000,5x", "x", 1000000.5 },
17 /* Bug 30964 */
18 { "10"NNBSP NNBSP"200", NNBSP NNBSP"200", 10.0 }
20 #define NTESTS (sizeof (tests) / sizeof (tests[0]))
23 static int
24 do_test (void)
26 if (setlocale (LC_ALL, "cs_CZ.UTF-8") == NULL)
28 puts ("could not set locale");
29 return 1;
32 int status = 0;
34 for (int i = 0; i < NTESTS; ++i)
36 char *ep;
37 double r = __strtod_internal (tests[i].in, &ep, 1);
39 if (strcmp (ep, tests[i].out) != 0)
41 printf ("%d: got rest string \"%s\", expected \"%s\"\n",
42 i, ep, tests[i].out);
43 status = 1;
46 if (r != tests[i].expected)
48 printf ("%d: got wrong results %g, expected %g\n",
49 i, r, tests[i].expected);
50 status = 1;
54 return status;
57 #define TEST_FUNCTION do_test ()
58 #include "../test-skeleton.c"