msvcrt: Use fpclass constants from public header.
[wine/zf.git] / dlls / msvcrt / tests / locale.c
blob176e3b5e6e4ad43165f4c38cbf704f65793e5b72
1 /*
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
21 #include <locale.h>
23 #include "wine/test.h"
24 #include "winnls.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";
47 char *ret, buf[100];
48 char *ptr;
49 int len;
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");
65 return;
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);
77 strcpy(buf, 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");
86 if(ret)
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");
91 if(ret)
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");
96 if(ret)
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");
101 if(ret)
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");
106 if(ret)
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");
111 if(ret)
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");
116 if(ret)
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");
123 if(ret)
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");
131 if(ret)
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");
137 if(ret)
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");
144 if(ret)
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");
150 if(ret)
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");
160 if(ret)
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");
166 if(ret)
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");
172 if(ret)
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");
177 if(ret)
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");
182 if(ret)
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");
187 if(ret)
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");
192 if(ret)
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");
197 if(ret)
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");
202 if(ret)
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");
208 if(ret)
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");
214 if(ret)
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");
219 if(ret)
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");
225 if(ret)
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");
231 if(ret)
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");
236 if(ret)
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");
242 if(ret)
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");
247 if(ret)
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");
252 if(ret)
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");
258 if(ret)
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");
264 if(ret)
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");
270 if(ret)
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");
276 if(ret)
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");
281 if(ret)
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");
286 if(ret)
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");
291 if(ret)
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");
297 if(ret)
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");
303 if(ret)
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");
308 if(ret)
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");
313 if(ret)
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");
318 if(ret)
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");
324 if(ret)
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");
330 if(ret)
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");
335 if(ret)
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");
341 if(ret)
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");
347 if(ret)
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");
353 if(ret)
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");
359 if(ret)
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");
364 if(ret)
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");
370 if(ret)
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");
376 if(ret)
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");
381 if(ret)
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");
386 if(ret)
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");
391 if(ret)
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");
396 if(ret)
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");
401 if(ret)
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");
406 if(ret)
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");
411 if(ret)
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");
417 if(ret)
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");
423 if(ret)
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");
428 if(ret)
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");
433 if(ret)
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");
438 if(ret)
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");
443 if(ret)
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");
449 if(ret)
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");
454 if(ret)
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 */
459 "ret = %s\n", ret);
461 ret = setlocale(LC_ALL, "nor");
462 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
463 if(ret)
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 */
468 "ret = %s\n", ret);
470 ret = setlocale(LC_ALL, "norwegian-bokmal");
471 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
472 if(ret)
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 */
477 "ret = %s\n", ret);
479 ret = setlocale(LC_ALL, "norwegian-nynorsk");
480 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
481 if(ret)
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 */,
487 "ret = %s\n", ret);
489 ret = setlocale(LC_ALL, "plk");
490 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
491 if(ret)
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");
496 if(ret)
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");
501 if(ret)
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");
507 if(ret)
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");
512 if(ret)
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");
517 if(ret)
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");
522 if(ret)
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");
527 if(ret)
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");
532 if(ret)
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");
537 if(ret)
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");
542 if(ret)
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");
548 if(ret)
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");
554 if(ret)
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");
560 if(ret)
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");
565 if(ret)
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");
570 if(ret)
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");
575 if(ret)
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");
580 if(ret)
581 ok(!strcmp(ret, "Turkish_Turkey.1254"), "ret = %s\n", ret);
583 ret = setlocale(LC_ALL, "uk");
584 ok(ret != NULL, "ret == NULL\n");
585 if(ret)
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");
591 if(ret)
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");
596 if(ret)
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");
601 if(ret) {
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");
610 if(ret) {
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" };
649 WORD out_crt, out;
650 BOOL ret_crt, ret;
651 int i;
653 if(!p__crtGetStringTypeW) {
654 win_skip("Skipping __crtGetStringTypeW tests\n");
655 return;
658 if(!pmemcpy_s) {
659 win_skip("Too old version of msvcrt.dll\n");
660 return;
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,
701 LOCALE_STIMEFORMAT
704 struct {
705 char *str[43];
706 LCID lcid;
707 int unk[2];
708 wchar_t *wstr[43];
709 char data[1];
710 } *ret;
711 int size;
712 char buf[64];
713 int i;
715 if(!setlocale(LC_ALL, "english"))
716 return;
718 ret = _Gettnames();
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);
725 else
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);
736 free(ret);
738 if(!setlocale(LC_TIME, "german"))
739 return;
741 ret = _Gettnames();
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);
749 free(ret);
751 setlocale(LC_ALL, "C");
754 static void test___mb_cur_max_func(void)
756 int mb_cur_max;
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");
763 else {
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");
770 else {
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");
780 else {
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");
787 else {
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");
795 START_TEST(locale)
797 init();
799 test_crtGetStringTypeW();
800 test_setlocale();
801 test__Gettnames();
802 test___mb_cur_max_func();