1 /* Test program for nl_langinfo() function.
2 Copyright (C) 2000 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4 Contributed by Ulrich Drepper <drepper@cygnus.com>.
6 The GNU C Library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Library General Public License as
8 published by the Free Software Foundation; either version 2 of the
9 License, or (at your option) any later version.
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 Library General Public License for more details.
16 You should have received a copy of the GNU Library General Public
17 License along with the GNU C Library; see the file COPYING.LIB. If not,
18 write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. */
33 #define VAL(name) { #name, name }
56 VAL (CURRENCY_SYMBOL),
74 VAL (INT_CURR_SYMBOL),
75 VAL (INT_FRAC_DIGITS),
88 VAL (MON_DECIMAL_POINT),
90 VAL (MON_THOUSANDS_SEP),
100 VAL (P_SEP_BY_SPACE),
113 map_paramstr (const char *str)
116 int high = sizeof (map) / sizeof (map[0]);
120 int med = (low + high) / 2;
123 cmpres = strcmp (str, map[med].str);
137 # define REASON(str) printf ("\"%s\" ignored: %s\n", buf, str)
147 while (! feof (stdin))
157 if (fgets (buf, sizeof (buf), stdin) == NULL)
160 /* Split the fields. There are three is them:
162 2. langinfo() parameter
163 3. expected result; this can be a string with white space etc.
166 while (*rp == ' ' || *rp == '\t')
171 /* It's a comment line. Ignore it. */
177 while (*rp != '\0' && *rp != ' ' && *rp != '\t' && *rp != '\n')
179 if (*rp == '\0' || *rp == '\n')
181 /* Incomplete line. */
182 REASON ("incomplete line");
187 while (*rp == ' ' || *rp == '\t')
191 while (*rp != '\0' && *rp != ' ' && *rp != '\t' && *rp != '\n')
193 if (*rp == '\0' || *rp == '\n')
195 /* Incomplete line. */
196 REASON ("incomplete line");
201 while (*rp == ' ' || *rp == '\t')
208 expected = wp = ++rp;
209 while (*rp != '"' && *rp != '\n' && *rp != '\0')
216 if (*rp >= '\0' && *rp <= 'p')
219 if (rp[1] >= '0' && rp[1] <= '9')
224 if (rp[1] >= '0' && rp[1] <= '9')
239 REASON ("missing '\"'");
248 while (*rp != '\0' && *rp != '\n')
253 param = map_paramstr (paramstr);
256 /* Invalid parameter. */
257 REASON ("invalid parameter");
261 /* Set the locale and check whether it worked. */
262 printf ("LC_ALL=%s nl_langinfo(%s)", locale, paramstr);
263 setlocale (LC_ALL, locale);
264 if (strcmp (locale, setlocale (LC_ALL, NULL)) != 0)
266 puts (": failed to set locale");
271 actual = nl_langinfo (param);
272 printf (" = \"%s\", ", actual);
274 if (strcmp (actual, expected) == 0)
278 printf ("FAILED (expected: %s)\n", expected);