aboutsummaryrefslogtreecommitdiff
path: root/locale/tst-C-locale.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2000-10-26 23:41:17 +0000
committerUlrich Drepper <drepper@redhat.com>2000-10-26 23:41:17 +0000
commitd8337213c83c3bd4aa32e16669745dd7ee32b329 (patch)
treec9f1296e2e3f355d296e4d8258c8380393006fc0 /locale/tst-C-locale.c
parent5be068fc154b697b56cce171a73eccf572f86937 (diff)
downloadglibc-d8337213c83c3bd4aa32e16669745dd7ee32b329.zip
glibc-d8337213c83c3bd4aa32e16669745dd7ee32b329.tar.gz
glibc-d8337213c83c3bd4aa32e16669745dd7ee32b329.tar.bz2
Update.
* locale/C-monetary.c: Set mon_decimal to empty string. Add missing entry _NL_MONETARY_CRNCYSTR. * stdio-common/printf_fp.c: If MON_DECIAL_POINT is not provided use DECIMAL_POINT information. * locale/C-numeric.c: Set mon_grouping entry to empty string. * locale/C-time.c: Add date_fmt entries. Remove two wrong entries. Correct value for number of entries. * locale/localeconv.c: Normalize result passed back in .grouping. Fix assignment to .int_* entries. * locale/Makefile (tests): Add tst-C-locale. * locale/tst-C-locale.c: New file. * locale/setlocale.c: Use LOCALEDIR and not LOCALE_PATH to locate locale files. * locale/newlocale.c: Likewise. 2000-10-26 GOTO Masanori <gotom@debian.or.jp> * locale/langinfo.h: Define _DATE_FMT and _NL_W_DATE_FMT. * locale/categories.def: New support for date_fmt. * locale/programs/ld-time.c: Likewise. * locale/programs/locfile-kw.gperf: Likewise. * locale/programs/locfile-kw.h: Likewise. * locale/programs/locfile-token.h: Likewise. 2000-10-26 Jakub Jelinek <jakub@redhat.com> * sysdeps/ieee754/ldbl-128/e_hypotl.c: New. * math/libm-test.inc (cabs_test, cexp_test, csqrt_test, hypot_test): Increase precision of constants. * sysdeps/alpha/fpu/libm-test-ulps: Update. * sysdeps/arm/libm-test-ulps: Update. * sysdeps/i386/fpu/libm-test-ulps: Update. * sysdeps/ia64/fpu/libm-test-ulps: Update. * sysdeps/m68k/fpu/libm-test-ulps: Update. * sysdeps/mips/fpu/libm-test-ulps: Update. * sysdeps/powerpc/fpu/libm-test-ulps: Update. * sysdeps/sparc/sparc32/fpu/libm-test-ulps: Update. * sysdeps/sparc/sparc64/fpu/libm-test-ulps: Update. * sysdeps/sh/sh4/fpu/libm-test-ulps: Update. * sysdeps/s390/fpu/libm-test-ulps: Update. 2000-10-26 Ulrich Drepper <drepper@redhat.com>
Diffstat (limited to 'locale/tst-C-locale.c')
-rw-r--r--locale/tst-C-locale.c231
1 files changed, 231 insertions, 0 deletions
diff --git a/locale/tst-C-locale.c b/locale/tst-C-locale.c
new file mode 100644
index 0000000..dc6a162
--- /dev/null
+++ b/locale/tst-C-locale.c
@@ -0,0 +1,231 @@
+/* Tests of X and POSIX locale contents.
+ Copyright (C) 2000 Free Software Foundation, Inc.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 2000.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If not,
+ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+#include <langinfo.h>
+#include <limits.h>
+#include <locale.h>
+#include <stdio.h>
+#include <string.h>
+#include <wchar.h>
+
+
+static int
+run_test (const char *locname)
+{
+ struct lconv *lc;
+ const char *str;
+ const wchar_t *wstr;
+ int result = 0;
+
+ /* ISO C stuff. */
+ lc = localeconv ();
+ if (lc == NULL)
+ {
+ printf ("localeconv failed for locale %s\n", locname);
+ result = 1;
+ }
+ else
+ {
+#define STRTEST(name, exp) \
+ do \
+ if (strcmp (lc->name, exp) != 0) \
+ { \
+ printf (#name " in locale %s wrong (is \"%s\", should be \"%s\")\n",\
+ locname, lc->name, exp); \
+ result = 1; \
+ } \
+ while (0)
+ STRTEST (decimal_point, ".");
+ STRTEST (thousands_sep, "");
+ STRTEST (grouping, "");
+ STRTEST (mon_decimal_point, "");
+ STRTEST (mon_thousands_sep, "");
+ STRTEST (mon_grouping, "");
+ STRTEST (positive_sign, "");
+ STRTEST (negative_sign, "");
+ STRTEST (currency_symbol, "");
+ STRTEST (int_curr_symbol, "");
+
+#define CHARTEST(name, exp) \
+ do \
+ if (lc->name != exp) \
+ { \
+ printf (#name " in locale %s wrong (is %d, should be %d)\n", \
+ locname, lc->name, CHAR_MAX); \
+ result = 1; \
+ } \
+ while (0)
+ CHARTEST (frac_digits, CHAR_MAX);
+ CHARTEST (p_cs_precedes, CHAR_MAX);
+ CHARTEST (n_cs_precedes, CHAR_MAX);
+ CHARTEST (p_sep_by_space, CHAR_MAX);
+ CHARTEST (n_sep_by_space, CHAR_MAX);
+ CHARTEST (p_sign_posn, CHAR_MAX);
+ CHARTEST (n_sign_posn, CHAR_MAX);
+ CHARTEST (int_frac_digits, CHAR_MAX);
+ CHARTEST (int_p_cs_precedes, CHAR_MAX);
+ CHARTEST (int_n_cs_precedes, CHAR_MAX);
+ CHARTEST (int_p_sep_by_space, CHAR_MAX);
+ CHARTEST (int_n_sep_by_space, CHAR_MAX);
+ CHARTEST (int_p_sign_posn, CHAR_MAX);
+ CHARTEST (int_n_sign_posn, CHAR_MAX);
+ }
+
+#undef STRTEST
+#define STRTEST(name, exp) \
+ str = nl_langinfo (name); \
+ if (strcmp (str, exp) != 0) \
+ { \
+ printf ("nl_langinfo(" #name ") int locale %s wrong " \
+ "(is \"%s\", should be \"%s\")\n", locname, str, exp); \
+ result = 1; \
+ }
+#define WSTRTEST(name, exp) \
+ wstr = (wchar_t *) nl_langinfo (name); \
+ if (wcscmp (wstr, exp) != 0) \
+ { \
+ printf ("nl_langinfo(" #name ") int locale %s wrong " \
+ "(is \"%S\", should be \"%S\")\n", locname, wstr, exp); \
+ result = 1; \
+ }
+
+ /* Unix stuff. */
+ STRTEST (ABDAY_1, "Sun");
+ STRTEST (ABDAY_2, "Mon");
+ STRTEST (ABDAY_3, "Tue");
+ STRTEST (ABDAY_4, "Wed");
+ STRTEST (ABDAY_5, "Thu");
+ STRTEST (ABDAY_6, "Fri");
+ STRTEST (ABDAY_7, "Sat");
+ STRTEST (DAY_1, "Sunday");
+ STRTEST (DAY_2, "Monday");
+ STRTEST (DAY_3, "Tuesday");
+ STRTEST (DAY_4, "Wednesday");
+ STRTEST (DAY_5, "Thursday");
+ STRTEST (DAY_6, "Friday");
+ STRTEST (DAY_7, "Saturday");
+ STRTEST (ABMON_1, "Jan");
+ STRTEST (ABMON_2, "Feb");
+ STRTEST (ABMON_3, "Mar");
+ STRTEST (ABMON_4, "Apr");
+ STRTEST (ABMON_5, "May");
+ STRTEST (ABMON_6, "Jun");
+ STRTEST (ABMON_7, "Jul");
+ STRTEST (ABMON_8, "Aug");
+ STRTEST (ABMON_9, "Sep");
+ STRTEST (ABMON_10, "Oct");
+ STRTEST (ABMON_11, "Nov");
+ STRTEST (ABMON_12, "Dec");
+ STRTEST (MON_1, "January");
+ STRTEST (MON_2, "February");
+ STRTEST (MON_3, "March");
+ STRTEST (MON_4, "April");
+ STRTEST (MON_5, "May");
+ STRTEST (MON_6, "June");
+ STRTEST (MON_7, "July");
+ STRTEST (MON_8, "August");
+ STRTEST (MON_9, "September");
+ STRTEST (MON_10, "October");
+ STRTEST (MON_11, "November");
+ STRTEST (MON_12, "December");
+ STRTEST (AM_STR, "AM");
+ STRTEST (PM_STR, "PM");
+ STRTEST (D_T_FMT, "%a %b %e %H:%M:%S %Y");
+ STRTEST (D_FMT, "%m/%d/%y");
+ STRTEST (T_FMT, "%H:%M:%S");
+ STRTEST (T_FMT_AMPM, "%I:%M:%S %p");
+
+ /* Extensions. */
+ WSTRTEST (_NL_WABDAY_1, L"Sun");
+ WSTRTEST (_NL_WABDAY_2, L"Mon");
+ WSTRTEST (_NL_WABDAY_3, L"Tue");
+ WSTRTEST (_NL_WABDAY_4, L"Wed");
+ WSTRTEST (_NL_WABDAY_5, L"Thu");
+ WSTRTEST (_NL_WABDAY_6, L"Fri");
+ WSTRTEST (_NL_WABDAY_7, L"Sat");
+ WSTRTEST (_NL_WDAY_1, L"Sunday");
+ WSTRTEST (_NL_WDAY_2, L"Monday");
+ WSTRTEST (_NL_WDAY_3, L"Tuesday");
+ WSTRTEST (_NL_WDAY_4, L"Wednesday");
+ WSTRTEST (_NL_WDAY_5, L"Thursday");
+ WSTRTEST (_NL_WDAY_6, L"Friday");
+ WSTRTEST (_NL_WDAY_7, L"Saturday");
+ WSTRTEST (_NL_WABMON_1, L"Jan");
+ WSTRTEST (_NL_WABMON_2, L"Feb");
+ WSTRTEST (_NL_WABMON_3, L"Mar");
+ WSTRTEST (_NL_WABMON_4, L"Apr");
+ WSTRTEST (_NL_WABMON_5, L"May");
+ WSTRTEST (_NL_WABMON_6, L"Jun");
+ WSTRTEST (_NL_WABMON_7, L"Jul");
+ WSTRTEST (_NL_WABMON_8, L"Aug");
+ WSTRTEST (_NL_WABMON_9, L"Sep");
+ WSTRTEST (_NL_WABMON_10, L"Oct");
+ WSTRTEST (_NL_WABMON_11, L"Nov");
+ WSTRTEST (_NL_WABMON_12, L"Dec");
+ WSTRTEST (_NL_WMON_1, L"January");
+ WSTRTEST (_NL_WMON_2, L"February");
+ WSTRTEST (_NL_WMON_3, L"March");
+ WSTRTEST (_NL_WMON_4, L"April");
+ WSTRTEST (_NL_WMON_5, L"May");
+ WSTRTEST (_NL_WMON_6, L"June");
+ WSTRTEST (_NL_WMON_7, L"July");
+ WSTRTEST (_NL_WMON_8, L"August");
+ WSTRTEST (_NL_WMON_9, L"September");
+ WSTRTEST (_NL_WMON_10, L"October");
+ WSTRTEST (_NL_WMON_11, L"November");
+ WSTRTEST (_NL_WMON_12, L"December");
+ WSTRTEST (_NL_WAM_STR, L"AM");
+ WSTRTEST (_NL_WPM_STR, L"PM");
+ WSTRTEST (_NL_WD_T_FMT, L"%a %b %e %H:%M:%S %Y");
+ WSTRTEST (_NL_WD_FMT, L"%m/%d/%y");
+ WSTRTEST (_NL_WT_FMT, L"%H:%M:%S");
+ WSTRTEST (_NL_WT_FMT_AMPM, L"%I:%M:%S %p");
+
+ STRTEST (_DATE_FMT, "%a %b %e %H:%M:%S %Z %Y");
+ WSTRTEST (_NL_W_DATE_FMT, L"%a %b %e %H:%M:%S %Z %Y");
+
+ return result;
+}
+
+
+int
+main (void)
+{
+ int result;
+
+ /* First use the name "C". */
+ if (setlocale (LC_ALL, "C") == NULL)
+ {
+ puts ("cannot set C locale");
+ result = 1;
+ }
+ else
+ result = run_test ("C");
+
+ /* Then the name "POSIX". */
+ if (setlocale (LC_ALL, "POSIX") == NULL)
+ {
+ puts ("cannot set POSIX locale");
+ result = 1;
+ }
+ else
+ result |= run_test ("POSIX");
+
+ return result;
+}