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

source code of glibc/stdlib/tst-strtod4.c