]> git.ipfire.org Git - thirdparty/glibc.git/blame - stdlib/tst-strtod-nan-locale-main.c
Update copyright dates with scripts/update-copyrights.
[thirdparty/glibc.git] / stdlib / tst-strtod-nan-locale-main.c
CommitLineData
a7f0c5ae
JM
1/* Test strtod functions work with all ASCII letters in NAN(...) in
2 Turkish locales (bug 19266).
f7a9f785 3 Copyright (C) 2015-2016 Free Software Foundation, Inc.
a7f0c5ae
JM
4 This file is part of the GNU C Library.
5
6 The GNU C Library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
10
11 The GNU C Library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
15
16 You should have received a copy of the GNU Lesser General Public
17 License along with the GNU C Library; if not, see
18 <http://www.gnu.org/licenses/>. */
19
20#include <locale.h>
21#include <math.h>
22#include <stdio.h>
23#include <stdlib.h>
24#include <wchar.h>
25
26#define STR_(X) #X
27#define STR(X) STR_(X)
28#define FNPFXS STR (FNPFX)
29#define CONCAT_(X, Y) X ## Y
30#define CONCAT(X, Y) CONCAT_ (X, Y)
31#define FNX(FN) CONCAT (FNPFX, FN)
32
33#define TEST(LOC, STR, FN, TYPE) \
34 do \
35 { \
36 CHAR *ep; \
37 TYPE val = FNX (FN) (STR, &ep); \
38 if (isnan (val) && *ep == 0) \
39 printf ("PASS: %s: " FNPFXS #FN " (" SFMT ")\n", LOC, STR); \
40 else \
41 { \
42 printf ("FAIL: %s: " FNPFXS #FN " (" SFMT ")\n", LOC, STR); \
43 result = 1; \
44 } \
45 } \
46 while (0)
47
48static int
49test_one_locale (const char *loc)
50{
51 if (setlocale (LC_ALL, loc) == NULL)
52 {
53 printf ("setlocale (LC_ALL, \"%s\") failed\n", loc);
54 return 1;
55 }
56 int result = 0;
57 for (int i = 10; i < 36; i++)
58 {
59 CHAR s[7];
60 s[0] = L_('N');
61 s[1] = L_('A');
62 s[2] = L_('N');
63 s[3] = L_('(');
64 s[4] = L_('A') + i - 10;
65 s[5] = L_(')');
66 s[6] = 0;
67 TEST (loc, s, f, float);
68 TEST (loc, s, d, double);
69 TEST (loc, s, ld, long double);
70 s[4] = L_('a') + i - 10;
71 TEST (loc, s, f, float);
72 TEST (loc, s, d, double);
73 TEST (loc, s, ld, long double);
74 }
75 return result;
76}
77
78static int
79do_test (void)
80{
81 int result = 0;
82 result |= test_one_locale ("C");
83 result |= test_one_locale ("tr_TR.UTF-8");
84 result |= test_one_locale ("tr_TR.ISO-8859-9");
85 return result;
86}
87
88#define TEST_FUNCTION do_test ()
89#include "../test-skeleton.c"