Release 1.6-rc2.
[wine/testsucceed.git] / dlls / msvcrt / tests / locale.c
blob63f8a591652a83fe94ca1f145574ffbbaa3bcf9b
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];
49 ret = setlocale(20, "C");
50 ok(ret == NULL, "ret = %s\n", ret);
52 ret = setlocale(LC_ALL, "");
53 ok(ret != NULL, "ret == NULL\n");
55 ret = setlocale(LC_ALL, "C");
56 ok(!strcmp(ret, "C"), "ret = %s\n", ret);
58 ret = setlocale(LC_ALL, NULL);
59 ok(!strcmp(ret, "C"), "ret = %s\n", ret);
61 if(!setlocale(LC_NUMERIC, "Polish")
62 || !setlocale(LC_NUMERIC, "Greek")
63 || !setlocale(LC_NUMERIC, "German")
64 || !setlocale(LC_NUMERIC, "English")) {
65 win_skip("System with limited locales\n");
66 return;
69 ret = setlocale(LC_NUMERIC, "Polish");
70 ok(!strcmp(ret, "Polish_Poland.1250"), "ret = %s\n", ret);
72 ret = setlocale(LC_MONETARY, "Greek");
73 ok(!strcmp(ret, "Greek_Greece.1253"), "ret = %s\n", ret);
75 ret = setlocale(LC_ALL, NULL);
76 ok(!strcmp(ret, lc_all), "ret = %s\n", ret);
78 strcpy(buf, ret);
79 ret = setlocale(LC_ALL, buf);
80 ok(!strcmp(ret, lc_all), "ret = %s\n", ret);
82 ret = setlocale(LC_ALL, "German");
83 ok(!strcmp(ret, "German_Germany.1252"), "ret = %s\n", ret);
85 ret = setlocale(LC_ALL, "american");
86 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
87 if(ret)
88 ok(!strcmp(ret, "English_United States.1252"), "ret = %s\n", ret);
90 ret = setlocale(LC_ALL, "american english");
91 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
92 if(ret)
93 ok(!strcmp(ret, "English_United States.1252"), "ret = %s\n", ret);
95 ret = setlocale(LC_ALL, "american-english");
96 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
97 if(ret)
98 ok(!strcmp(ret, "English_United States.1252"), "ret = %s\n", ret);
100 ret = setlocale(LC_ALL, "australian");
101 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
102 if(ret)
103 ok(!strcmp(ret, "English_Australia.1252"), "ret = %s\n", ret);
105 ret = setlocale(LC_ALL, "belgian");
106 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
107 if(ret)
108 ok(!strcmp(ret, "Dutch_Belgium.1252"), "ret = %s\n", ret);
110 ret = setlocale(LC_ALL, "canadian");
111 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
112 if(ret)
113 ok(!strcmp(ret, "English_Canada.1252"), "ret = %s\n", ret);
115 ret = setlocale(LC_ALL, "chinese");
116 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
117 if(ret)
118 ok(!strcmp(ret, "Chinese (Simplified)_People's Republic of China.936")
119 || !strcmp(ret, "Chinese (Simplified)_China.936")
120 || broken(!strcmp(ret, "Chinese_Taiwan.950")), "ret = %s\n", ret);
122 ret = setlocale(LC_ALL, "chinese-simplified");
123 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
124 if(ret)
125 ok(!strcmp(ret, "Chinese (Simplified)_People's Republic of China.936")
126 || !strcmp(ret, "Chinese (Simplified)_China.936")
127 || broken(!strcmp(ret, "Chinese_People's Republic of China.936"))
128 || broken(!strcmp(ret, "Chinese_Taiwan.950")), "ret = %s\n", ret);
130 ret = setlocale(LC_ALL, "chinese-traditional");
131 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
132 if(ret)
133 ok(!strcmp(ret, "Chinese (Traditional)_Taiwan.950")
134 || broken(!strcmp(ret, "Chinese_Taiwan.950")), "ret = %s\n", ret);
136 ret = setlocale(LC_ALL, "chs");
137 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
138 if(ret)
139 ok(!strcmp(ret, "Chinese (Simplified)_People's Republic of China.936")
140 || !strcmp(ret, "Chinese (Simplified)_China.936")
141 || broken(!strcmp(ret, "Chinese_People's Republic of China.936")), "ret = %s\n", ret);
143 ret = setlocale(LC_ALL, "cht");
144 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
145 if(ret)
146 ok(!strcmp(ret, "Chinese (Traditional)_Taiwan.950")
147 || broken(!strcmp(ret, "Chinese_Taiwan.950")), "ret = %s\n", ret);
149 ret = setlocale(LC_ALL, "csy");
150 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
151 if(ret)
152 ok(!strcmp(ret, "Czech_Czech Republic.1250"), "ret = %s\n", ret);
154 ret = setlocale(LC_ALL, "czech");
155 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
156 if(ret)
157 ok(!strcmp(ret, "Czech_Czech Republic.1250"), "ret = %s\n", ret);
159 ret = setlocale(LC_ALL, "dan");
160 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
161 if(ret)
162 ok(!strcmp(ret, "Danish_Denmark.1252"), "ret = %s\n", ret);
164 ret = setlocale(LC_ALL, "danish");
165 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
166 if(ret)
167 ok(!strcmp(ret, "Danish_Denmark.1252"), "ret = %s\n", ret);
169 ret = setlocale(LC_ALL, "dea");
170 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
171 if(ret)
172 ok(!strcmp(ret, "German_Austria.1252"), "ret = %s\n", ret);
174 ret = setlocale(LC_ALL, "des");
175 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
176 if(ret)
177 ok(!strcmp(ret, "German_Switzerland.1252"), "ret = %s\n", ret);
179 ret = setlocale(LC_ALL, "deu");
180 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
181 if(ret)
182 ok(!strcmp(ret, "German_Germany.1252"), "ret = %s\n", ret);
184 ret = setlocale(LC_ALL, "dutch");
185 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
186 if(ret)
187 ok(!strcmp(ret, "Dutch_Netherlands.1252"), "ret = %s\n", ret);
189 ret = setlocale(LC_ALL, "dutch-belgian");
190 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
191 if(ret)
192 ok(!strcmp(ret, "Dutch_Belgium.1252")
193 || broken(!strcmp(ret, "Dutch_Netherlands.1252")), "ret = %s\n", ret);
195 ret = setlocale(LC_ALL, "ena");
196 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
197 if(ret)
198 ok(!strcmp(ret, "English_Australia.1252")
199 || broken(!strcmp(ret, "English_United States.1252")), "ret = %s\n", ret);
201 ret = setlocale(LC_ALL, "ell");
202 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
203 if(ret)
204 ok(!strcmp(ret, "Greek_Greece.1253"), "ret = %s\n", ret);
206 ret = setlocale(LC_ALL, "enc");
207 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
208 if(ret)
209 ok(!strcmp(ret, "English_Canada.1252")
210 || broken(!strcmp(ret, "English_United States.1252")), "ret = %s\n", ret);
212 ret = setlocale(LC_ALL, "eng");
213 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
214 if(ret)
215 ok(!strcmp(ret, "English_United Kingdom.1252")
216 || broken(!strcmp(ret, "English_United States.1252")), "ret = %s\n", ret);
218 ret = setlocale(LC_ALL, "enu");
219 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
220 if(ret)
221 ok(!strcmp(ret, "English_United States.1252"), "ret = %s\n", ret);
223 ret = setlocale(LC_ALL, "enz");
224 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
225 if(ret)
226 ok(!strcmp(ret, "English_New Zealand.1252")
227 || broken(!strcmp(ret, "English_United States.1252")), "ret = %s\n", ret);
229 ret = setlocale(LC_ALL, "english");
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, "english-american");
235 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
236 if(ret)
237 ok(!strcmp(ret, "English_United States.1252"), "ret = %s\n", ret);
239 ret = setlocale(LC_ALL, "english-aus");
240 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
241 if(ret)
242 ok(!strcmp(ret, "English_Australia.1252")
243 || broken(!strcmp(ret, "English_United States.1252")), "ret = %s\n", ret);
245 ret = setlocale(LC_ALL, "english-can");
246 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
247 if(ret)
248 ok(!strcmp(ret, "English_Canada.1252")
249 || broken(!strcmp(ret, "English_United States.1252")), "ret = %s\n", ret);
251 ret = setlocale(LC_ALL, "english-nz");
252 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
253 if(ret)
254 ok(!strcmp(ret, "English_New Zealand.1252")
255 || broken(!strcmp(ret, "English_United States.1252")), "ret = %s\n", ret);
257 ret = setlocale(LC_ALL, "english-uk");
258 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
259 if(ret)
260 ok(!strcmp(ret, "English_United Kingdom.1252")
261 || broken(!strcmp(ret, "English_United States.1252")), "ret = %s\n", ret);
263 ret = setlocale(LC_ALL, "english-us");
264 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
265 if(ret)
266 ok(!strcmp(ret, "English_United States.1252"), "ret = %s\n", ret);
268 ret = setlocale(LC_ALL, "english-usa");
269 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
270 if(ret)
271 ok(!strcmp(ret, "English_United States.1252"), "ret = %s\n", ret);
273 ret = setlocale(LC_ALL, "esm");
274 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
275 if(ret)
276 ok(!strcmp(ret, "Spanish_Mexico.1252"), "ret = %s\n", ret);
278 ret = setlocale(LC_ALL, "esn");
279 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
280 if(ret)
281 ok(!strcmp(ret, "Spanish_Spain.1252")
282 || broken(!strcmp(ret, "Spanish - Modern Sort_Spain.1252")), "ret = %s\n", ret);
284 ret = setlocale(LC_ALL, "esp");
285 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
286 if(ret)
287 ok(!strcmp(ret, "Spanish_Spain.1252")
288 || broken(!strcmp(ret, "Spanish - Traditional Sort_Spain.1252")), "ret = %s\n", ret);
290 ret = setlocale(LC_ALL, "fin");
291 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
292 if(ret)
293 ok(!strcmp(ret, "Finnish_Finland.1252"), "ret = %s\n", ret);
295 ret = setlocale(LC_ALL, "finnish");
296 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
297 if(ret)
298 ok(!strcmp(ret, "Finnish_Finland.1252"), "ret = %s\n", ret);
300 ret = setlocale(LC_ALL, "fra");
301 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
302 if(ret)
303 ok(!strcmp(ret, "French_France.1252"), "ret = %s\n", ret);
305 ret = setlocale(LC_ALL, "frb");
306 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
307 if(ret)
308 ok(!strcmp(ret, "French_Belgium.1252")
309 || broken(!strcmp(ret, "French_France.1252")), "ret = %s\n", ret);
311 ret = setlocale(LC_ALL, "frc");
312 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
313 if(ret)
314 ok(!strcmp(ret, "French_Canada.1252")
315 || broken(!strcmp(ret, "French_France.1252")), "ret = %s\n", ret);
317 ret = setlocale(LC_ALL, "french");
318 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
319 if(ret)
320 ok(!strcmp(ret, "French_France.1252"), "ret = %s\n", ret);
322 ret = setlocale(LC_ALL, "french-belgian");
323 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
324 if(ret)
325 ok(!strcmp(ret, "French_Belgium.1252")
326 || broken(!strcmp(ret, "French_France.1252")), "ret = %s\n", ret);
328 ret = setlocale(LC_ALL, "french-canadian");
329 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
330 if(ret)
331 ok(!strcmp(ret, "French_Canada.1252")
332 || broken(!strcmp(ret, "French_France.1252")), "ret = %s\n", ret);
334 ret = setlocale(LC_ALL, "french-swiss");
335 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
336 if(ret)
337 ok(!strcmp(ret, "French_Switzerland.1252")
338 || broken(!strcmp(ret, "French_France.1252")), "ret = %s\n", ret);
340 ret = setlocale(LC_ALL, "frs");
341 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
342 if(ret)
343 ok(!strcmp(ret, "French_Switzerland.1252")
344 || broken(!strcmp(ret, "French_France.1252")), "ret = %s\n", ret);
346 ret = setlocale(LC_ALL, "german");
347 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
348 if(ret)
349 ok(!strcmp(ret, "German_Germany.1252"), "ret = %s\n", ret);
351 ret = setlocale(LC_ALL, "german-austrian");
352 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
353 if(ret)
354 ok(!strcmp(ret, "German_Austria.1252")
355 || broken(!strcmp(ret, "German_Germany.1252")), "ret = %s\n", ret);
357 ret = setlocale(LC_ALL, "german-swiss");
358 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
359 if(ret)
360 ok(!strcmp(ret, "German_Switzerland.1252")
361 || broken(!strcmp(ret, "German_Germany.1252")), "ret = %s\n", ret);
363 ret = setlocale(LC_ALL, "greek");
364 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
365 if(ret)
366 ok(!strcmp(ret, "Greek_Greece.1253"), "ret = %s\n", ret);
368 ret = setlocale(LC_ALL, "hun");
369 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
370 if(ret)
371 ok(!strcmp(ret, "Hungarian_Hungary.1250"), "ret = %s\n", ret);
373 ret = setlocale(LC_ALL, "hungarian");
374 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
375 if(ret)
376 ok(!strcmp(ret, "Hungarian_Hungary.1250"), "ret = %s\n", ret);
378 ret = setlocale(LC_ALL, "icelandic");
379 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
380 if(ret)
381 ok(!strcmp(ret, "Icelandic_Iceland.1252"), "ret = %s\n", ret);
383 ret = setlocale(LC_ALL, "isl");
384 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
385 if(ret)
386 ok(!strcmp(ret, "Icelandic_Iceland.1252"), "ret = %s\n", ret);
388 ret = setlocale(LC_ALL, "ita");
389 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
390 if(ret)
391 ok(!strcmp(ret, "Italian_Italy.1252"), "ret = %s\n", ret);
393 ret = setlocale(LC_ALL, "italian");
394 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
395 if(ret)
396 ok(!strcmp(ret, "Italian_Italy.1252"), "ret = %s\n", ret);
398 ret = setlocale(LC_ALL, "italian-swiss");
399 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
400 if(ret)
401 ok(!strcmp(ret, "Italian_Switzerland.1252")
402 || broken(!strcmp(ret, "Italian_Italy.1252")), "ret = %s\n", ret);
404 ret = setlocale(LC_ALL, "its");
405 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
406 if(ret)
407 ok(!strcmp(ret, "Italian_Switzerland.1252")
408 || broken(!strcmp(ret, "Italian_Italy.1252")), "ret = %s\n", ret);
410 ret = setlocale(LC_ALL, "japanese");
411 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
412 if(ret)
413 ok(!strcmp(ret, "Japanese_Japan.932"), "ret = %s\n", ret);
415 ret = setlocale(LC_ALL, "jpn");
416 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
417 if(ret)
418 ok(!strcmp(ret, "Japanese_Japan.932"), "ret = %s\n", ret);
420 ret = setlocale(LC_ALL, "korean");
421 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
422 if(ret)
423 ok(!strcmp(ret, "Korean_Korea.949"), "ret = %s\n", ret);
425 ret = setlocale(LC_ALL, "korean");
426 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
427 if(ret)
428 ok(!strcmp(ret, "Korean_Korea.949"), "ret = %s\n", ret);
430 ret = setlocale(LC_ALL, "nlb");
431 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
432 if(ret)
433 ok(!strcmp(ret, "Dutch_Belgium.1252")
434 || broken(!strcmp(ret, "Dutch_Netherlands.1252")), "ret = %s\n", ret);
436 ret = setlocale(LC_ALL, "nld");
437 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
438 if(ret)
439 ok(!strcmp(ret, "Dutch_Netherlands.1252"), "ret = %s\n", ret);
441 ret = setlocale(LC_ALL, "non");
442 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
443 if(ret)
444 ok(!strcmp( ret, "Norwegian-Nynorsk_Norway.1252")
445 || !strcmp(ret, "Norwegian (Nynorsk)_Norway.1252")
446 || broken(!strcmp(ret, "Norwegian (Bokm\xe5l)_Norway.1252"))
447 || broken(!strcmp(ret, "Norwegian_Norway.1252")), "ret = %s\n", ret);
449 ret = setlocale(LC_ALL, "nor");
450 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
451 if(ret)
452 ok(!strcmp(ret, "Norwegian (Bokm\xe5l)_Norway.1252")
453 || !strcmp(ret, "Norwegian (Bokmal)_Norway.1252")
454 || broken(!strcmp(ret, "Norwegian_Norway.1252")), "ret = %s\n", ret);
456 ret = setlocale(LC_ALL, "norwegian-bokmal");
457 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
458 if(ret)
459 ok(!strcmp(ret, "Norwegian (Bokm\xe5l)_Norway.1252")
460 || !strcmp(ret, "Norwegian (Bokmal)_Norway.1252")
461 || broken(!strcmp(ret, "Norwegian_Norway.1252")), "ret = %s\n", ret);
463 ret = setlocale(LC_ALL, "norwegian-nynorsk");
464 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
465 if(ret)
466 ok(!strcmp(ret, "Norwegian-Nynorsk_Norway.1252")
467 || !strcmp(ret, "Norwegian (Nynorsk)_Norway.1252")
468 || broken(!strcmp(ret, "Norwegian_Norway.1252"))
469 || broken(!strcmp(ret, "Norwegian (Bokmal)_Norway.1252"))
470 || broken(!strcmp(ret, "Norwegian (Bokm\xe5l)_Norway.1252")), "ret = %s\n", ret);
472 ret = setlocale(LC_ALL, "plk");
473 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
474 if(ret)
475 ok(!strcmp(ret, "Polish_Poland.1250"), "ret = %s\n", ret);
477 ret = setlocale(LC_ALL, "polish");
478 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
479 if(ret)
480 ok(!strcmp(ret, "Polish_Poland.1250"), "ret = %s\n", ret);
482 ret = setlocale(LC_ALL, "portuguese");
483 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
484 if(ret)
485 ok(!strcmp(ret, "Portuguese_Brazil.1252")
486 || broken(!strcmp(ret, "Portuguese_Portugal.1252")) /* NT4 */, "ret = %s\n", ret);
488 ret = setlocale(LC_ALL, "portuguese-brazil");
489 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
490 if(ret)
491 ok(!strcmp(ret, "Portuguese_Brazil.1252"), "ret = %s\n", ret);
493 ret = setlocale(LC_ALL, "ptb");
494 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
495 if(ret)
496 ok(!strcmp(ret, "Portuguese_Brazil.1252"), "ret = %s\n", ret);
498 ret = setlocale(LC_ALL, "ptg");
499 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
500 if(ret)
501 ok(!strcmp(ret, "Portuguese_Portugal.1252"), "ret = %s\n", ret);
503 ret = setlocale(LC_ALL, "rus");
504 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
505 if(ret)
506 ok(!strcmp(ret, "Russian_Russia.1251"), "ret = %s\n", ret);
508 ret = setlocale(LC_ALL, "russian");
509 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
510 if(ret)
511 ok(!strcmp(ret, "Russian_Russia.1251"), "ret = %s\n", ret);
513 ret = setlocale(LC_ALL, "sky");
514 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
515 if(ret)
516 ok(!strcmp(ret, "Slovak_Slovakia.1250"), "ret = %s\n", ret);
518 ret = setlocale(LC_ALL, "slovak");
519 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
520 if(ret)
521 ok(!strcmp(ret, "Slovak_Slovakia.1250"), "ret = %s\n", ret);
523 ret = setlocale(LC_ALL, "spanish");
524 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
525 if(ret)
526 ok(!strcmp(ret, "Spanish_Spain.1252")
527 || broken(!strcmp(ret, "Spanish - Traditional Sort_Spain.1252")), "ret = %s\n", ret);
529 ret = setlocale(LC_ALL, "spanish-mexican");
530 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
531 if(ret)
532 ok(!strcmp(ret, "Spanish_Mexico.1252")
533 || broken(!strcmp(ret, "Spanish_Spain.1252")), "ret = %s\n", ret);
535 ret = setlocale(LC_ALL, "spanish-modern");
536 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
537 if(ret)
538 ok(!strcmp(ret, "Spanish - Modern Sort_Spain.1252")
539 || !strcmp(ret, "Spanish_Spain.1252"), "ret = %s\n", ret);
541 ret = setlocale(LC_ALL, "sve");
542 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
543 if(ret)
544 ok(!strcmp(ret, "Swedish_Sweden.1252"), "ret = %s\n", ret);
546 ret = setlocale(LC_ALL, "swedish");
547 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
548 if(ret)
549 ok(!strcmp(ret, "Swedish_Sweden.1252"), "ret = %s\n", ret);
551 ret = setlocale(LC_ALL, "swiss");
552 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
553 if(ret)
554 ok(!strcmp(ret, "German_Switzerland.1252"), "ret = %s\n", ret);
556 ret = setlocale(LC_ALL, "trk");
557 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
558 if(ret)
559 ok(!strcmp(ret, "Turkish_Turkey.1254"), "ret = %s\n", ret);
561 ret = setlocale(LC_ALL, "turkish");
562 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
563 if(ret)
564 ok(!strcmp(ret, "Turkish_Turkey.1254"), "ret = %s\n", ret);
566 ret = setlocale(LC_ALL, "uk");
567 ok(ret != NULL, "ret == NULL\n");
568 if(ret)
569 ok(!strcmp(ret, "English_United Kingdom.1252")
570 || broken(!strcmp(ret, "Ukrainian_Ukraine.1251")), "ret = %s\n", ret);
572 ret = setlocale(LC_ALL, "us");
573 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
574 if(ret)
575 ok(!strcmp(ret, "English_United States.1252"), "ret = %s\n", ret);
577 ret = setlocale(LC_ALL, "usa");
578 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
579 if(ret)
580 ok(!strcmp(ret, "English_United States.1252"), "ret = %s\n", ret);
582 ret = setlocale(LC_ALL, "English_United States.ACP");
583 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
584 if(ret) {
585 strcpy(buf, "English_United States.");
586 GetLocaleInfoA(MAKELCID(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), SORT_DEFAULT),
587 LOCALE_IDEFAULTANSICODEPAGE, buf+strlen(buf), 80);
588 ok(!strcmp(ret, buf), "ret = %s, expected %s\n", ret, buf);
591 ret = setlocale(LC_ALL, "English_United States.OCP");
592 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
593 if(ret) {
594 strcpy(buf, "English_United States.");
595 GetLocaleInfoA(MAKELCID(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), SORT_DEFAULT),
596 LOCALE_IDEFAULTCODEPAGE, buf+strlen(buf), 80);
597 ok(!strcmp(ret, buf), "ret = %s, expected %s\n", ret, buf);
600 ret = setlocale(LC_ALL, "English_United States.UTF8");
601 ok(ret == NULL, "ret != NULL\n");
604 static void test_crtGetStringTypeW(void)
606 static const wchar_t str0[] = { '0', '\0' };
607 static const wchar_t strA[] = { 'A', '\0' };
608 static const wchar_t str_space[] = { ' ', '\0' };
609 static const wchar_t str_null[] = { '\0', '\0' };
610 static const wchar_t str_rand[] = { 1234, '\0' };
612 const wchar_t *str[] = { str0, strA, str_space, str_null, str_rand };
614 WORD out_crt, out;
615 BOOL ret_crt, ret;
616 int i;
618 if(!p__crtGetStringTypeW) {
619 win_skip("Skipping __crtGetStringTypeW tests\n");
620 return;
623 if(!pmemcpy_s) {
624 win_skip("Too old version of msvcrt.dll\n");
625 return;
628 for(i=0; i<sizeof(str)/sizeof(*str); i++) {
629 ret_crt = p__crtGetStringTypeW(0, CT_CTYPE1, str[i], 1, &out_crt);
630 ret = GetStringTypeW(CT_CTYPE1, str[i], 1, &out);
631 ok(ret == ret_crt, "%d) ret_crt = %d\n", i, (int)ret_crt);
632 ok(out == out_crt, "%d) out_crt = %x, expected %x\n", i, (int)out_crt, (int)out);
634 ret_crt = p__crtGetStringTypeW(0, CT_CTYPE2, str[i], 1, &out_crt);
635 ret = GetStringTypeW(CT_CTYPE2, str[i], 1, &out);
636 ok(ret == ret_crt, "%d) ret_crt = %d\n", i, (int)ret_crt);
637 ok(out == out_crt, "%d) out_crt = %x, expected %x\n", i, (int)out_crt, (int)out);
639 ret_crt = p__crtGetStringTypeW(0, CT_CTYPE3, str[i], 1, &out_crt);
640 ret = GetStringTypeW(CT_CTYPE3, str[i], 1, &out);
641 ok(ret == ret_crt, "%d) ret_crt = %d\n", i, (int)ret_crt);
642 ok(out == out_crt, "%d) out_crt = %x, expected %x\n", i, (int)out_crt, (int)out);
645 ret = p__crtGetStringTypeW(0, 3, str[0], 1, &out);
646 ok(!ret, "ret == TRUE\n");
649 static void test__Gettnames(void)
651 struct {
652 char *str[43];
653 LCID lcid;
654 int unk[2];
655 wchar_t *wstr[43];
656 char data[1];
657 } *ret;
658 int size;
659 char buf[64];
661 if(!setlocale(LC_ALL, "english"))
662 return;
664 ret = _Gettnames();
665 size = ret->data-(char*)ret;
666 /* Newer version of the structure stores both ascii and unicode strings.
667 * Unicode strings are only initialized on Windows 7
669 if(sizeof(void*) == 8)
670 ok(size==0x2c0 || broken(size==0x170), "strucure size: %x\n", size);
671 else
672 ok(size==0x164 || broken(size==0xb8), "strucure size: %x\n", size);
674 ok(!strcmp(ret->str[0], "Sun"), "ret->str[0] = %s\n", ret->str[0]);
675 ok(!strcmp(ret->str[1], "Mon"), "ret->str[1] = %s\n", ret->str[1]);
676 ok(!strcmp(ret->str[2], "Tue"), "ret->str[2] = %s\n", ret->str[2]);
677 ok(!strcmp(ret->str[3], "Wed"), "ret->str[3] = %s\n", ret->str[3]);
678 ok(!strcmp(ret->str[4], "Thu"), "ret->str[4] = %s\n", ret->str[4]);
679 ok(!strcmp(ret->str[5], "Fri"), "ret->str[5] = %s\n", ret->str[5]);
680 ok(!strcmp(ret->str[6], "Sat"), "ret->str[6] = %s\n", ret->str[6]);
681 ok(!strcmp(ret->str[7], "Sunday"), "ret->str[7] = %s\n", ret->str[7]);
682 ok(!strcmp(ret->str[8], "Monday"), "ret->str[8] = %s\n", ret->str[8]);
683 ok(!strcmp(ret->str[9], "Tuesday"), "ret->str[9] = %s\n", ret->str[9]);
684 ok(!strcmp(ret->str[10], "Wednesday"), "ret->str[10] = %s\n", ret->str[10]);
685 ok(!strcmp(ret->str[11], "Thursday"), "ret->str[11] = %s\n", ret->str[11]);
686 ok(!strcmp(ret->str[12], "Friday"), "ret->str[12] = %s\n", ret->str[12]);
687 ok(!strcmp(ret->str[13], "Saturday"), "ret->str[13] = %s\n", ret->str[13]);
688 ok(!strcmp(ret->str[14], "Jan"), "ret->str[14] = %s\n", ret->str[14]);
689 ok(!strcmp(ret->str[15], "Feb"), "ret->str[15] = %s\n", ret->str[15]);
690 ok(!strcmp(ret->str[16], "Mar"), "ret->str[16] = %s\n", ret->str[16]);
691 ok(!strcmp(ret->str[17], "Apr"), "ret->str[17] = %s\n", ret->str[17]);
692 ok(!strcmp(ret->str[18], "May"), "ret->str[18] = %s\n", ret->str[18]);
693 ok(!strcmp(ret->str[19], "Jun"), "ret->str[19] = %s\n", ret->str[19]);
694 ok(!strcmp(ret->str[20], "Jul"), "ret->str[20] = %s\n", ret->str[20]);
695 ok(!strcmp(ret->str[21], "Aug"), "ret->str[21] = %s\n", ret->str[21]);
696 ok(!strcmp(ret->str[22], "Sep"), "ret->str[22] = %s\n", ret->str[22]);
697 ok(!strcmp(ret->str[23], "Oct"), "ret->str[23] = %s\n", ret->str[23]);
698 ok(!strcmp(ret->str[24], "Nov"), "ret->str[24] = %s\n", ret->str[24]);
699 ok(!strcmp(ret->str[25], "Dec"), "ret->str[25] = %s\n", ret->str[25]);
700 ok(!strcmp(ret->str[26], "January"), "ret->str[26] = %s\n", ret->str[26]);
701 ok(!strcmp(ret->str[27], "February"), "ret->str[27] = %s\n", ret->str[27]);
702 ok(!strcmp(ret->str[28], "March"), "ret->str[28] = %s\n", ret->str[28]);
703 ok(!strcmp(ret->str[29], "April"), "ret->str[29] = %s\n", ret->str[29]);
704 ok(!strcmp(ret->str[30], "May"), "ret->str[30] = %s\n", ret->str[30]);
705 ok(!strcmp(ret->str[31], "June"), "ret->str[31] = %s\n", ret->str[31]);
706 ok(!strcmp(ret->str[32], "July"), "ret->str[32] = %s\n", ret->str[32]);
707 ok(!strcmp(ret->str[33], "August"), "ret->str[33] = %s\n", ret->str[33]);
708 ok(!strcmp(ret->str[34], "September"), "ret->str[34] = %s\n", ret->str[34]);
709 ok(!strcmp(ret->str[35], "October"), "ret->str[35] = %s\n", ret->str[35]);
710 ok(!strcmp(ret->str[36], "November"), "ret->str[36] = %s\n", ret->str[36]);
711 ok(!strcmp(ret->str[37], "December"), "ret->str[37] = %s\n", ret->str[37]);
712 ok(!strcmp(ret->str[38], "AM"), "ret->str[38] = %s\n", ret->str[38]);
713 ok(!strcmp(ret->str[39], "PM"), "ret->str[39] = %s\n", ret->str[39]);
714 ok(!strcmp(ret->str[40], "M/d/yyyy") || broken(!strcmp(ret->str[40], "M/d/yy"))/*NT*/,
715 "ret->str[40] = %s\n", ret->str[40]);
716 size = GetLocaleInfoA(MAKELCID(LANG_ENGLISH, SORT_DEFAULT),
717 LOCALE_SLONGDATE|LOCALE_NOUSEROVERRIDE, buf, sizeof(buf));
718 ok(size, "GetLocaleInfo failed: %x\n", GetLastError());
719 ok(!strcmp(ret->str[41], buf), "ret->str[41] = %s, expected %s\n", ret->str[41], buf);
720 free(ret);
722 if(!setlocale(LC_TIME, "german"))
723 return;
725 ret = _Gettnames();
726 ok(!strcmp(ret->str[0], "So"), "ret->str[0] = %s\n", ret->str[0]);
727 ok(!strcmp(ret->str[1], "Mo"), "ret->str[1] = %s\n", ret->str[1]);
728 ok(!strcmp(ret->str[2], "Di"), "ret->str[2] = %s\n", ret->str[2]);
729 ok(!strcmp(ret->str[3], "Mi"), "ret->str[3] = %s\n", ret->str[3]);
730 ok(!strcmp(ret->str[4], "Do"), "ret->str[4] = %s\n", ret->str[4]);
731 ok(!strcmp(ret->str[5], "Fr"), "ret->str[5] = %s\n", ret->str[5]);
732 ok(!strcmp(ret->str[6], "Sa"), "ret->str[6] = %s\n", ret->str[6]);
733 ok(!strcmp(ret->str[7], "Sonntag"), "ret->str[7] = %s\n", ret->str[7]);
734 ok(!strcmp(ret->str[8], "Montag"), "ret->str[8] = %s\n", ret->str[8]);
735 ok(!strcmp(ret->str[9], "Dienstag"), "ret->str[9] = %s\n", ret->str[9]);
736 ok(!strcmp(ret->str[10], "Mittwoch"), "ret->str[10] = %s\n", ret->str[10]);
737 ok(!strcmp(ret->str[11], "Donnerstag"), "ret->str[11] = %s\n", ret->str[11]);
738 ok(!strcmp(ret->str[12], "Freitag"), "ret->str[12] = %s\n", ret->str[12]);
739 ok(!strcmp(ret->str[13], "Samstag"), "ret->str[13] = %s\n", ret->str[13]);
740 ok(!strcmp(ret->str[14], "Jan"), "ret->str[14] = %s\n", ret->str[14]);
741 ok(!strcmp(ret->str[15], "Feb"), "ret->str[15] = %s\n", ret->str[15]);
742 ok(!strcmp(ret->str[16], "Mrz"), "ret->str[16] = %s\n", ret->str[16]);
743 ok(!strcmp(ret->str[17], "Apr"), "ret->str[17] = %s\n", ret->str[17]);
744 ok(!strcmp(ret->str[18], "Mai"), "ret->str[18] = %s\n", ret->str[18]);
745 ok(!strcmp(ret->str[19], "Jun"), "ret->str[19] = %s\n", ret->str[19]);
746 ok(!strcmp(ret->str[20], "Jul"), "ret->str[20] = %s\n", ret->str[20]);
747 ok(!strcmp(ret->str[21], "Aug"), "ret->str[21] = %s\n", ret->str[21]);
748 ok(!strcmp(ret->str[22], "Sep"), "ret->str[22] = %s\n", ret->str[22]);
749 ok(!strcmp(ret->str[23], "Okt"), "ret->str[23] = %s\n", ret->str[23]);
750 ok(!strcmp(ret->str[24], "Nov"), "ret->str[24] = %s\n", ret->str[24]);
751 ok(!strcmp(ret->str[25], "Dez"), "ret->str[25] = %s\n", ret->str[25]);
752 ok(!strcmp(ret->str[26], "Januar"), "ret->str[26] = %s\n", ret->str[26]);
753 ok(!strcmp(ret->str[27], "Februar"), "ret->str[27] = %s\n", ret->str[27]);
754 ok(!strcmp(ret->str[29], "April"), "ret->str[29] = %s\n", ret->str[29]);
755 ok(!strcmp(ret->str[30], "Mai"), "ret->str[30] = %s\n", ret->str[30]);
756 ok(!strcmp(ret->str[31], "Juni"), "ret->str[31] = %s\n", ret->str[31]);
757 ok(!strcmp(ret->str[32], "Juli"), "ret->str[32] = %s\n", ret->str[32]);
758 ok(!strcmp(ret->str[33], "August"), "ret->str[33] = %s\n", ret->str[33]);
759 ok(!strcmp(ret->str[34], "September"), "ret->str[34] = %s\n", ret->str[34]);
760 ok(!strcmp(ret->str[35], "Oktober"), "ret->str[35] = %s\n", ret->str[35]);
761 ok(!strcmp(ret->str[36], "November"), "ret->str[36] = %s\n", ret->str[36]);
762 ok(!strcmp(ret->str[37], "Dezember"), "ret->str[37] = %s\n", ret->str[37]);
763 ok(!strcmp(ret->str[38], ""), "ret->str[38] = %s\n", ret->str[38]);
764 ok(!strcmp(ret->str[39], ""), "ret->str[39] = %s\n", ret->str[39]);
765 ok(!strcmp(ret->str[40], "dd.MM.yyyy") || broken(!strcmp(ret->str[40], "dd.MM.yy"))/*NT*/,
766 "ret->str[40] = %s\n", ret->str[40]);
767 ok(!strcmp(ret->str[41], "dddd, d. MMMM yyyy"), "ret->str[41] = %s\n", ret->str[41]);
768 free(ret);
770 setlocale(LC_ALL, "C");
773 static void test___mb_cur_max_func(void)
775 int mb_cur_max;
776 CPINFO cp;
778 setlocale(LC_ALL, "C");
779 GetCPInfo(CP_ACP, &cp);
781 /* for newer Windows */
782 if(!p___mb_cur_max_func)
783 win_skip("Skipping ___mb_cur_max_func tests\n");
784 else {
785 mb_cur_max = p___mb_cur_max_func();
786 ok(mb_cur_max == 1, "mb_cur_max = %d, expected 1\n", mb_cur_max);
788 /* some old Windows don't set chinese */
789 if (!setlocale(LC_ALL, "chinese"))
790 win_skip("Skipping test with chinese locale\n");
791 else {
792 mb_cur_max = p___mb_cur_max_func();
793 ok(mb_cur_max == 2, "mb_cur_max = %d, expected 2\n", mb_cur_max);
794 setlocale(LC_ALL, "C");
798 /* for older Windows */
799 if (!p__p___mb_cur_max)
800 win_skip("Skipping __p___mb_cur_max tests\n");
801 else {
802 mb_cur_max = *p__p___mb_cur_max();
803 if (cp.MaxCharSize != 1) {
804 todo_wine ok(mb_cur_max == cp.MaxCharSize, "mb_cur_max = %d, expected %d\n",
805 mb_cur_max, cp.MaxCharSize);
807 else {
808 ok(mb_cur_max == 1, "mb_cur_max = %d, expected 1\n", mb_cur_max);
811 /* some old Windows don't set chinese */
812 if (!setlocale(LC_ALL, "chinese"))
813 win_skip("Skipping test with chinese locale\n");
814 else {
815 mb_cur_max = *p__p___mb_cur_max();
816 ok(mb_cur_max == 2, "mb_cur_max = %d, expected 2\n", mb_cur_max);
817 setlocale(LC_ALL, "C");
822 START_TEST(locale)
824 init();
826 test_crtGetStringTypeW();
827 test_setlocale();
828 test__Gettnames();
829 test___mb_cur_max_func();