[powerpc] Rename fesetenv_mode to fesetenv_control
[glibc.git] / stdlib / bug-strtod2.c
blob6128f2dd56710c7fafd4848a74fd60bca2cfb2e5
1 #include <locale.h>
2 #include <math.h>
3 #include <stdio.h>
4 #include <stdlib.h>
6 #include "tst-strtod.h"
8 static const char *tests[] =
10 "inf", "Inf", "iNf", "inF", "INf", "iNF", "INF", "InF",
11 "infinity", "Infinity", "InfInity", "INFINITY"
13 #define ntests (sizeof (tests) / sizeof (tests[0]))
15 #define TEST_STRTOD(FSUF, FTYPE, FTOSTR, LSUF, CSUF) \
16 static int \
17 test_strto ## FSUF (void) \
18 { \
19 int res = 0; \
20 for (int i = 0; i < ntests; ++i) \
21 { \
22 char *endp; \
23 FTYPE d = strto ## FSUF (tests[i], &endp); \
24 if (*endp != '\0') \
25 { \
26 printf ("did not consume all of '%s'\n", tests[i]); \
27 res = 1; \
28 } \
29 if (!isinf (d)) \
30 { \
31 printf ("'%s' does not pass isinf\n", tests[i]); \
32 res = 1; \
33 } \
34 } \
36 return res; \
39 GEN_TEST_STRTOD_FOREACH (TEST_STRTOD)
41 static int
42 do_test (void)
44 /* The Turkish locale is notorious because tolower() maps 'I' to the
45 dotless lowercase 'i' and toupper() maps 'i' to an 'I' with a dot
46 above. */
47 if (setlocale (LC_ALL, "tr_TR.UTF-8") == NULL)
49 puts ("cannot set locale");
50 return 0;
53 return STRTOD_TEST_FOREACH (test_strto);
56 #define TEST_FUNCTION do_test ()
57 #include "../test-skeleton.c"