2 * Unit test suite for locale functions.
4 * Copyright 2010 Piotr Caban for CodeWeavers
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This 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 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
23 #include "wine/test.h"
26 static BOOL (__cdecl
*p__crtGetStringTypeW
)(DWORD
, DWORD
, const wchar_t*, int, WORD
*);
27 static int (__cdecl
*pmemcpy_s
)(void *, size_t, void*, size_t);
28 static int (__cdecl
*p___mb_cur_max_func
)(void);
29 static int *(__cdecl
*p__p___mb_cur_max
)(void);
30 void* __cdecl
_Gettnames(void);
32 static void init(void)
34 HMODULE hmod
= GetModuleHandleA("msvcrt.dll");
36 p__crtGetStringTypeW
= (void*)GetProcAddress(hmod
, "__crtGetStringTypeW");
37 pmemcpy_s
= (void*)GetProcAddress(hmod
, "memcpy_s");
38 p___mb_cur_max_func
= (void*)GetProcAddress(hmod
, "___mb_cur_max_func");
39 p__p___mb_cur_max
= (void*)GetProcAddress(hmod
, "__p___mb_cur_max");
42 static void test_setlocale(void)
44 static const char lc_all
[] = "LC_COLLATE=C;LC_CTYPE=C;"
45 "LC_MONETARY=Greek_Greece.1253;LC_NUMERIC=Polish_Poland.1250;LC_TIME=C";
51 ret
= setlocale(20, "C");
52 ok(ret
== NULL
, "ret = %s\n", ret
);
54 ret
= setlocale(LC_ALL
, "C");
55 ok(!strcmp(ret
, "C"), "ret = %s\n", ret
);
57 ret
= setlocale(LC_ALL
, NULL
);
58 ok(!strcmp(ret
, "C"), "ret = %s\n", ret
);
60 if(!setlocale(LC_NUMERIC
, "Polish")
61 || !setlocale(LC_NUMERIC
, "Greek")
62 || !setlocale(LC_NUMERIC
, "German")
63 || !setlocale(LC_NUMERIC
, "English")) {
64 win_skip("System with limited locales\n");
68 ret
= setlocale(LC_NUMERIC
, "Polish");
69 ok(!strcmp(ret
, "Polish_Poland.1250"), "ret = %s\n", ret
);
71 ret
= setlocale(LC_MONETARY
, "Greek");
72 ok(!strcmp(ret
, "Greek_Greece.1253"), "ret = %s\n", ret
);
74 ret
= setlocale(LC_ALL
, NULL
);
75 ok(!strcmp(ret
, lc_all
), "ret = %s\n", ret
);
78 ret
= setlocale(LC_ALL
, buf
);
79 ok(!strcmp(ret
, lc_all
), "ret = %s\n", ret
);
81 ret
= setlocale(LC_ALL
, "German");
82 ok(!strcmp(ret
, "German_Germany.1252"), "ret = %s\n", ret
);
84 ret
= setlocale(LC_ALL
, "american");
85 ok(ret
!= NULL
|| broken (ret
== NULL
), "ret == NULL\n");
87 ok(!strcmp(ret
, "English_United States.1252"), "ret = %s\n", ret
);
89 ret
= setlocale(LC_ALL
, "american english");
90 ok(ret
!= NULL
|| broken (ret
== NULL
), "ret == NULL\n");
92 ok(!strcmp(ret
, "English_United States.1252"), "ret = %s\n", ret
);
94 ret
= setlocale(LC_ALL
, "american-english");
95 ok(ret
!= NULL
|| broken (ret
== NULL
), "ret == NULL\n");
97 ok(!strcmp(ret
, "English_United States.1252"), "ret = %s\n", ret
);
99 ret
= setlocale(LC_ALL
, "australian");
100 ok(ret
!= NULL
|| broken (ret
== NULL
), "ret == NULL\n");
102 ok(!strcmp(ret
, "English_Australia.1252"), "ret = %s\n", ret
);
104 ret
= setlocale(LC_ALL
, "belgian");
105 ok(ret
!= NULL
|| broken (ret
== NULL
), "ret == NULL\n");
107 ok(!strcmp(ret
, "Dutch_Belgium.1252"), "ret = %s\n", ret
);
109 ret
= setlocale(LC_ALL
, "canadian");
110 ok(ret
!= NULL
|| broken (ret
== NULL
), "ret == NULL\n");
112 ok(!strcmp(ret
, "English_Canada.1252"), "ret = %s\n", ret
);
114 ret
= setlocale(LC_ALL
, "chinese");
115 ok(ret
!= NULL
|| broken (ret
== NULL
), "ret == NULL\n");
117 ok(!strcmp(ret
, "Chinese (Simplified)_People's Republic of China.936")
118 || !strcmp(ret
, "Chinese (Simplified)_China.936")
119 || broken(!strcmp(ret
, "Chinese_Taiwan.950")), "ret = %s\n", ret
);
121 ret
= setlocale(LC_ALL
, "chinese-simplified");
122 ok(ret
!= NULL
|| broken (ret
== NULL
), "ret == NULL\n");
124 ok(!strcmp(ret
, "Chinese (Simplified)_People's Republic of China.936")
125 || !strcmp(ret
, "Chinese (Simplified)_China.936")
126 || broken(!strcmp(ret
, "Chinese_People's Republic of China.936"))
127 || broken(!strcmp(ret
, "Chinese_Taiwan.950")), "ret = %s\n", ret
);
129 ret
= setlocale(LC_ALL
, "chinese-traditional");
130 ok(ret
!= NULL
|| broken (ret
== NULL
), "ret == NULL\n");
132 ok(!strcmp(ret
, "Chinese (Traditional)_Taiwan.950")
133 || broken(!strcmp(ret
, "Chinese_Taiwan.950")), "ret = %s\n", ret
);
135 ret
= setlocale(LC_ALL
, "chs");
136 ok(ret
!= NULL
|| broken (ret
== NULL
), "ret == NULL\n");
138 ok(!strcmp(ret
, "Chinese (Simplified)_People's Republic of China.936")
139 || !strcmp(ret
, "Chinese (Simplified)_China.936")
140 || broken(!strcmp(ret
, "Chinese_People's Republic of China.936")), "ret = %s\n", ret
);
142 ret
= setlocale(LC_ALL
, "cht");
143 ok(ret
!= NULL
|| broken (ret
== NULL
), "ret == NULL\n");
145 ok(!strcmp(ret
, "Chinese (Traditional)_Taiwan.950")
146 || broken(!strcmp(ret
, "Chinese_Taiwan.950")), "ret = %s\n", ret
);
148 ret
= setlocale(LC_ALL
, "Chinese_China.936");
149 ok(ret
!= NULL
|| broken (ret
== NULL
), "ret == NULL\n");
152 trace("Chinese_China.936=%s\n", ret
);
153 ok(!strcmp(ret
, "Chinese (Simplified)_People's Republic of China.936") /* Vista - Win7 */
154 || !strcmp(ret
, "Chinese (Simplified)_China.936") /* Win8 - Win10 */
155 || broken(!strcmp(ret
, "Chinese_People's Republic of China.936")), "ret = %s\n", ret
);
158 ret
= setlocale(LC_ALL
, "csy");
159 ok(ret
!= NULL
|| broken (ret
== NULL
), "ret == NULL\n");
161 ok(!strcmp(ret
, "Czech_Czech Republic.1250")
162 || !strcmp(ret
, "Czech_Czechia.1250"), "ret = %s\n", ret
);
164 ret
= setlocale(LC_ALL
, "czech");
165 ok(ret
!= NULL
|| broken (ret
== NULL
), "ret == NULL\n");
167 ok(!strcmp(ret
, "Czech_Czech Republic.1250")
168 || !strcmp(ret
, "Czech_Czechia.1250"), "ret = %s\n", ret
);
170 ret
= setlocale(LC_ALL
, "dan");
171 ok(ret
!= NULL
|| broken (ret
== NULL
), "ret == NULL\n");
173 ok(!strcmp(ret
, "Danish_Denmark.1252"), "ret = %s\n", ret
);
175 ret
= setlocale(LC_ALL
, "danish");
176 ok(ret
!= NULL
|| broken (ret
== NULL
), "ret == NULL\n");
178 ok(!strcmp(ret
, "Danish_Denmark.1252"), "ret = %s\n", ret
);
180 ret
= setlocale(LC_ALL
, "dea");
181 ok(ret
!= NULL
|| broken (ret
== NULL
), "ret == NULL\n");
183 ok(!strcmp(ret
, "German_Austria.1252"), "ret = %s\n", ret
);
185 ret
= setlocale(LC_ALL
, "des");
186 ok(ret
!= NULL
|| broken (ret
== NULL
), "ret == NULL\n");
188 ok(!strcmp(ret
, "German_Switzerland.1252"), "ret = %s\n", ret
);
190 ret
= setlocale(LC_ALL
, "deu");
191 ok(ret
!= NULL
|| broken (ret
== NULL
), "ret == NULL\n");
193 ok(!strcmp(ret
, "German_Germany.1252"), "ret = %s\n", ret
);
195 ret
= setlocale(LC_ALL
, "dutch");
196 ok(ret
!= NULL
|| broken (ret
== NULL
), "ret == NULL\n");
198 ok(!strcmp(ret
, "Dutch_Netherlands.1252"), "ret = %s\n", ret
);
200 ret
= setlocale(LC_ALL
, "dutch-belgian");
201 ok(ret
!= NULL
|| broken (ret
== NULL
), "ret == NULL\n");
203 ok(!strcmp(ret
, "Dutch_Belgium.1252")
204 || broken(!strcmp(ret
, "Dutch_Netherlands.1252")), "ret = %s\n", ret
);
206 ret
= setlocale(LC_ALL
, "ena");
207 ok(ret
!= NULL
|| broken (ret
== NULL
), "ret == NULL\n");
209 ok(!strcmp(ret
, "English_Australia.1252")
210 || broken(!strcmp(ret
, "English_United States.1252")), "ret = %s\n", ret
);
212 ret
= setlocale(LC_ALL
, "ell");
213 ok(ret
!= NULL
|| broken (ret
== NULL
), "ret == NULL\n");
215 ok(!strcmp(ret
, "Greek_Greece.1253"), "ret = %s\n", ret
);
217 ret
= setlocale(LC_ALL
, "enc");
218 ok(ret
!= NULL
|| broken (ret
== NULL
), "ret == NULL\n");
220 ok(!strcmp(ret
, "English_Canada.1252")
221 || broken(!strcmp(ret
, "English_United States.1252")), "ret = %s\n", ret
);
223 ret
= setlocale(LC_ALL
, "eng");
224 ok(ret
!= NULL
|| broken (ret
== NULL
), "ret == NULL\n");
226 ok(!strcmp(ret
, "English_United Kingdom.1252")
227 || broken(!strcmp(ret
, "English_United States.1252")), "ret = %s\n", ret
);
229 ret
= setlocale(LC_ALL
, "enu");
230 ok(ret
!= NULL
|| broken (ret
== NULL
), "ret == NULL\n");
232 ok(!strcmp(ret
, "English_United States.1252"), "ret = %s\n", ret
);
234 ret
= setlocale(LC_ALL
, "enz");
235 ok(ret
!= NULL
|| broken (ret
== NULL
), "ret == NULL\n");
237 ok(!strcmp(ret
, "English_New Zealand.1252")
238 || broken(!strcmp(ret
, "English_United States.1252")), "ret = %s\n", ret
);
240 ret
= setlocale(LC_ALL
, "english");
241 ok(ret
!= NULL
|| broken (ret
== NULL
), "ret == NULL\n");
243 ok(!strcmp(ret
, "English_United States.1252"), "ret = %s\n", ret
);
245 ret
= setlocale(LC_ALL
, "english-american");
246 ok(ret
!= NULL
|| broken (ret
== NULL
), "ret == NULL\n");
248 ok(!strcmp(ret
, "English_United States.1252"), "ret = %s\n", ret
);
250 ret
= setlocale(LC_ALL
, "english-aus");
251 ok(ret
!= NULL
|| broken (ret
== NULL
), "ret == NULL\n");
253 ok(!strcmp(ret
, "English_Australia.1252")
254 || broken(!strcmp(ret
, "English_United States.1252")), "ret = %s\n", ret
);
256 ret
= setlocale(LC_ALL
, "english-can");
257 ok(ret
!= NULL
|| broken (ret
== NULL
), "ret == NULL\n");
259 ok(!strcmp(ret
, "English_Canada.1252")
260 || broken(!strcmp(ret
, "English_United States.1252")), "ret = %s\n", ret
);
262 ret
= setlocale(LC_ALL
, "english-nz");
263 ok(ret
!= NULL
|| broken (ret
== NULL
), "ret == NULL\n");
265 ok(!strcmp(ret
, "English_New Zealand.1252")
266 || broken(!strcmp(ret
, "English_United States.1252")), "ret = %s\n", ret
);
268 ret
= setlocale(LC_ALL
, "english-uk");
269 ok(ret
!= NULL
|| broken (ret
== NULL
), "ret == NULL\n");
271 ok(!strcmp(ret
, "English_United Kingdom.1252")
272 || broken(!strcmp(ret
, "English_United States.1252")), "ret = %s\n", ret
);
274 ret
= setlocale(LC_ALL
, "english-us");
275 ok(ret
!= NULL
|| broken (ret
== NULL
), "ret == NULL\n");
277 ok(!strcmp(ret
, "English_United States.1252"), "ret = %s\n", ret
);
279 ret
= setlocale(LC_ALL
, "english-usa");
280 ok(ret
!= NULL
|| broken (ret
== NULL
), "ret == NULL\n");
282 ok(!strcmp(ret
, "English_United States.1252"), "ret = %s\n", ret
);
284 ret
= setlocale(LC_ALL
, "esm");
285 ok(ret
!= NULL
|| broken (ret
== NULL
), "ret == NULL\n");
287 ok(!strcmp(ret
, "Spanish_Mexico.1252"), "ret = %s\n", ret
);
289 ret
= setlocale(LC_ALL
, "esn");
290 ok(ret
!= NULL
|| broken (ret
== NULL
), "ret == NULL\n");
292 ok(!strcmp(ret
, "Spanish_Spain.1252")
293 || broken(!strcmp(ret
, "Spanish - Modern Sort_Spain.1252")), "ret = %s\n", ret
);
295 ret
= setlocale(LC_ALL
, "esp");
296 ok(ret
!= NULL
|| broken (ret
== NULL
), "ret == NULL\n");
298 ok(!strcmp(ret
, "Spanish_Spain.1252")
299 || broken(!strcmp(ret
, "Spanish - Traditional Sort_Spain.1252")), "ret = %s\n", ret
);
301 ret
= setlocale(LC_ALL
, "fin");
302 ok(ret
!= NULL
|| broken (ret
== NULL
), "ret == NULL\n");
304 ok(!strcmp(ret
, "Finnish_Finland.1252"), "ret = %s\n", ret
);
306 ret
= setlocale(LC_ALL
, "finnish");
307 ok(ret
!= NULL
|| broken (ret
== NULL
), "ret == NULL\n");
309 ok(!strcmp(ret
, "Finnish_Finland.1252"), "ret = %s\n", ret
);
311 ret
= setlocale(LC_ALL
, "fra");
312 ok(ret
!= NULL
|| broken (ret
== NULL
), "ret == NULL\n");
314 ok(!strcmp(ret
, "French_France.1252"), "ret = %s\n", ret
);
316 ret
= setlocale(LC_ALL
, "frb");
317 ok(ret
!= NULL
|| broken (ret
== NULL
), "ret == NULL\n");
319 ok(!strcmp(ret
, "French_Belgium.1252")
320 || broken(!strcmp(ret
, "French_France.1252")), "ret = %s\n", ret
);
322 ret
= setlocale(LC_ALL
, "frc");
323 ok(ret
!= NULL
|| broken (ret
== NULL
), "ret == NULL\n");
325 ok(!strcmp(ret
, "French_Canada.1252")
326 || broken(!strcmp(ret
, "French_France.1252")), "ret = %s\n", ret
);
328 ret
= setlocale(LC_ALL
, "french");
329 ok(ret
!= NULL
|| broken (ret
== NULL
), "ret == NULL\n");
331 ok(!strcmp(ret
, "French_France.1252"), "ret = %s\n", ret
);
333 ret
= setlocale(LC_ALL
, "french-belgian");
334 ok(ret
!= NULL
|| broken (ret
== NULL
), "ret == NULL\n");
336 ok(!strcmp(ret
, "French_Belgium.1252")
337 || broken(!strcmp(ret
, "French_France.1252")), "ret = %s\n", ret
);
339 ret
= setlocale(LC_ALL
, "french-canadian");
340 ok(ret
!= NULL
|| broken (ret
== NULL
), "ret == NULL\n");
342 ok(!strcmp(ret
, "French_Canada.1252")
343 || broken(!strcmp(ret
, "French_France.1252")), "ret = %s\n", ret
);
345 ret
= setlocale(LC_ALL
, "french-swiss");
346 ok(ret
!= NULL
|| broken (ret
== NULL
), "ret == NULL\n");
348 ok(!strcmp(ret
, "French_Switzerland.1252")
349 || broken(!strcmp(ret
, "French_France.1252")), "ret = %s\n", ret
);
351 ret
= setlocale(LC_ALL
, "frs");
352 ok(ret
!= NULL
|| broken (ret
== NULL
), "ret == NULL\n");
354 ok(!strcmp(ret
, "French_Switzerland.1252")
355 || broken(!strcmp(ret
, "French_France.1252")), "ret = %s\n", ret
);
357 ret
= setlocale(LC_ALL
, "german");
358 ok(ret
!= NULL
|| broken (ret
== NULL
), "ret == NULL\n");
360 ok(!strcmp(ret
, "German_Germany.1252"), "ret = %s\n", ret
);
362 ret
= setlocale(LC_ALL
, "german-austrian");
363 ok(ret
!= NULL
|| broken (ret
== NULL
), "ret == NULL\n");
365 ok(!strcmp(ret
, "German_Austria.1252")
366 || broken(!strcmp(ret
, "German_Germany.1252")), "ret = %s\n", ret
);
368 ret
= setlocale(LC_ALL
, "german-swiss");
369 ok(ret
!= NULL
|| broken (ret
== NULL
), "ret == NULL\n");
371 ok(!strcmp(ret
, "German_Switzerland.1252")
372 || broken(!strcmp(ret
, "German_Germany.1252")), "ret = %s\n", ret
);
374 ret
= setlocale(LC_ALL
, "greek");
375 ok(ret
!= NULL
|| broken (ret
== NULL
), "ret == NULL\n");
377 ok(!strcmp(ret
, "Greek_Greece.1253"), "ret = %s\n", ret
);
379 ret
= setlocale(LC_ALL
, "hun");
380 ok(ret
!= NULL
|| broken (ret
== NULL
), "ret == NULL\n");
382 ok(!strcmp(ret
, "Hungarian_Hungary.1250"), "ret = %s\n", ret
);
384 ret
= setlocale(LC_ALL
, "hungarian");
385 ok(ret
!= NULL
|| broken (ret
== NULL
), "ret == NULL\n");
387 ok(!strcmp(ret
, "Hungarian_Hungary.1250"), "ret = %s\n", ret
);
389 ret
= setlocale(LC_ALL
, "icelandic");
390 ok(ret
!= NULL
|| broken (ret
== NULL
), "ret == NULL\n");
392 ok(!strcmp(ret
, "Icelandic_Iceland.1252"), "ret = %s\n", ret
);
394 ret
= setlocale(LC_ALL
, "isl");
395 ok(ret
!= NULL
|| broken (ret
== NULL
), "ret == NULL\n");
397 ok(!strcmp(ret
, "Icelandic_Iceland.1252"), "ret = %s\n", ret
);
399 ret
= setlocale(LC_ALL
, "ita");
400 ok(ret
!= NULL
|| broken (ret
== NULL
), "ret == NULL\n");
402 ok(!strcmp(ret
, "Italian_Italy.1252"), "ret = %s\n", ret
);
404 ret
= setlocale(LC_ALL
, "italian");
405 ok(ret
!= NULL
|| broken (ret
== NULL
), "ret == NULL\n");
407 ok(!strcmp(ret
, "Italian_Italy.1252"), "ret = %s\n", ret
);
409 ret
= setlocale(LC_ALL
, "italian-swiss");
410 ok(ret
!= NULL
|| broken (ret
== NULL
), "ret == NULL\n");
412 ok(!strcmp(ret
, "Italian_Switzerland.1252")
413 || broken(!strcmp(ret
, "Italian_Italy.1252")), "ret = %s\n", ret
);
415 ret
= setlocale(LC_ALL
, "its");
416 ok(ret
!= NULL
|| broken (ret
== NULL
), "ret == NULL\n");
418 ok(!strcmp(ret
, "Italian_Switzerland.1252")
419 || broken(!strcmp(ret
, "Italian_Italy.1252")), "ret = %s\n", ret
);
421 ret
= setlocale(LC_ALL
, "japanese");
422 ok(ret
!= NULL
|| broken (ret
== NULL
), "ret == NULL\n");
424 ok(!strcmp(ret
, "Japanese_Japan.932"), "ret = %s\n", ret
);
426 ret
= setlocale(LC_ALL
, "jpn");
427 ok(ret
!= NULL
|| broken (ret
== NULL
), "ret == NULL\n");
429 ok(!strcmp(ret
, "Japanese_Japan.932"), "ret = %s\n", ret
);
431 ret
= setlocale(LC_ALL
, "korean");
432 ok(ret
!= NULL
|| broken (ret
== NULL
), "ret == NULL\n");
434 ok(!strcmp(ret
, "Korean_Korea.949"), "ret = %s\n", ret
);
436 ret
= setlocale(LC_ALL
, "korean");
437 ok(ret
!= NULL
|| broken (ret
== NULL
), "ret == NULL\n");
439 ok(!strcmp(ret
, "Korean_Korea.949"), "ret = %s\n", ret
);
441 ret
= setlocale(LC_ALL
, "nlb");
442 ok(ret
!= NULL
|| broken (ret
== NULL
), "ret == NULL\n");
444 ok(!strcmp(ret
, "Dutch_Belgium.1252")
445 || broken(!strcmp(ret
, "Dutch_Netherlands.1252")), "ret = %s\n", ret
);
447 ret
= setlocale(LC_ALL
, "nld");
448 ok(ret
!= NULL
|| broken (ret
== NULL
), "ret == NULL\n");
450 ok(!strcmp(ret
, "Dutch_Netherlands.1252"), "ret = %s\n", ret
);
452 ret
= setlocale(LC_ALL
, "non");
453 ok(ret
!= NULL
|| broken (ret
== NULL
), "ret == NULL\n");
455 ok(!strcmp( ret
, "Norwegian-Nynorsk_Norway.1252") /* XP - Win10 */
456 || !strcmp(ret
, "Norwegian (Nynorsk)_Norway.1252")
457 || broken(!strcmp(ret
, "Norwegian (Bokm\xe5l)_Norway.1252"))
458 || broken(!strcmp(ret
, "Norwegian_Norway.1252")), /* WinME */
461 ret
= setlocale(LC_ALL
, "nor");
462 ok(ret
!= NULL
|| broken (ret
== NULL
), "ret == NULL\n");
464 ok(!strcmp(ret
, "Norwegian (Bokm\xe5l)_Norway.1252") /* XP - Win8 */
465 || !strcmp(ret
, "Norwegian Bokm\xe5l_Norway.1252") /* Win10 */
466 || !strcmp(ret
, "Norwegian (Bokmal)_Norway.1252")
467 || broken(!strcmp(ret
, "Norwegian_Norway.1252")), /* WinME */
470 ret
= setlocale(LC_ALL
, "norwegian-bokmal");
471 ok(ret
!= NULL
|| broken (ret
== NULL
), "ret == NULL\n");
473 ok(!strcmp(ret
, "Norwegian (Bokm\xe5l)_Norway.1252") /* XP - Win8 */
474 || !strcmp(ret
, "Norwegian Bokm\xe5l_Norway.1252") /* Win10 */
475 || !strcmp(ret
, "Norwegian (Bokmal)_Norway.1252")
476 || broken(!strcmp(ret
, "Norwegian_Norway.1252")), /* WinME */
479 ret
= setlocale(LC_ALL
, "norwegian-nynorsk");
480 ok(ret
!= NULL
|| broken (ret
== NULL
), "ret == NULL\n");
482 ok(!strcmp(ret
, "Norwegian-Nynorsk_Norway.1252") /* Vista - Win10 */
483 || !strcmp(ret
, "Norwegian (Nynorsk)_Norway.1252")
484 || broken(!strcmp(ret
, "Norwegian_Norway.1252")) /* WinME */
485 || broken(!strcmp(ret
, "Norwegian (Bokmal)_Norway.1252"))
486 || broken(!strcmp(ret
, "Norwegian (Bokm\xe5l)_Norway.1252")) /* XP & 2003 */,
489 ret
= setlocale(LC_ALL
, "plk");
490 ok(ret
!= NULL
|| broken (ret
== NULL
), "ret == NULL\n");
492 ok(!strcmp(ret
, "Polish_Poland.1250"), "ret = %s\n", ret
);
494 ret
= setlocale(LC_ALL
, "polish");
495 ok(ret
!= NULL
|| broken (ret
== NULL
), "ret == NULL\n");
497 ok(!strcmp(ret
, "Polish_Poland.1250"), "ret = %s\n", ret
);
499 ret
= setlocale(LC_ALL
, "portuguese");
500 ok(ret
!= NULL
|| broken (ret
== NULL
), "ret == NULL\n");
502 ok(!strcmp(ret
, "Portuguese_Brazil.1252")
503 || broken(!strcmp(ret
, "Portuguese_Portugal.1252")) /* NT4 */, "ret = %s\n", ret
);
505 ret
= setlocale(LC_ALL
, "portuguese-brazil");
506 ok(ret
!= NULL
|| broken (ret
== NULL
), "ret == NULL\n");
508 ok(!strcmp(ret
, "Portuguese_Brazil.1252"), "ret = %s\n", ret
);
510 ret
= setlocale(LC_ALL
, "ptb");
511 ok(ret
!= NULL
|| broken (ret
== NULL
), "ret == NULL\n");
513 ok(!strcmp(ret
, "Portuguese_Brazil.1252"), "ret = %s\n", ret
);
515 ret
= setlocale(LC_ALL
, "ptg");
516 ok(ret
!= NULL
|| broken (ret
== NULL
), "ret == NULL\n");
518 ok(!strcmp(ret
, "Portuguese_Portugal.1252"), "ret = %s\n", ret
);
520 ret
= setlocale(LC_ALL
, "rus");
521 ok(ret
!= NULL
|| broken (ret
== NULL
), "ret == NULL\n");
523 ok(!strcmp(ret
, "Russian_Russia.1251"), "ret = %s\n", ret
);
525 ret
= setlocale(LC_ALL
, "russian");
526 ok(ret
!= NULL
|| broken (ret
== NULL
), "ret == NULL\n");
528 ok(!strcmp(ret
, "Russian_Russia.1251"), "ret = %s\n", ret
);
530 ret
= setlocale(LC_ALL
, "sky");
531 ok(ret
!= NULL
|| broken (ret
== NULL
), "ret == NULL\n");
533 ok(!strcmp(ret
, "Slovak_Slovakia.1250"), "ret = %s\n", ret
);
535 ret
= setlocale(LC_ALL
, "slovak");
536 ok(ret
!= NULL
|| broken (ret
== NULL
), "ret == NULL\n");
538 ok(!strcmp(ret
, "Slovak_Slovakia.1250"), "ret = %s\n", ret
);
540 ret
= setlocale(LC_ALL
, "spanish");
541 ok(ret
!= NULL
|| broken (ret
== NULL
), "ret == NULL\n");
543 ok(!strcmp(ret
, "Spanish_Spain.1252")
544 || broken(!strcmp(ret
, "Spanish - Traditional Sort_Spain.1252")), "ret = %s\n", ret
);
546 ret
= setlocale(LC_ALL
, "spanish-mexican");
547 ok(ret
!= NULL
|| broken (ret
== NULL
), "ret == NULL\n");
549 ok(!strcmp(ret
, "Spanish_Mexico.1252")
550 || broken(!strcmp(ret
, "Spanish_Spain.1252")), "ret = %s\n", ret
);
552 ret
= setlocale(LC_ALL
, "spanish-modern");
553 ok(ret
!= NULL
|| broken (ret
== NULL
), "ret == NULL\n");
555 ok(!strcmp(ret
, "Spanish - Modern Sort_Spain.1252")
556 || !strcmp(ret
, "Spanish_Spain.1252"), "ret = %s\n", ret
);
558 ret
= setlocale(LC_ALL
, "sve");
559 ok(ret
!= NULL
|| broken (ret
== NULL
), "ret == NULL\n");
561 ok(!strcmp(ret
, "Swedish_Sweden.1252"), "ret = %s\n", ret
);
563 ret
= setlocale(LC_ALL
, "swedish");
564 ok(ret
!= NULL
|| broken (ret
== NULL
), "ret == NULL\n");
566 ok(!strcmp(ret
, "Swedish_Sweden.1252"), "ret = %s\n", ret
);
568 ret
= setlocale(LC_ALL
, "swiss");
569 ok(ret
!= NULL
|| broken (ret
== NULL
), "ret == NULL\n");
571 ok(!strcmp(ret
, "German_Switzerland.1252"), "ret = %s\n", ret
);
573 ret
= setlocale(LC_ALL
, "trk");
574 ok(ret
!= NULL
|| broken (ret
== NULL
), "ret == NULL\n");
576 ok(!strcmp(ret
, "Turkish_Turkey.1254"), "ret = %s\n", ret
);
578 ret
= setlocale(LC_ALL
, "turkish");
579 ok(ret
!= NULL
|| broken (ret
== NULL
), "ret == NULL\n");
581 ok(!strcmp(ret
, "Turkish_Turkey.1254"), "ret = %s\n", ret
);
583 ret
= setlocale(LC_ALL
, "uk");
584 ok(ret
!= NULL
, "ret == NULL\n");
586 ok(!strcmp(ret
, "English_United Kingdom.1252")
587 || broken(!strcmp(ret
, "Ukrainian_Ukraine.1251")), "ret = %s\n", ret
);
589 ret
= setlocale(LC_ALL
, "us");
590 ok(ret
!= NULL
|| broken (ret
== NULL
), "ret == NULL\n");
592 ok(!strcmp(ret
, "English_United States.1252"), "ret = %s\n", ret
);
594 ret
= setlocale(LC_ALL
, "usa");
595 ok(ret
!= NULL
|| broken (ret
== NULL
), "ret == NULL\n");
597 ok(!strcmp(ret
, "English_United States.1252"), "ret = %s\n", ret
);
599 ret
= setlocale(LC_ALL
, "English_United States.ACP");
600 ok(ret
!= NULL
|| broken (ret
== NULL
), "ret == NULL\n");
602 strcpy(buf
, "English_United States.");
603 GetLocaleInfoA(MAKELCID(MAKELANGID(LANG_ENGLISH
, SUBLANG_ENGLISH_US
), SORT_DEFAULT
),
604 LOCALE_IDEFAULTANSICODEPAGE
, buf
+strlen(buf
), 80);
605 ok(!strcmp(ret
, buf
), "ret = %s, expected %s\n", ret
, buf
);
608 ret
= setlocale(LC_ALL
, "English_United States.OCP");
609 ok(ret
!= NULL
|| broken (ret
== NULL
), "ret == NULL\n");
611 strcpy(buf
, "English_United States.");
612 GetLocaleInfoA(MAKELCID(MAKELANGID(LANG_ENGLISH
, SUBLANG_ENGLISH_US
), SORT_DEFAULT
),
613 LOCALE_IDEFAULTCODEPAGE
, buf
+strlen(buf
), 80);
614 ok(!strcmp(ret
, buf
), "ret = %s, expected %s\n", ret
, buf
);
617 GetLocaleInfoA(GetUserDefaultLCID(), LOCALE_IDEFAULTCODEPAGE
, buf
, sizeof(buf
));
618 if(IsValidCodePage(atoi(buf
))) {
619 ret
= setlocale(LC_ALL
, ".OCP");
620 ok(ret
!= NULL
, "ret == NULL\n");
621 ptr
= strchr(ret
, '.');
622 ok(ptr
&& !strcmp(ptr
+ 1, buf
), "ret %s, buf %s.\n", ret
, buf
);
625 len
= GetLocaleInfoA(GetUserDefaultLCID(), LOCALE_IDEFAULTANSICODEPAGE
, buf
, sizeof(buf
)) - 1;
626 if(buf
[0] == '0' && !buf
[1])
627 len
= sprintf(buf
, "%d", GetACP());
628 ret
= setlocale(LC_ALL
, ".ACP");
629 ok(ret
!= NULL
, "ret == NULL\n");
630 ptr
= strchr(ret
, '.');
631 ok(ptr
&& !strncmp(ptr
+ 1, buf
, len
), "ret %s, buf %s.\n", ret
, buf
);
633 ret
= setlocale(LC_ALL
, ".1250");
634 ok(ret
!= NULL
, "ret == NULL\n");
635 ptr
= strchr(ret
, '.');
636 ok(ptr
&& !strcmp(ptr
, ".1250"), "ret %s, buf %s.\n", ret
, buf
);
638 ret
= setlocale(LC_ALL
, "English_United States.UTF8");
639 ok(ret
== NULL
, "ret != NULL\n");
641 ret
= setlocale(LC_ALL
, "en-US");
642 ok(ret
== NULL
|| broken (ret
!= NULL
), "ret != NULL\n"); /* XP & 2003 */
645 static void test_crtGetStringTypeW(void)
647 const wchar_t *str
[] = { L
"0", L
"A", L
" ", L
"\0", L
"\x04d2" };
653 if(!p__crtGetStringTypeW
) {
654 win_skip("Skipping __crtGetStringTypeW tests\n");
659 win_skip("Too old version of msvcrt.dll\n");
663 for(i
=0; i
<ARRAY_SIZE(str
); i
++) {
664 ret_crt
= p__crtGetStringTypeW(0, CT_CTYPE1
, str
[i
], 1, &out_crt
);
665 ret
= GetStringTypeW(CT_CTYPE1
, str
[i
], 1, &out
);
666 ok(ret
== ret_crt
, "%d) ret_crt = %d\n", i
, (int)ret_crt
);
667 ok(out
== out_crt
, "%d) out_crt = %x, expected %x\n", i
, (int)out_crt
, (int)out
);
669 ret_crt
= p__crtGetStringTypeW(0, CT_CTYPE2
, str
[i
], 1, &out_crt
);
670 ret
= GetStringTypeW(CT_CTYPE2
, str
[i
], 1, &out
);
671 ok(ret
== ret_crt
, "%d) ret_crt = %d\n", i
, (int)ret_crt
);
672 ok(out
== out_crt
, "%d) out_crt = %x, expected %x\n", i
, (int)out_crt
, (int)out
);
674 ret_crt
= p__crtGetStringTypeW(0, CT_CTYPE3
, str
[i
], 1, &out_crt
);
675 ret
= GetStringTypeW(CT_CTYPE3
, str
[i
], 1, &out
);
676 ok(ret
== ret_crt
, "%d) ret_crt = %d\n", i
, (int)ret_crt
);
677 ok(out
== out_crt
, "%d) out_crt = %x, expected %x\n", i
, (int)out_crt
, (int)out
);
680 ret
= p__crtGetStringTypeW(0, 3, str
[0], 1, &out
);
681 ok(!ret
, "ret == TRUE\n");
684 static void test__Gettnames(void)
686 static const DWORD time_data
[] = {
687 LOCALE_SABBREVDAYNAME7
, LOCALE_SABBREVDAYNAME1
, LOCALE_SABBREVDAYNAME2
,
688 LOCALE_SABBREVDAYNAME3
, LOCALE_SABBREVDAYNAME4
, LOCALE_SABBREVDAYNAME5
,
689 LOCALE_SABBREVDAYNAME6
,
690 LOCALE_SDAYNAME7
, LOCALE_SDAYNAME1
, LOCALE_SDAYNAME2
, LOCALE_SDAYNAME3
,
691 LOCALE_SDAYNAME4
, LOCALE_SDAYNAME5
, LOCALE_SDAYNAME6
,
692 LOCALE_SABBREVMONTHNAME1
, LOCALE_SABBREVMONTHNAME2
, LOCALE_SABBREVMONTHNAME3
,
693 LOCALE_SABBREVMONTHNAME4
, LOCALE_SABBREVMONTHNAME5
, LOCALE_SABBREVMONTHNAME6
,
694 LOCALE_SABBREVMONTHNAME7
, LOCALE_SABBREVMONTHNAME8
, LOCALE_SABBREVMONTHNAME9
,
695 LOCALE_SABBREVMONTHNAME10
, LOCALE_SABBREVMONTHNAME11
, LOCALE_SABBREVMONTHNAME12
,
696 LOCALE_SMONTHNAME1
, LOCALE_SMONTHNAME2
, LOCALE_SMONTHNAME3
, LOCALE_SMONTHNAME4
,
697 LOCALE_SMONTHNAME5
, LOCALE_SMONTHNAME6
, LOCALE_SMONTHNAME7
, LOCALE_SMONTHNAME8
,
698 LOCALE_SMONTHNAME9
, LOCALE_SMONTHNAME10
, LOCALE_SMONTHNAME11
, LOCALE_SMONTHNAME12
,
699 LOCALE_S1159
, LOCALE_S2359
,
700 LOCALE_SSHORTDATE
, LOCALE_SLONGDATE
,
715 if(!setlocale(LC_ALL
, "english"))
719 size
= ret
->str
[0]-(char*)ret
;
720 /* Newer version of the structure stores both ascii and unicode strings.
721 * Unicode strings are only initialized on Windows 7
723 if(sizeof(void*) == 8)
724 ok(size
==0x2c0 || broken(size
==0x168), "structure size: %x\n", size
);
726 ok(size
==0x164 || broken(size
==0xb8), "structure size: %x\n", size
);
728 for (i
= 0; i
< ARRAY_SIZE(time_data
); i
++)
730 size
= GetLocaleInfoA(MAKELCID(LANG_ENGLISH
, SORT_DEFAULT
),
731 time_data
[i
], buf
, sizeof(buf
));
732 ok(size
, "GetLocaleInfo failed: %x\n", GetLastError());
733 ok(!strcmp(ret
->str
[i
], buf
), "ret->str[%i] = %s, expected %s\n", i
, ret
->str
[i
], buf
);
738 if(!setlocale(LC_TIME
, "german"))
742 for (i
= 0; i
< ARRAY_SIZE(time_data
); i
++)
744 size
= GetLocaleInfoA(MAKELCID(LANG_GERMAN
, SORT_DEFAULT
),
745 time_data
[i
], buf
, sizeof(buf
));
746 ok(size
, "GetLocaleInfo failed: %x\n", GetLastError());
747 ok(!strcmp(ret
->str
[i
], buf
), "ret->str[%i] = %s, expected %s\n", i
, ret
->str
[i
], buf
);
751 setlocale(LC_ALL
, "C");
754 static void test___mb_cur_max_func(void)
758 setlocale(LC_ALL
, "C");
760 /* for newer Windows */
761 if(!p___mb_cur_max_func
)
762 win_skip("Skipping ___mb_cur_max_func tests\n");
764 mb_cur_max
= p___mb_cur_max_func();
765 ok(mb_cur_max
== 1, "mb_cur_max = %d, expected 1\n", mb_cur_max
);
767 /* some old Windows don't set chinese */
768 if (!setlocale(LC_ALL
, "chinese"))
769 win_skip("Skipping test with chinese locale\n");
771 mb_cur_max
= p___mb_cur_max_func();
772 ok(mb_cur_max
== 2, "mb_cur_max = %d, expected 2\n", mb_cur_max
);
773 setlocale(LC_ALL
, "C");
777 /* for older Windows */
778 if (!p__p___mb_cur_max
)
779 skip("Skipping __p___mb_cur_max tests\n");
781 mb_cur_max
= *p__p___mb_cur_max();
782 ok(mb_cur_max
== 1, "mb_cur_max = %d, expected 1\n", mb_cur_max
);
784 /* some old Windows don't set chinese */
785 if (!setlocale(LC_ALL
, "chinese"))
786 win_skip("Skipping test with chinese locale\n");
788 mb_cur_max
= *p__p___mb_cur_max();
789 ok(mb_cur_max
== 2, "mb_cur_max = %d, expected 2\n", mb_cur_max
);
790 setlocale(LC_ALL
, "C");
799 test_crtGetStringTypeW();
802 test___mb_cur_max_func();