bcc04ee9c6fb9c978dd3546e30908f5553f5c990
[platform/upstream/diffutils.git] / gnulib-tests / test-nl_langinfo.c
1 /* -*- buffer-read-only: t -*- vi: set ro: */
2 /* DO NOT EDIT! GENERATED AUTOMATICALLY! */
3 /* Test of nl_langinfo replacement.
4    Copyright (C) 2009-2011 Free Software Foundation, Inc.
5
6    This program is free software: you can redistribute it and/or modify
7    it under the terms of the GNU General Public License as published by
8    the Free Software Foundation; either version 3 of the License, or
9    (at your option) any later version.
10
11    This program 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
14    GNU General Public License for more details.
15
16    You should have received a copy of the GNU General Public License
17    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
18
19 /* Written by Bruno Haible <bruno@clisp.org>, 2009.  */
20
21 #include <config.h>
22
23 #include <langinfo.h>
24
25 #include "signature.h"
26 SIGNATURE_CHECK (nl_langinfo, char *, (nl_item));
27
28 #include <locale.h>
29 #include <stdlib.h>
30 #include <string.h>
31
32 #include "c-strcase.h"
33 #include "macros.h"
34
35 /* For GCC >= 4.3, silence the warnings
36      "comparison of unsigned expression >= 0 is always true"
37    in this file.  */
38 #if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
39 # pragma GCC diagnostic ignored "-Wtype-limits"
40 #endif
41
42 int
43 main (int argc, char *argv[])
44 {
45   int pass = atoi (argv[1]);
46   /* pass    locale
47       0        C
48       1        traditional French locale
49       2        French UTF-8 locale
50    */
51
52   setlocale (LC_ALL, "");
53
54   /* nl_langinfo items of the LC_CTYPE category */
55   ASSERT (strlen (nl_langinfo (CODESET)) > 0);
56   if (pass == 2)
57     {
58       const char *codeset = nl_langinfo (CODESET);
59       ASSERT (c_strcasecmp (codeset, "UTF-8") == 0 || c_strcasecmp (codeset, "UTF8") == 0);
60     }
61   /* nl_langinfo items of the LC_NUMERIC category */
62   ASSERT (strlen (nl_langinfo (RADIXCHAR)) > 0);
63   ASSERT (strlen (nl_langinfo (THOUSEP)) >= 0);
64   /* nl_langinfo items of the LC_TIME category */
65   ASSERT (strlen (nl_langinfo (D_T_FMT)) > 0);
66   ASSERT (strlen (nl_langinfo (D_FMT)) > 0);
67   ASSERT (strlen (nl_langinfo (T_FMT)) > 0);
68   ASSERT (strlen (nl_langinfo (T_FMT_AMPM)) >= (pass == 0 ? 1 : 0));
69   ASSERT (strlen (nl_langinfo (AM_STR)) >= (pass == 0 ? 1 : 0));
70   ASSERT (strlen (nl_langinfo (PM_STR)) >= (pass == 0 ? 1 : 0));
71   ASSERT (strlen (nl_langinfo (DAY_1)) > 0);
72   ASSERT (strlen (nl_langinfo (DAY_2)) > 0);
73   ASSERT (strlen (nl_langinfo (DAY_3)) > 0);
74   ASSERT (strlen (nl_langinfo (DAY_4)) > 0);
75   ASSERT (strlen (nl_langinfo (DAY_5)) > 0);
76   ASSERT (strlen (nl_langinfo (DAY_6)) > 0);
77   ASSERT (strlen (nl_langinfo (DAY_7)) > 0);
78   ASSERT (strlen (nl_langinfo (ABDAY_1)) > 0);
79   ASSERT (strlen (nl_langinfo (ABDAY_2)) > 0);
80   ASSERT (strlen (nl_langinfo (ABDAY_3)) > 0);
81   ASSERT (strlen (nl_langinfo (ABDAY_4)) > 0);
82   ASSERT (strlen (nl_langinfo (ABDAY_5)) > 0);
83   ASSERT (strlen (nl_langinfo (ABDAY_6)) > 0);
84   ASSERT (strlen (nl_langinfo (ABDAY_7)) > 0);
85   ASSERT (strlen (nl_langinfo (MON_1)) > 0);
86   ASSERT (strlen (nl_langinfo (MON_2)) > 0);
87   ASSERT (strlen (nl_langinfo (MON_3)) > 0);
88   ASSERT (strlen (nl_langinfo (MON_4)) > 0);
89   ASSERT (strlen (nl_langinfo (MON_5)) > 0);
90   ASSERT (strlen (nl_langinfo (MON_6)) > 0);
91   ASSERT (strlen (nl_langinfo (MON_7)) > 0);
92   ASSERT (strlen (nl_langinfo (MON_8)) > 0);
93   ASSERT (strlen (nl_langinfo (MON_9)) > 0);
94   ASSERT (strlen (nl_langinfo (MON_10)) > 0);
95   ASSERT (strlen (nl_langinfo (MON_11)) > 0);
96   ASSERT (strlen (nl_langinfo (MON_12)) > 0);
97   ASSERT (strlen (nl_langinfo (ABMON_1)) > 0);
98   ASSERT (strlen (nl_langinfo (ABMON_2)) > 0);
99   ASSERT (strlen (nl_langinfo (ABMON_3)) > 0);
100   ASSERT (strlen (nl_langinfo (ABMON_4)) > 0);
101   ASSERT (strlen (nl_langinfo (ABMON_5)) > 0);
102   ASSERT (strlen (nl_langinfo (ABMON_6)) > 0);
103   ASSERT (strlen (nl_langinfo (ABMON_7)) > 0);
104   ASSERT (strlen (nl_langinfo (ABMON_8)) > 0);
105   ASSERT (strlen (nl_langinfo (ABMON_9)) > 0);
106   ASSERT (strlen (nl_langinfo (ABMON_10)) > 0);
107   ASSERT (strlen (nl_langinfo (ABMON_11)) > 0);
108   ASSERT (strlen (nl_langinfo (ABMON_12)) > 0);
109   ASSERT (strlen (nl_langinfo (ERA)) >= 0);
110   ASSERT (strlen (nl_langinfo (ERA_D_FMT)) >= 0);
111   ASSERT (strlen (nl_langinfo (ERA_D_T_FMT)) >= 0);
112   ASSERT (strlen (nl_langinfo (ERA_T_FMT)) >= 0);
113   ASSERT (nl_langinfo (ALT_DIGITS) != NULL);
114   /* nl_langinfo items of the LC_MONETARY category */
115   {
116     const char *currency = nl_langinfo (CRNCYSTR);
117     ASSERT (strlen (currency) >= 0);
118 #if !defined __NetBSD__
119     if (pass > 0)
120       ASSERT (strlen (currency) >= 1);
121 #endif
122   }
123   /* nl_langinfo items of the LC_MESSAGES category */
124   ASSERT (strlen (nl_langinfo (YESEXPR)) > 0);
125   ASSERT (strlen (nl_langinfo (NOEXPR)) > 0);
126
127   return 0;
128 }