Remove powerpc, sparc fdim inlines (bug 22987).
[glibc.git] / stdlib / tst-strtod1i.c
blobdb49a7b829854298debf1a4823ab12102ef2e6d5
1 /* Basic tests for __strtod_internal.
2 Copyright (C) 1991-2018 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 <http://www.gnu.org/licenses/>. */
19 #include <ctype.h>
20 #include <locale.h>
21 #include <stddef.h>
22 #include <stdio.h>
23 #include <stdlib.h>
24 #include <errno.h>
25 #include <string.h>
26 #include <math.h>
28 /* Perform a few tests in a locale with thousands separators. */
29 static int
30 do_test (void)
32 static const struct
34 const char *loc;
35 const char *str;
36 double exp;
37 ptrdiff_t nread;
38 } tests[] =
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]))
46 size_t n;
47 int result = 0;
49 puts ("\nLocale tests");
51 for (n = 0; n < ntests; ++n)
53 double d;
54 char *endp;
56 if (setlocale (LC_ALL, tests[n].loc) == NULL)
58 printf ("cannot set locale %s\n", tests[n].loc);
59 result = 1;
60 continue;
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);
68 result = 1;
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);
74 result = 1;
78 if (result == 0)
79 puts ("all OK");
81 return result ? EXIT_FAILURE : EXIT_SUCCESS;
84 #include <support/test-driver.c>