Mercurial > gnulib
annotate tests/test-nl_langinfo.c @ 40057:b06060465f09
maint: Run 'make update-copyright'
author | Paul Eggert <eggert@cs.ucla.edu> |
---|---|
date | Tue, 01 Jan 2019 00:25:11 +0100 |
parents | 672a9a35f02c |
children |
rev | line source |
---|---|
12431 | 1 /* Test of nl_langinfo replacement. |
40057
b06060465f09
maint: Run 'make update-copyright'
Paul Eggert <eggert@cs.ucla.edu>
parents:
19511
diff
changeset
|
2 Copyright (C) 2009-2019 Free Software Foundation, Inc. |
12431 | 3 |
4 This program is free software: you can redistribute it and/or modify | |
5 it under the terms of the GNU General Public License as published by | |
6 the Free Software Foundation; either version 3 of the License, or | |
7 (at your option) any later version. | |
8 | |
9 This program is distributed in the hope that it will be useful, | |
10 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 GNU General Public License for more details. | |
13 | |
14 You should have received a copy of the GNU General Public License | |
19190 | 15 along with this program. If not, see <https://www.gnu.org/licenses/>. */ |
12431 | 16 |
17 /* Written by Bruno Haible <bruno@clisp.org>, 2009. */ | |
18 | |
19 #include <config.h> | |
20 | |
21 #include <langinfo.h> | |
22 | |
12489 | 23 #include "signature.h" |
24 SIGNATURE_CHECK (nl_langinfo, char *, (nl_item)); | |
25 | |
12431 | 26 #include <locale.h> |
27 #include <stdlib.h> | |
28 #include <string.h> | |
29 | |
30 #include "c-strcase.h" | |
12496
a48d3d749ca5
Refactor common macros used in tests.
Bruno Haible <bruno@clisp.org>
parents:
12489
diff
changeset
|
31 #include "macros.h" |
12431 | 32 |
13946
438ac293c649
nl_langinfo tests: Avoid gcc warning.
Bruno Haible <bruno@clisp.org>
parents:
13819
diff
changeset
|
33 /* For GCC >= 4.3, silence the warnings |
13816
4b3de439fe40
nl_langinfo tests: Silence some warnings.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
34 "comparison of unsigned expression >= 0 is always true" |
4b3de439fe40
nl_langinfo tests: Silence some warnings.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
35 in this file. */ |
13946
438ac293c649
nl_langinfo tests: Avoid gcc warning.
Bruno Haible <bruno@clisp.org>
parents:
13819
diff
changeset
|
36 #if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) |
13816
4b3de439fe40
nl_langinfo tests: Silence some warnings.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
37 # pragma GCC diagnostic ignored "-Wtype-limits" |
4b3de439fe40
nl_langinfo tests: Silence some warnings.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
38 #endif |
4b3de439fe40
nl_langinfo tests: Silence some warnings.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
39 |
12431 | 40 int |
41 main (int argc, char *argv[]) | |
42 { | |
43 int pass = atoi (argv[1]); | |
44 /* pass locale | |
45 0 C | |
46 1 traditional French locale | |
47 2 French UTF-8 locale | |
48 */ | |
49 | |
50 setlocale (LC_ALL, ""); | |
51 | |
52 /* nl_langinfo items of the LC_CTYPE category */ | |
53 ASSERT (strlen (nl_langinfo (CODESET)) > 0); | |
54 if (pass == 2) | |
55 { | |
56 const char *codeset = nl_langinfo (CODESET); | |
57 ASSERT (c_strcasecmp (codeset, "UTF-8") == 0 || c_strcasecmp (codeset, "UTF8") == 0); | |
58 } | |
59 /* nl_langinfo items of the LC_NUMERIC category */ | |
60 ASSERT (strlen (nl_langinfo (RADIXCHAR)) > 0); | |
61 ASSERT (strlen (nl_langinfo (THOUSEP)) >= 0); | |
62 /* nl_langinfo items of the LC_TIME category */ | |
63 ASSERT (strlen (nl_langinfo (D_T_FMT)) > 0); | |
64 ASSERT (strlen (nl_langinfo (D_FMT)) > 0); | |
65 ASSERT (strlen (nl_langinfo (T_FMT)) > 0); | |
66 ASSERT (strlen (nl_langinfo (T_FMT_AMPM)) >= (pass == 0 ? 1 : 0)); | |
67 ASSERT (strlen (nl_langinfo (AM_STR)) >= (pass == 0 ? 1 : 0)); | |
68 ASSERT (strlen (nl_langinfo (PM_STR)) >= (pass == 0 ? 1 : 0)); | |
69 ASSERT (strlen (nl_langinfo (DAY_1)) > 0); | |
70 ASSERT (strlen (nl_langinfo (DAY_2)) > 0); | |
71 ASSERT (strlen (nl_langinfo (DAY_3)) > 0); | |
72 ASSERT (strlen (nl_langinfo (DAY_4)) > 0); | |
73 ASSERT (strlen (nl_langinfo (DAY_5)) > 0); | |
74 ASSERT (strlen (nl_langinfo (DAY_6)) > 0); | |
75 ASSERT (strlen (nl_langinfo (DAY_7)) > 0); | |
76 ASSERT (strlen (nl_langinfo (ABDAY_1)) > 0); | |
77 ASSERT (strlen (nl_langinfo (ABDAY_2)) > 0); | |
78 ASSERT (strlen (nl_langinfo (ABDAY_3)) > 0); | |
79 ASSERT (strlen (nl_langinfo (ABDAY_4)) > 0); | |
80 ASSERT (strlen (nl_langinfo (ABDAY_5)) > 0); | |
81 ASSERT (strlen (nl_langinfo (ABDAY_6)) > 0); | |
82 ASSERT (strlen (nl_langinfo (ABDAY_7)) > 0); | |
83 ASSERT (strlen (nl_langinfo (MON_1)) > 0); | |
84 ASSERT (strlen (nl_langinfo (MON_2)) > 0); | |
85 ASSERT (strlen (nl_langinfo (MON_3)) > 0); | |
86 ASSERT (strlen (nl_langinfo (MON_4)) > 0); | |
87 ASSERT (strlen (nl_langinfo (MON_5)) > 0); | |
88 ASSERT (strlen (nl_langinfo (MON_6)) > 0); | |
89 ASSERT (strlen (nl_langinfo (MON_7)) > 0); | |
90 ASSERT (strlen (nl_langinfo (MON_8)) > 0); | |
91 ASSERT (strlen (nl_langinfo (MON_9)) > 0); | |
92 ASSERT (strlen (nl_langinfo (MON_10)) > 0); | |
93 ASSERT (strlen (nl_langinfo (MON_11)) > 0); | |
94 ASSERT (strlen (nl_langinfo (MON_12)) > 0); | |
19511
672a9a35f02c
langinfo, nl_langinfo: Add support for alternative month names.
Bruno Haible <bruno@clisp.org>
parents:
19484
diff
changeset
|
95 ASSERT (strlen (nl_langinfo (ALTMON_1)) > 0); |
672a9a35f02c
langinfo, nl_langinfo: Add support for alternative month names.
Bruno Haible <bruno@clisp.org>
parents:
19484
diff
changeset
|
96 ASSERT (strlen (nl_langinfo (ALTMON_2)) > 0); |
672a9a35f02c
langinfo, nl_langinfo: Add support for alternative month names.
Bruno Haible <bruno@clisp.org>
parents:
19484
diff
changeset
|
97 ASSERT (strlen (nl_langinfo (ALTMON_3)) > 0); |
672a9a35f02c
langinfo, nl_langinfo: Add support for alternative month names.
Bruno Haible <bruno@clisp.org>
parents:
19484
diff
changeset
|
98 ASSERT (strlen (nl_langinfo (ALTMON_4)) > 0); |
672a9a35f02c
langinfo, nl_langinfo: Add support for alternative month names.
Bruno Haible <bruno@clisp.org>
parents:
19484
diff
changeset
|
99 ASSERT (strlen (nl_langinfo (ALTMON_5)) > 0); |
672a9a35f02c
langinfo, nl_langinfo: Add support for alternative month names.
Bruno Haible <bruno@clisp.org>
parents:
19484
diff
changeset
|
100 ASSERT (strlen (nl_langinfo (ALTMON_6)) > 0); |
672a9a35f02c
langinfo, nl_langinfo: Add support for alternative month names.
Bruno Haible <bruno@clisp.org>
parents:
19484
diff
changeset
|
101 ASSERT (strlen (nl_langinfo (ALTMON_7)) > 0); |
672a9a35f02c
langinfo, nl_langinfo: Add support for alternative month names.
Bruno Haible <bruno@clisp.org>
parents:
19484
diff
changeset
|
102 ASSERT (strlen (nl_langinfo (ALTMON_8)) > 0); |
672a9a35f02c
langinfo, nl_langinfo: Add support for alternative month names.
Bruno Haible <bruno@clisp.org>
parents:
19484
diff
changeset
|
103 ASSERT (strlen (nl_langinfo (ALTMON_9)) > 0); |
672a9a35f02c
langinfo, nl_langinfo: Add support for alternative month names.
Bruno Haible <bruno@clisp.org>
parents:
19484
diff
changeset
|
104 ASSERT (strlen (nl_langinfo (ALTMON_10)) > 0); |
672a9a35f02c
langinfo, nl_langinfo: Add support for alternative month names.
Bruno Haible <bruno@clisp.org>
parents:
19484
diff
changeset
|
105 ASSERT (strlen (nl_langinfo (ALTMON_11)) > 0); |
672a9a35f02c
langinfo, nl_langinfo: Add support for alternative month names.
Bruno Haible <bruno@clisp.org>
parents:
19484
diff
changeset
|
106 ASSERT (strlen (nl_langinfo (ALTMON_12)) > 0); |
672a9a35f02c
langinfo, nl_langinfo: Add support for alternative month names.
Bruno Haible <bruno@clisp.org>
parents:
19484
diff
changeset
|
107 /* In the tested locales, alternate month names and month names ought to be |
672a9a35f02c
langinfo, nl_langinfo: Add support for alternative month names.
Bruno Haible <bruno@clisp.org>
parents:
19484
diff
changeset
|
108 the same. */ |
672a9a35f02c
langinfo, nl_langinfo: Add support for alternative month names.
Bruno Haible <bruno@clisp.org>
parents:
19484
diff
changeset
|
109 ASSERT (strcmp (nl_langinfo (ALTMON_1), nl_langinfo (MON_1)) == 0); |
672a9a35f02c
langinfo, nl_langinfo: Add support for alternative month names.
Bruno Haible <bruno@clisp.org>
parents:
19484
diff
changeset
|
110 ASSERT (strcmp (nl_langinfo (ALTMON_2), nl_langinfo (MON_2)) == 0); |
672a9a35f02c
langinfo, nl_langinfo: Add support for alternative month names.
Bruno Haible <bruno@clisp.org>
parents:
19484
diff
changeset
|
111 ASSERT (strcmp (nl_langinfo (ALTMON_3), nl_langinfo (MON_3)) == 0); |
672a9a35f02c
langinfo, nl_langinfo: Add support for alternative month names.
Bruno Haible <bruno@clisp.org>
parents:
19484
diff
changeset
|
112 ASSERT (strcmp (nl_langinfo (ALTMON_4), nl_langinfo (MON_4)) == 0); |
672a9a35f02c
langinfo, nl_langinfo: Add support for alternative month names.
Bruno Haible <bruno@clisp.org>
parents:
19484
diff
changeset
|
113 ASSERT (strcmp (nl_langinfo (ALTMON_5), nl_langinfo (MON_5)) == 0); |
672a9a35f02c
langinfo, nl_langinfo: Add support for alternative month names.
Bruno Haible <bruno@clisp.org>
parents:
19484
diff
changeset
|
114 ASSERT (strcmp (nl_langinfo (ALTMON_6), nl_langinfo (MON_6)) == 0); |
672a9a35f02c
langinfo, nl_langinfo: Add support for alternative month names.
Bruno Haible <bruno@clisp.org>
parents:
19484
diff
changeset
|
115 ASSERT (strcmp (nl_langinfo (ALTMON_7), nl_langinfo (MON_7)) == 0); |
672a9a35f02c
langinfo, nl_langinfo: Add support for alternative month names.
Bruno Haible <bruno@clisp.org>
parents:
19484
diff
changeset
|
116 ASSERT (strcmp (nl_langinfo (ALTMON_8), nl_langinfo (MON_8)) == 0); |
672a9a35f02c
langinfo, nl_langinfo: Add support for alternative month names.
Bruno Haible <bruno@clisp.org>
parents:
19484
diff
changeset
|
117 ASSERT (strcmp (nl_langinfo (ALTMON_9), nl_langinfo (MON_9)) == 0); |
672a9a35f02c
langinfo, nl_langinfo: Add support for alternative month names.
Bruno Haible <bruno@clisp.org>
parents:
19484
diff
changeset
|
118 ASSERT (strcmp (nl_langinfo (ALTMON_10), nl_langinfo (MON_10)) == 0); |
672a9a35f02c
langinfo, nl_langinfo: Add support for alternative month names.
Bruno Haible <bruno@clisp.org>
parents:
19484
diff
changeset
|
119 ASSERT (strcmp (nl_langinfo (ALTMON_11), nl_langinfo (MON_11)) == 0); |
672a9a35f02c
langinfo, nl_langinfo: Add support for alternative month names.
Bruno Haible <bruno@clisp.org>
parents:
19484
diff
changeset
|
120 ASSERT (strcmp (nl_langinfo (ALTMON_12), nl_langinfo (MON_12)) == 0); |
12431 | 121 ASSERT (strlen (nl_langinfo (ABMON_1)) > 0); |
122 ASSERT (strlen (nl_langinfo (ABMON_2)) > 0); | |
123 ASSERT (strlen (nl_langinfo (ABMON_3)) > 0); | |
124 ASSERT (strlen (nl_langinfo (ABMON_4)) > 0); | |
125 ASSERT (strlen (nl_langinfo (ABMON_5)) > 0); | |
126 ASSERT (strlen (nl_langinfo (ABMON_6)) > 0); | |
127 ASSERT (strlen (nl_langinfo (ABMON_7)) > 0); | |
128 ASSERT (strlen (nl_langinfo (ABMON_8)) > 0); | |
129 ASSERT (strlen (nl_langinfo (ABMON_9)) > 0); | |
130 ASSERT (strlen (nl_langinfo (ABMON_10)) > 0); | |
131 ASSERT (strlen (nl_langinfo (ABMON_11)) > 0); | |
132 ASSERT (strlen (nl_langinfo (ABMON_12)) > 0); | |
133 ASSERT (strlen (nl_langinfo (ERA)) >= 0); | |
134 ASSERT (strlen (nl_langinfo (ERA_D_FMT)) >= 0); | |
135 ASSERT (strlen (nl_langinfo (ERA_D_T_FMT)) >= 0); | |
136 ASSERT (strlen (nl_langinfo (ERA_T_FMT)) >= 0); | |
137 ASSERT (nl_langinfo (ALT_DIGITS) != NULL); | |
138 /* nl_langinfo items of the LC_MONETARY category */ | |
139 { | |
140 const char *currency = nl_langinfo (CRNCYSTR); | |
13819
b7fdddf92299
nl_langinfo test: Avoid test failure on NetBSD 5.
Bruno Haible <bruno@clisp.org>
parents:
13816
diff
changeset
|
141 ASSERT (strlen (currency) >= 0); |
b7fdddf92299
nl_langinfo test: Avoid test failure on NetBSD 5.
Bruno Haible <bruno@clisp.org>
parents:
13816
diff
changeset
|
142 #if !defined __NetBSD__ |
b7fdddf92299
nl_langinfo test: Avoid test failure on NetBSD 5.
Bruno Haible <bruno@clisp.org>
parents:
13816
diff
changeset
|
143 if (pass > 0) |
b7fdddf92299
nl_langinfo test: Avoid test failure on NetBSD 5.
Bruno Haible <bruno@clisp.org>
parents:
13816
diff
changeset
|
144 ASSERT (strlen (currency) >= 1); |
b7fdddf92299
nl_langinfo test: Avoid test failure on NetBSD 5.
Bruno Haible <bruno@clisp.org>
parents:
13816
diff
changeset
|
145 #endif |
12431 | 146 } |
147 /* nl_langinfo items of the LC_MESSAGES category */ | |
148 ASSERT (strlen (nl_langinfo (YESEXPR)) > 0); | |
149 ASSERT (strlen (nl_langinfo (NOEXPR)) > 0); | |
150 | |
151 return 0; | |
152 } |