1 /* Basic tests for __strtod_internal.
2 Copyright (C) 1991-2021 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <https://www.gnu.org/licenses/>. */
28 /* Perform a few tests in a locale with thousands separators. */
40 { "de_DE.UTF-8", "1,5", 1.5, 3 },
41 { "de_DE.UTF-8", "1.5", 1.0, 1 },
42 { "de_DE.UTF-8", "1.500", 1500.0, 5 },
43 { "de_DE.UTF-8", "36.893.488.147.419.103.232", 0x1.0p65
, 26 }
45 #define ntests (sizeof (tests) / sizeof (tests[0]))
49 puts ("\nLocale tests");
51 for (n
= 0; n
< ntests
; ++n
)
56 if (setlocale (LC_ALL
, tests
[n
].loc
) == NULL
)
58 printf ("cannot set locale %s\n", tests
[n
].loc
);
63 d
= __strtod_internal (tests
[n
].str
, &endp
, 1);
64 if (d
!= tests
[n
].exp
)
66 printf ("strtod(\"%s\") returns %g and not %g\n",
67 tests
[n
].str
, d
, tests
[n
].exp
);
70 else if (endp
- tests
[n
].str
!= tests
[n
].nread
)
72 printf ("strtod(\"%s\") read %td bytes and not %td\n",
73 tests
[n
].str
, endp
- tests
[n
].str
, tests
[n
].nread
);
81 return result
? EXIT_FAILURE
: EXIT_SUCCESS
;
84 #include <support/test-driver.c>