cdefs.h: fix "__clang_major" typo
[glibc.git] / localedata / tst-c-utf8-consistency.c
blob1625e4dd0b75e3941f55e11c7ffb917ae6e2287c
1 /* Test that C/POSIX and C.UTF-8 are consistent.
2 Copyright (C) 2022-2023 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <https://www.gnu.org/licenses/>. */
19 #include <langinfo.h>
20 #include <locale.h>
21 #include <stdbool.h>
22 #include <stdio.h>
23 #include <support/check.h>
25 /* Initialized by do_test using newlocale. */
26 static locale_t c_utf8;
28 /* Set to true for second pass. */
29 static bool use_nl_langinfo_l;
31 static void
32 switch_to_c (void)
34 if (setlocale (LC_ALL, "C") == NULL)
35 FAIL_EXIT1 ("setlocale (LC_ALL, \"C\")");
38 static void
39 switch_to_c_utf8 (void)
41 if (setlocale (LC_ALL, "C.UTF-8") == NULL)
42 FAIL_EXIT1 ("setlocale (LC_ALL, \"C.UTF-8\")");
45 static char *
46 str (nl_item item)
48 if (!use_nl_langinfo_l)
49 switch_to_c ();
50 return nl_langinfo (item);
53 static char *
54 str_utf8 (nl_item item)
56 if (use_nl_langinfo_l)
57 return nl_langinfo_l (item, c_utf8);
58 else
60 switch_to_c_utf8 ();
61 return nl_langinfo (item);
65 static wchar_t *
66 wstr (nl_item item)
68 return (wchar_t *) str (item);
71 static wchar_t *
72 wstr_utf8 (nl_item item)
74 return (wchar_t *) str_utf8 (item);
77 static int
78 byte (nl_item item)
80 return (signed char) *str (item);
83 static int
84 byte_utf8 (nl_item item)
86 return (signed char) *str_utf8 (item);
89 static int
90 word (nl_item item)
92 union
94 char *ptr;
95 int word;
96 } u;
97 u.ptr = str (item);
98 return u.word;
101 static int
102 word_utf8 (nl_item item)
104 union
106 char *ptr;
107 int word;
108 } u;
109 u.ptr = str_utf8 (item);
110 return u.word;
113 static void
114 one_pass (void)
116 /* LC_TIME. */
117 TEST_COMPARE_STRING (str (ABDAY_1), str_utf8 (ABDAY_1));
118 TEST_COMPARE_STRING (str (ABDAY_2), str_utf8 (ABDAY_2));
119 TEST_COMPARE_STRING (str (ABDAY_3), str_utf8 (ABDAY_3));
120 TEST_COMPARE_STRING (str (ABDAY_4), str_utf8 (ABDAY_4));
121 TEST_COMPARE_STRING (str (ABDAY_5), str_utf8 (ABDAY_5));
122 TEST_COMPARE_STRING (str (ABDAY_6), str_utf8 (ABDAY_6));
123 TEST_COMPARE_STRING (str (ABDAY_7), str_utf8 (ABDAY_7));
125 TEST_COMPARE_STRING (str (DAY_1), str_utf8 (DAY_1));
126 TEST_COMPARE_STRING (str (DAY_2), str_utf8 (DAY_2));
127 TEST_COMPARE_STRING (str (DAY_3), str_utf8 (DAY_3));
128 TEST_COMPARE_STRING (str (DAY_4), str_utf8 (DAY_4));
129 TEST_COMPARE_STRING (str (DAY_5), str_utf8 (DAY_5));
130 TEST_COMPARE_STRING (str (DAY_6), str_utf8 (DAY_6));
131 TEST_COMPARE_STRING (str (DAY_7), str_utf8 (DAY_7));
133 TEST_COMPARE_STRING (str (ABMON_1), str_utf8 (ABMON_1));
134 TEST_COMPARE_STRING (str (ABMON_2), str_utf8 (ABMON_2));
135 TEST_COMPARE_STRING (str (ABMON_3), str_utf8 (ABMON_3));
136 TEST_COMPARE_STRING (str (ABMON_4), str_utf8 (ABMON_4));
137 TEST_COMPARE_STRING (str (ABMON_5), str_utf8 (ABMON_5));
138 TEST_COMPARE_STRING (str (ABMON_6), str_utf8 (ABMON_6));
139 TEST_COMPARE_STRING (str (ABMON_7), str_utf8 (ABMON_7));
140 TEST_COMPARE_STRING (str (ABMON_8), str_utf8 (ABMON_8));
141 TEST_COMPARE_STRING (str (ABMON_9), str_utf8 (ABMON_9));
142 TEST_COMPARE_STRING (str (ABMON_10), str_utf8 (ABMON_10));
143 TEST_COMPARE_STRING (str (ABMON_11), str_utf8 (ABMON_11));
144 TEST_COMPARE_STRING (str (ABMON_12), str_utf8 (ABMON_12));
146 TEST_COMPARE_STRING (str (MON_1), str_utf8 (MON_1));
147 TEST_COMPARE_STRING (str (MON_2), str_utf8 (MON_2));
148 TEST_COMPARE_STRING (str (MON_3), str_utf8 (MON_3));
149 TEST_COMPARE_STRING (str (MON_4), str_utf8 (MON_4));
150 TEST_COMPARE_STRING (str (MON_5), str_utf8 (MON_5));
151 TEST_COMPARE_STRING (str (MON_6), str_utf8 (MON_6));
152 TEST_COMPARE_STRING (str (MON_7), str_utf8 (MON_7));
153 TEST_COMPARE_STRING (str (MON_8), str_utf8 (MON_8));
154 TEST_COMPARE_STRING (str (MON_9), str_utf8 (MON_9));
155 TEST_COMPARE_STRING (str (MON_10), str_utf8 (MON_10));
156 TEST_COMPARE_STRING (str (MON_11), str_utf8 (MON_11));
157 TEST_COMPARE_STRING (str (MON_12), str_utf8 (MON_12));
159 TEST_COMPARE_STRING (str (AM_STR), str_utf8 (AM_STR));
160 TEST_COMPARE_STRING (str (PM_STR), str_utf8 (PM_STR));
162 TEST_COMPARE_STRING (str (D_T_FMT), str_utf8 (D_T_FMT));
163 TEST_COMPARE_STRING (str (D_FMT), str_utf8 (D_FMT));
164 TEST_COMPARE_STRING (str (T_FMT), str_utf8 (T_FMT));
165 TEST_COMPARE_STRING (str (T_FMT_AMPM),
166 str_utf8 (T_FMT_AMPM));
168 TEST_COMPARE_STRING (str (ERA), str_utf8 (ERA));
169 TEST_COMPARE_STRING (str (ERA_YEAR), str_utf8 (ERA_YEAR));
170 TEST_COMPARE_STRING (str (ERA_D_FMT), str_utf8 (ERA_D_FMT));
171 TEST_COMPARE_STRING (str (ALT_DIGITS), str_utf8 (ALT_DIGITS));
172 TEST_COMPARE_STRING (str (ERA_D_T_FMT), str_utf8 (ERA_D_T_FMT));
173 TEST_COMPARE_STRING (str (ERA_T_FMT), str_utf8 (ERA_T_FMT));
174 TEST_COMPARE (word (_NL_TIME_ERA_NUM_ENTRIES),
175 word_utf8 (_NL_TIME_ERA_NUM_ENTRIES));
176 /* No array elements, so nothing to compare for _NL_TIME_ERA_ENTRIES. */
177 TEST_COMPARE (word (_NL_TIME_ERA_NUM_ENTRIES), 0);
179 TEST_COMPARE_STRING_WIDE (wstr (_NL_WABDAY_1), wstr_utf8 (_NL_WABDAY_1));
180 TEST_COMPARE_STRING_WIDE (wstr (_NL_WABDAY_2), wstr_utf8 (_NL_WABDAY_2));
181 TEST_COMPARE_STRING_WIDE (wstr (_NL_WABDAY_3), wstr_utf8 (_NL_WABDAY_3));
182 TEST_COMPARE_STRING_WIDE (wstr (_NL_WABDAY_4), wstr_utf8 (_NL_WABDAY_4));
183 TEST_COMPARE_STRING_WIDE (wstr (_NL_WABDAY_5), wstr_utf8 (_NL_WABDAY_5));
184 TEST_COMPARE_STRING_WIDE (wstr (_NL_WABDAY_6), wstr_utf8 (_NL_WABDAY_6));
185 TEST_COMPARE_STRING_WIDE (wstr (_NL_WABDAY_7), wstr_utf8 (_NL_WABDAY_7));
187 TEST_COMPARE_STRING_WIDE (wstr (_NL_WDAY_1), wstr_utf8 (_NL_WDAY_1));
188 TEST_COMPARE_STRING_WIDE (wstr (_NL_WDAY_2), wstr_utf8 (_NL_WDAY_2));
189 TEST_COMPARE_STRING_WIDE (wstr (_NL_WDAY_3), wstr_utf8 (_NL_WDAY_3));
190 TEST_COMPARE_STRING_WIDE (wstr (_NL_WDAY_4), wstr_utf8 (_NL_WDAY_4));
191 TEST_COMPARE_STRING_WIDE (wstr (_NL_WDAY_5), wstr_utf8 (_NL_WDAY_5));
192 TEST_COMPARE_STRING_WIDE (wstr (_NL_WDAY_6), wstr_utf8 (_NL_WDAY_6));
193 TEST_COMPARE_STRING_WIDE (wstr (_NL_WDAY_7), wstr_utf8 (_NL_WDAY_7));
195 TEST_COMPARE_STRING_WIDE (wstr (_NL_WABMON_1), wstr_utf8 (_NL_WABMON_1));
196 TEST_COMPARE_STRING_WIDE (wstr (_NL_WABMON_2), wstr_utf8 (_NL_WABMON_2));
197 TEST_COMPARE_STRING_WIDE (wstr (_NL_WABMON_3), wstr_utf8 (_NL_WABMON_3));
198 TEST_COMPARE_STRING_WIDE (wstr (_NL_WABMON_4), wstr_utf8 (_NL_WABMON_4));
199 TEST_COMPARE_STRING_WIDE (wstr (_NL_WABMON_5), wstr_utf8 (_NL_WABMON_5));
200 TEST_COMPARE_STRING_WIDE (wstr (_NL_WABMON_6), wstr_utf8 (_NL_WABMON_6));
201 TEST_COMPARE_STRING_WIDE (wstr (_NL_WABMON_7), wstr_utf8 (_NL_WABMON_7));
202 TEST_COMPARE_STRING_WIDE (wstr (_NL_WABMON_8), wstr_utf8 (_NL_WABMON_8));
203 TEST_COMPARE_STRING_WIDE (wstr (_NL_WABMON_9), wstr_utf8 (_NL_WABMON_9));
204 TEST_COMPARE_STRING_WIDE (wstr (_NL_WABMON_10), wstr_utf8 (_NL_WABMON_10));
205 TEST_COMPARE_STRING_WIDE (wstr (_NL_WABMON_11), wstr_utf8 (_NL_WABMON_11));
206 TEST_COMPARE_STRING_WIDE (wstr (_NL_WABMON_12), wstr_utf8 (_NL_WABMON_12));
208 TEST_COMPARE_STRING_WIDE (wstr (_NL_WMON_1), wstr_utf8 (_NL_WMON_1));
209 TEST_COMPARE_STRING_WIDE (wstr (_NL_WMON_2), wstr_utf8 (_NL_WMON_2));
210 TEST_COMPARE_STRING_WIDE (wstr (_NL_WMON_3), wstr_utf8 (_NL_WMON_3));
211 TEST_COMPARE_STRING_WIDE (wstr (_NL_WMON_4), wstr_utf8 (_NL_WMON_4));
212 TEST_COMPARE_STRING_WIDE (wstr (_NL_WMON_5), wstr_utf8 (_NL_WMON_5));
213 TEST_COMPARE_STRING_WIDE (wstr (_NL_WMON_6), wstr_utf8 (_NL_WMON_6));
214 TEST_COMPARE_STRING_WIDE (wstr (_NL_WMON_7), wstr_utf8 (_NL_WMON_7));
215 TEST_COMPARE_STRING_WIDE (wstr (_NL_WMON_8), wstr_utf8 (_NL_WMON_8));
216 TEST_COMPARE_STRING_WIDE (wstr (_NL_WMON_9), wstr_utf8 (_NL_WMON_9));
217 TEST_COMPARE_STRING_WIDE (wstr (_NL_WMON_10), wstr_utf8 (_NL_WMON_10));
218 TEST_COMPARE_STRING_WIDE (wstr (_NL_WMON_11), wstr_utf8 (_NL_WMON_11));
219 TEST_COMPARE_STRING_WIDE (wstr (_NL_WMON_12), wstr_utf8 (_NL_WMON_12));
221 TEST_COMPARE_STRING_WIDE (wstr (_NL_WAM_STR), wstr_utf8 (_NL_WAM_STR));
222 TEST_COMPARE_STRING_WIDE (wstr (_NL_WPM_STR), wstr_utf8 (_NL_WPM_STR));
224 TEST_COMPARE_STRING_WIDE (wstr (_NL_WD_T_FMT), wstr_utf8 (_NL_WD_T_FMT));
225 TEST_COMPARE_STRING_WIDE (wstr (_NL_WD_FMT), wstr_utf8 (_NL_WD_FMT));
226 TEST_COMPARE_STRING_WIDE (wstr (_NL_WT_FMT), wstr_utf8 (_NL_WT_FMT));
227 TEST_COMPARE_STRING_WIDE (wstr (_NL_WT_FMT_AMPM),
228 wstr_utf8 (_NL_WT_FMT_AMPM));
230 TEST_COMPARE_STRING_WIDE (wstr (_NL_WERA_YEAR), wstr_utf8 (_NL_WERA_YEAR));
231 TEST_COMPARE_STRING_WIDE (wstr (_NL_WERA_D_FMT), wstr_utf8 (_NL_WERA_D_FMT));
232 TEST_COMPARE_STRING_WIDE (wstr (_NL_WALT_DIGITS),
233 wstr_utf8 (_NL_WALT_DIGITS));
234 TEST_COMPARE_STRING_WIDE (wstr (_NL_WERA_D_T_FMT),
235 wstr_utf8 (_NL_WERA_D_T_FMT));
236 TEST_COMPARE_STRING_WIDE (wstr (_NL_WERA_T_FMT), wstr_utf8 (_NL_WERA_T_FMT));
238 /* This is somewhat inconsistent, but see locale/categories.def. */
239 TEST_COMPARE (byte (_NL_TIME_WEEK_NDAYS), byte_utf8 (_NL_TIME_WEEK_NDAYS));
240 TEST_COMPARE (word (_NL_TIME_WEEK_1STDAY),
241 word_utf8 (_NL_TIME_WEEK_1STDAY));
242 TEST_COMPARE (byte (_NL_TIME_WEEK_1STWEEK),
243 byte_utf8 (_NL_TIME_WEEK_1STWEEK));
244 TEST_COMPARE (byte (_NL_TIME_FIRST_WEEKDAY),
245 byte_utf8 (_NL_TIME_FIRST_WEEKDAY));
246 TEST_COMPARE (byte (_NL_TIME_FIRST_WORKDAY),
247 byte_utf8 (_NL_TIME_FIRST_WORKDAY));
248 TEST_COMPARE (byte (_NL_TIME_CAL_DIRECTION),
249 byte_utf8 (_NL_TIME_CAL_DIRECTION));
250 TEST_COMPARE_STRING (str (_NL_TIME_TIMEZONE), str_utf8 (_NL_TIME_TIMEZONE));
252 TEST_COMPARE_STRING (str (_DATE_FMT), str_utf8 (_DATE_FMT));
253 TEST_COMPARE_STRING_WIDE (wstr (_NL_W_DATE_FMT), wstr_utf8 (_NL_W_DATE_FMT));
255 /* Expected difference. */
256 TEST_COMPARE_STRING (str (_NL_TIME_CODESET), "ANSI_X3.4-1968");
257 TEST_COMPARE_STRING (str_utf8 (_NL_TIME_CODESET), "UTF-8");
259 TEST_COMPARE_STRING (str (ALTMON_1), str_utf8 (ALTMON_1));
260 TEST_COMPARE_STRING (str (ALTMON_2), str_utf8 (ALTMON_2));
261 TEST_COMPARE_STRING (str (ALTMON_3), str_utf8 (ALTMON_3));
262 TEST_COMPARE_STRING (str (ALTMON_4), str_utf8 (ALTMON_4));
263 TEST_COMPARE_STRING (str (ALTMON_5), str_utf8 (ALTMON_5));
264 TEST_COMPARE_STRING (str (ALTMON_6), str_utf8 (ALTMON_6));
265 TEST_COMPARE_STRING (str (ALTMON_7), str_utf8 (ALTMON_7));
266 TEST_COMPARE_STRING (str (ALTMON_8), str_utf8 (ALTMON_8));
267 TEST_COMPARE_STRING (str (ALTMON_9), str_utf8 (ALTMON_9));
268 TEST_COMPARE_STRING (str (ALTMON_10), str_utf8 (ALTMON_10));
269 TEST_COMPARE_STRING (str (ALTMON_11), str_utf8 (ALTMON_11));
270 TEST_COMPARE_STRING (str (ALTMON_12), str_utf8 (ALTMON_12));
272 TEST_COMPARE_STRING_WIDE (wstr (_NL_WALTMON_1), wstr_utf8 (_NL_WALTMON_1));
273 TEST_COMPARE_STRING_WIDE (wstr (_NL_WALTMON_2), wstr_utf8 (_NL_WALTMON_2));
274 TEST_COMPARE_STRING_WIDE (wstr (_NL_WALTMON_3), wstr_utf8 (_NL_WALTMON_3));
275 TEST_COMPARE_STRING_WIDE (wstr (_NL_WALTMON_4), wstr_utf8 (_NL_WALTMON_4));
276 TEST_COMPARE_STRING_WIDE (wstr (_NL_WALTMON_5), wstr_utf8 (_NL_WALTMON_5));
277 TEST_COMPARE_STRING_WIDE (wstr (_NL_WALTMON_6), wstr_utf8 (_NL_WALTMON_6));
278 TEST_COMPARE_STRING_WIDE (wstr (_NL_WALTMON_7), wstr_utf8 (_NL_WALTMON_7));
279 TEST_COMPARE_STRING_WIDE (wstr (_NL_WALTMON_8), wstr_utf8 (_NL_WALTMON_8));
280 TEST_COMPARE_STRING_WIDE (wstr (_NL_WALTMON_9), wstr_utf8 (_NL_WALTMON_9));
281 TEST_COMPARE_STRING_WIDE (wstr (_NL_WALTMON_10), wstr_utf8 (_NL_WALTMON_10));
282 TEST_COMPARE_STRING_WIDE (wstr (_NL_WALTMON_11), wstr_utf8 (_NL_WALTMON_11));
283 TEST_COMPARE_STRING_WIDE (wstr (_NL_WALTMON_12), wstr_utf8 (_NL_WALTMON_12));
285 TEST_COMPARE_STRING (str (_NL_ABALTMON_1), str_utf8 (_NL_ABALTMON_1));
286 TEST_COMPARE_STRING (str (_NL_ABALTMON_2), str_utf8 (_NL_ABALTMON_2));
287 TEST_COMPARE_STRING (str (_NL_ABALTMON_3), str_utf8 (_NL_ABALTMON_3));
288 TEST_COMPARE_STRING (str (_NL_ABALTMON_4), str_utf8 (_NL_ABALTMON_4));
289 TEST_COMPARE_STRING (str (_NL_ABALTMON_5), str_utf8 (_NL_ABALTMON_5));
290 TEST_COMPARE_STRING (str (_NL_ABALTMON_6), str_utf8 (_NL_ABALTMON_6));
291 TEST_COMPARE_STRING (str (_NL_ABALTMON_7), str_utf8 (_NL_ABALTMON_7));
292 TEST_COMPARE_STRING (str (_NL_ABALTMON_8), str_utf8 (_NL_ABALTMON_8));
293 TEST_COMPARE_STRING (str (_NL_ABALTMON_9), str_utf8 (_NL_ABALTMON_9));
294 TEST_COMPARE_STRING (str (_NL_ABALTMON_10), str_utf8 (_NL_ABALTMON_10));
295 TEST_COMPARE_STRING (str (_NL_ABALTMON_11), str_utf8 (_NL_ABALTMON_11));
296 TEST_COMPARE_STRING (str (_NL_ABALTMON_12), str_utf8 (_NL_ABALTMON_12));
298 TEST_COMPARE_STRING_WIDE (wstr (_NL_WABALTMON_1),
299 wstr_utf8 (_NL_WABALTMON_1));
300 TEST_COMPARE_STRING_WIDE (wstr (_NL_WABALTMON_2),
301 wstr_utf8 (_NL_WABALTMON_2));
302 TEST_COMPARE_STRING_WIDE (wstr (_NL_WABALTMON_3),
303 wstr_utf8 (_NL_WABALTMON_3));
304 TEST_COMPARE_STRING_WIDE (wstr (_NL_WABALTMON_4),
305 wstr_utf8 (_NL_WABALTMON_4));
306 TEST_COMPARE_STRING_WIDE (wstr (_NL_WABALTMON_5),
307 wstr_utf8 (_NL_WABALTMON_5));
308 TEST_COMPARE_STRING_WIDE (wstr (_NL_WABALTMON_6),
309 wstr_utf8 (_NL_WABALTMON_6));
310 TEST_COMPARE_STRING_WIDE (wstr (_NL_WABALTMON_7),
311 wstr_utf8 (_NL_WABALTMON_7));
312 TEST_COMPARE_STRING_WIDE (wstr (_NL_WABALTMON_8),
313 wstr_utf8 (_NL_WABALTMON_8));
314 TEST_COMPARE_STRING_WIDE (wstr (_NL_WABALTMON_9),
315 wstr_utf8 (_NL_WABALTMON_9));
316 TEST_COMPARE_STRING_WIDE (wstr (_NL_WABALTMON_10),
317 wstr_utf8 (_NL_WABALTMON_10));
318 TEST_COMPARE_STRING_WIDE (wstr (_NL_WABALTMON_11),
319 wstr_utf8 (_NL_WABALTMON_11));
320 TEST_COMPARE_STRING_WIDE (wstr (_NL_WABALTMON_12),
321 wstr_utf8 (_NL_WABALTMON_12));
323 /* LC_COLLATE. Mostly untested, only expected differences. */
324 TEST_COMPARE_STRING (str (_NL_COLLATE_CODESET), "ANSI_X3.4-1968");
325 TEST_COMPARE_STRING (str_utf8 (_NL_COLLATE_CODESET), "UTF-8");
327 /* LC_CTYPE. Mostly untested, only expected differences. */
328 TEST_COMPARE_STRING (str (CODESET), "ANSI_X3.4-1968");
329 TEST_COMPARE_STRING (str_utf8 (CODESET), "UTF-8");
331 /* LC_MONETARY. */
332 TEST_COMPARE_STRING (str (INT_CURR_SYMBOL), str_utf8 (INT_CURR_SYMBOL));
333 TEST_COMPARE_STRING (str (CURRENCY_SYMBOL), str_utf8 (CURRENCY_SYMBOL));
334 TEST_COMPARE_STRING (str (MON_DECIMAL_POINT), str_utf8 (MON_DECIMAL_POINT));
335 TEST_COMPARE_STRING (str (MON_THOUSANDS_SEP), str_utf8 (MON_THOUSANDS_SEP));
336 TEST_COMPARE_STRING (str (MON_GROUPING), str_utf8 (MON_GROUPING));
337 TEST_COMPARE_STRING (str (POSITIVE_SIGN), str_utf8 (POSITIVE_SIGN));
338 TEST_COMPARE_STRING (str (NEGATIVE_SIGN), str_utf8 (NEGATIVE_SIGN));
339 TEST_COMPARE (byte (INT_FRAC_DIGITS), byte_utf8 (INT_FRAC_DIGITS));
340 TEST_COMPARE (byte (FRAC_DIGITS), byte_utf8 (FRAC_DIGITS));
341 TEST_COMPARE (byte (P_CS_PRECEDES), byte_utf8 (P_CS_PRECEDES));
342 TEST_COMPARE (byte (P_SEP_BY_SPACE), byte_utf8 (P_SEP_BY_SPACE));
343 TEST_COMPARE (byte (N_CS_PRECEDES), byte_utf8 (N_CS_PRECEDES));
344 TEST_COMPARE (byte (N_SEP_BY_SPACE), byte_utf8 (N_SEP_BY_SPACE));
345 TEST_COMPARE (byte (P_SIGN_POSN), byte_utf8 (P_SIGN_POSN));
346 TEST_COMPARE (byte (N_SIGN_POSN), byte_utf8 (N_SIGN_POSN));
347 TEST_COMPARE_STRING (str (CRNCYSTR), str_utf8 (CRNCYSTR));
348 TEST_COMPARE (byte (INT_P_CS_PRECEDES), byte_utf8 (INT_P_CS_PRECEDES));
349 TEST_COMPARE (byte (INT_P_SEP_BY_SPACE), byte_utf8 (INT_P_SEP_BY_SPACE));
350 TEST_COMPARE (byte (INT_N_CS_PRECEDES), byte_utf8 (INT_N_CS_PRECEDES));
351 TEST_COMPARE (byte (INT_N_SEP_BY_SPACE), byte_utf8 (INT_N_SEP_BY_SPACE));
352 TEST_COMPARE (byte (INT_P_SIGN_POSN), byte_utf8 (INT_P_SIGN_POSN));
353 TEST_COMPARE (byte (INT_N_SIGN_POSN), byte_utf8 (INT_N_SIGN_POSN));
354 TEST_COMPARE_STRING (str (_NL_MONETARY_DUO_INT_CURR_SYMBOL),
355 str_utf8 (_NL_MONETARY_DUO_INT_CURR_SYMBOL));
356 TEST_COMPARE_STRING (str (_NL_MONETARY_DUO_CURRENCY_SYMBOL),
357 str_utf8 (_NL_MONETARY_DUO_CURRENCY_SYMBOL));
358 TEST_COMPARE (byte (_NL_MONETARY_DUO_INT_FRAC_DIGITS),
359 byte_utf8 (_NL_MONETARY_DUO_INT_FRAC_DIGITS));
360 TEST_COMPARE (byte (_NL_MONETARY_DUO_FRAC_DIGITS),
361 byte_utf8 (_NL_MONETARY_DUO_FRAC_DIGITS));
362 TEST_COMPARE (byte (_NL_MONETARY_DUO_P_CS_PRECEDES),
363 byte_utf8 (_NL_MONETARY_DUO_P_CS_PRECEDES));
364 TEST_COMPARE (byte (_NL_MONETARY_DUO_P_SEP_BY_SPACE),
365 byte_utf8 (_NL_MONETARY_DUO_P_SEP_BY_SPACE));
366 TEST_COMPARE (byte (_NL_MONETARY_DUO_N_CS_PRECEDES),
367 byte_utf8 (_NL_MONETARY_DUO_N_CS_PRECEDES));
368 TEST_COMPARE (byte (_NL_MONETARY_DUO_N_SEP_BY_SPACE),
369 byte_utf8 (_NL_MONETARY_DUO_N_SEP_BY_SPACE));
370 TEST_COMPARE (byte (_NL_MONETARY_DUO_INT_P_CS_PRECEDES),
371 byte_utf8 (_NL_MONETARY_DUO_INT_P_CS_PRECEDES));
372 TEST_COMPARE (byte (_NL_MONETARY_DUO_INT_P_SEP_BY_SPACE),
373 byte_utf8 (_NL_MONETARY_DUO_INT_P_SEP_BY_SPACE));
374 TEST_COMPARE (byte (_NL_MONETARY_DUO_INT_N_CS_PRECEDES),
375 byte_utf8 (_NL_MONETARY_DUO_INT_N_CS_PRECEDES));
376 TEST_COMPARE (byte (_NL_MONETARY_DUO_INT_N_SEP_BY_SPACE),
377 byte_utf8 (_NL_MONETARY_DUO_INT_N_SEP_BY_SPACE));
378 TEST_COMPARE (byte (_NL_MONETARY_DUO_INT_P_SIGN_POSN),
379 byte_utf8 (_NL_MONETARY_DUO_INT_P_SIGN_POSN));
380 TEST_COMPARE (byte (_NL_MONETARY_DUO_INT_N_SIGN_POSN),
381 byte_utf8 (_NL_MONETARY_DUO_INT_N_SIGN_POSN));
382 TEST_COMPARE (byte (_NL_MONETARY_DUO_P_SIGN_POSN),
383 byte_utf8 (_NL_MONETARY_DUO_P_SIGN_POSN));
384 TEST_COMPARE (byte (_NL_MONETARY_DUO_N_SIGN_POSN),
385 byte_utf8 (_NL_MONETARY_DUO_N_SIGN_POSN));
386 TEST_COMPARE (byte (_NL_MONETARY_DUO_INT_P_SIGN_POSN),
387 byte_utf8 (_NL_MONETARY_DUO_INT_P_SIGN_POSN));
388 TEST_COMPARE (byte (_NL_MONETARY_DUO_INT_N_SIGN_POSN),
389 byte_utf8 (_NL_MONETARY_DUO_INT_N_SIGN_POSN));
390 TEST_COMPARE (word (_NL_MONETARY_UNO_VALID_FROM),
391 word_utf8 (_NL_MONETARY_UNO_VALID_FROM));
392 TEST_COMPARE (word (_NL_MONETARY_UNO_VALID_TO),
393 word_utf8 (_NL_MONETARY_UNO_VALID_TO));
394 TEST_COMPARE (word (_NL_MONETARY_DUO_VALID_FROM),
395 word_utf8 (_NL_MONETARY_DUO_VALID_FROM));
396 TEST_COMPARE (word (_NL_MONETARY_DUO_VALID_TO),
397 word_utf8 (_NL_MONETARY_DUO_VALID_TO));
398 /* _NL_MONETARY_CONVERSION_RATE cannot be tested (word array). */
399 TEST_COMPARE (word (_NL_MONETARY_DECIMAL_POINT_WC),
400 word_utf8 (_NL_MONETARY_DECIMAL_POINT_WC));
401 TEST_COMPARE (word (_NL_MONETARY_THOUSANDS_SEP_WC),
402 word_utf8 (_NL_MONETARY_THOUSANDS_SEP_WC));
403 /* Expected difference. */
404 TEST_COMPARE_STRING (str (_NL_MONETARY_CODESET), "ANSI_X3.4-1968");
405 TEST_COMPARE_STRING (str_utf8 (_NL_MONETARY_CODESET), "UTF-8");
407 /* LC_NUMERIC. */
409 TEST_COMPARE_STRING (str (DECIMAL_POINT), str_utf8 (DECIMAL_POINT));
410 TEST_COMPARE_STRING (str (RADIXCHAR), str_utf8 (RADIXCHAR));
411 TEST_COMPARE_STRING (str (THOUSANDS_SEP), str_utf8 (THOUSANDS_SEP));
412 TEST_COMPARE_STRING (str (THOUSEP), str_utf8 (THOUSEP));
413 TEST_COMPARE_STRING (str (GROUPING), str_utf8 (GROUPING));
414 TEST_COMPARE (word (_NL_NUMERIC_DECIMAL_POINT_WC),
415 word_utf8 (_NL_NUMERIC_DECIMAL_POINT_WC));
416 TEST_COMPARE (word (_NL_NUMERIC_THOUSANDS_SEP_WC),
417 word_utf8 (_NL_NUMERIC_THOUSANDS_SEP_WC));
418 /* Expected difference. */
419 TEST_COMPARE_STRING (str (_NL_NUMERIC_CODESET), "ANSI_X3.4-1968");
420 TEST_COMPARE_STRING (str_utf8 (_NL_NUMERIC_CODESET), "UTF-8");
422 /* LC_MESSAGES. */
424 TEST_COMPARE_STRING (str (YESEXPR), str_utf8 (YESEXPR));
425 TEST_COMPARE_STRING (str (NOEXPR), str_utf8 (NOEXPR));
426 TEST_COMPARE_STRING (str (YESSTR), str_utf8 (YESSTR));
427 TEST_COMPARE_STRING (str (NOSTR), str_utf8 (NOSTR));
428 /* Expected difference. */
429 TEST_COMPARE_STRING (str (_NL_MESSAGES_CODESET), "ANSI_X3.4-1968");
430 TEST_COMPARE_STRING (str_utf8 (_NL_MESSAGES_CODESET), "UTF-8");
432 /* LC_PAPER. */
434 TEST_COMPARE (word (_NL_PAPER_HEIGHT), word_utf8 (_NL_PAPER_HEIGHT));
435 TEST_COMPARE (word (_NL_PAPER_WIDTH), word_utf8 (_NL_PAPER_WIDTH));
436 /* Expected difference. */
437 TEST_COMPARE_STRING (str (_NL_PAPER_CODESET), "ANSI_X3.4-1968");
438 TEST_COMPARE_STRING (str_utf8 (_NL_PAPER_CODESET), "UTF-8");
440 /* LC_NAME. */
442 TEST_COMPARE_STRING (str (_NL_NAME_NAME_FMT),
443 str_utf8 (_NL_NAME_NAME_FMT));
444 TEST_COMPARE_STRING (str (_NL_NAME_NAME_GEN),
445 str_utf8 (_NL_NAME_NAME_GEN));
446 TEST_COMPARE_STRING (str (_NL_NAME_NAME_MR),
447 str_utf8 (_NL_NAME_NAME_MR));
448 TEST_COMPARE_STRING (str (_NL_NAME_NAME_MRS),
449 str_utf8 (_NL_NAME_NAME_MRS));
450 TEST_COMPARE_STRING (str (_NL_NAME_NAME_MISS),
451 str_utf8 (_NL_NAME_NAME_MISS));
452 TEST_COMPARE_STRING (str (_NL_NAME_NAME_MS),
453 str_utf8 (_NL_NAME_NAME_MS));
454 /* Expected difference. */
455 TEST_COMPARE_STRING (str (_NL_NAME_CODESET), "ANSI_X3.4-1968");
456 TEST_COMPARE_STRING (str_utf8 (_NL_NAME_CODESET), "UTF-8");
458 /* LC_ADDRESS. */
460 TEST_COMPARE_STRING (str (_NL_ADDRESS_POSTAL_FMT),
461 str_utf8 (_NL_ADDRESS_POSTAL_FMT));
462 TEST_COMPARE_STRING (str (_NL_ADDRESS_COUNTRY_NAME),
463 str_utf8 (_NL_ADDRESS_COUNTRY_NAME));
464 TEST_COMPARE_STRING (str (_NL_ADDRESS_COUNTRY_POST),
465 str_utf8 (_NL_ADDRESS_COUNTRY_POST));
466 TEST_COMPARE_STRING (str (_NL_ADDRESS_COUNTRY_AB2),
467 str_utf8 (_NL_ADDRESS_COUNTRY_AB2));
468 TEST_COMPARE_STRING (str (_NL_ADDRESS_COUNTRY_AB3),
469 str_utf8 (_NL_ADDRESS_COUNTRY_AB3));
470 TEST_COMPARE_STRING (str (_NL_ADDRESS_COUNTRY_CAR),
471 str_utf8 (_NL_ADDRESS_COUNTRY_CAR));
472 TEST_COMPARE (word (_NL_ADDRESS_COUNTRY_NUM),
473 word_utf8 (_NL_ADDRESS_COUNTRY_NUM));
474 TEST_COMPARE_STRING (str (_NL_ADDRESS_COUNTRY_ISBN),
475 str_utf8 (_NL_ADDRESS_COUNTRY_ISBN));
476 TEST_COMPARE_STRING (str (_NL_ADDRESS_LANG_NAME),
477 str_utf8 (_NL_ADDRESS_LANG_NAME));
478 TEST_COMPARE_STRING (str (_NL_ADDRESS_LANG_AB),
479 str_utf8 (_NL_ADDRESS_LANG_AB));
480 TEST_COMPARE_STRING (str (_NL_ADDRESS_LANG_TERM),
481 str_utf8 (_NL_ADDRESS_LANG_TERM));
482 TEST_COMPARE_STRING (str (_NL_ADDRESS_LANG_LIB),
483 str_utf8 (_NL_ADDRESS_LANG_LIB));
484 /* Expected difference. */
485 TEST_COMPARE_STRING (str (_NL_ADDRESS_CODESET), "ANSI_X3.4-1968");
486 TEST_COMPARE_STRING (str_utf8 (_NL_ADDRESS_CODESET), "UTF-8");
488 /* LC_TELEPHONE. */
490 TEST_COMPARE_STRING (str (_NL_TELEPHONE_TEL_INT_FMT),
491 str_utf8 (_NL_TELEPHONE_TEL_INT_FMT));
492 TEST_COMPARE_STRING (str (_NL_TELEPHONE_TEL_DOM_FMT),
493 str_utf8 (_NL_TELEPHONE_TEL_DOM_FMT));
494 TEST_COMPARE_STRING (str (_NL_TELEPHONE_INT_SELECT),
495 str_utf8 (_NL_TELEPHONE_INT_SELECT));
496 TEST_COMPARE_STRING (str (_NL_TELEPHONE_INT_PREFIX),
497 str_utf8 (_NL_TELEPHONE_INT_PREFIX));
498 /* Expected difference. */
499 TEST_COMPARE_STRING (str (_NL_TELEPHONE_CODESET), "ANSI_X3.4-1968");
500 TEST_COMPARE_STRING (str_utf8 (_NL_TELEPHONE_CODESET), "UTF-8");
502 /* LC_MEASUREMENT. */
504 TEST_COMPARE (byte (_NL_MEASUREMENT_MEASUREMENT),
505 byte_utf8 (_NL_MEASUREMENT_MEASUREMENT));
506 /* Expected difference. */
507 TEST_COMPARE_STRING (str (_NL_MEASUREMENT_CODESET), "ANSI_X3.4-1968");
508 TEST_COMPARE_STRING (str_utf8 (_NL_MEASUREMENT_CODESET), "UTF-8");
510 /* LC_IDENTIFICATION is skipped since C.UTF-8 is distinct from C. */
512 /* _NL_IDENTIFICATION_CATEGORY cannot be tested because it is a
513 string array. */
514 /* Expected difference. */
515 TEST_COMPARE_STRING (str (_NL_IDENTIFICATION_CODESET), "ANSI_X3.4-1968");
516 TEST_COMPARE_STRING (str_utf8 (_NL_IDENTIFICATION_CODESET), "UTF-8");
519 static int
520 do_test (void)
522 puts ("info: using setlocale and nl_langinfo");
523 one_pass ();
525 puts ("info: using nl_langinfo_l");
527 c_utf8 = newlocale (LC_ALL_MASK, "C.UTF-8", (locale_t) 0);
528 TEST_VERIFY_EXIT (c_utf8 != (locale_t) 0);
530 switch_to_c ();
531 use_nl_langinfo_l = true;
532 one_pass ();
534 freelocale (c_utf8);
536 return 0;
539 #include <support/test-driver.c>