]>
Commit | Line | Data |
---|---|---|
d6220e9e UD |
1 | #include <locale.h> |
2 | #include <stdio.h> | |
3 | #include <stdlib.h> | |
4 | #include <string.h> | |
5 | ||
a6bd8722 | 6 | #define NNBSP "\xe2\x80\xaf" |
d6220e9e UD |
7 | |
8 | static const struct | |
9 | { | |
10 | const char *in; | |
11 | const char *out; | |
12 | double expected; | |
13 | } tests[] = | |
14 | { | |
a6bd8722 MF |
15 | { "000"NNBSP"000"NNBSP"000", "", 0.0 }, |
16 | { "1"NNBSP"000"NNBSP"000,5x", "x", 1000000.5 } | |
d6220e9e UD |
17 | }; |
18 | #define NTESTS (sizeof (tests) / sizeof (tests[0])) | |
19 | ||
20 | ||
21 | static int | |
22 | do_test (void) | |
23 | { | |
24 | if (setlocale (LC_ALL, "cs_CZ.UTF-8") == NULL) | |
25 | { | |
26 | puts ("could not set locale"); | |
27 | return 1; | |
28 | } | |
29 | ||
30 | int status = 0; | |
31 | ||
32 | for (int i = 0; i < NTESTS; ++i) | |
33 | { | |
34 | char *ep; | |
35 | double r = __strtod_internal (tests[i].in, &ep, 1); | |
36 | ||
37 | if (strcmp (ep, tests[i].out) != 0) | |
38 | { | |
39 | printf ("%d: got rest string \"%s\", expected \"%s\"\n", | |
40 | i, ep, tests[i].out); | |
41 | status = 1; | |
42 | } | |
43 | ||
44 | if (r != tests[i].expected) | |
45 | { | |
46 | printf ("%d: got wrong results %g, expected %g\n", | |
47 | i, r, tests[i].expected); | |
48 | status = 1; | |
49 | } | |
50 | } | |
51 | ||
52 | return status; | |
53 | } | |
54 | ||
55 | #define TEST_FUNCTION do_test () | |
56 | #include "../test-skeleton.c" |