msvcrt/tests: Add more tests for setlocale().
[wine/wine-gecko.git] / dlls / msvcrt / tests / locale.c
blob23ecbc5fa552caeb8eccb1fa334ad55141b1c737
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);
29 static void init(void)
31 HMODULE hmod = GetModuleHandleA("msvcrt.dll");
33 p__crtGetStringTypeW = (void*)GetProcAddress(hmod, "__crtGetStringTypeW");
34 pmemcpy_s = (void*)GetProcAddress(hmod, "memcpy_s");
37 static void test_setlocale(void)
39 static const char lc_all[] = "LC_COLLATE=C;LC_CTYPE=C;"
40 "LC_MONETARY=Greek_Greece.1253;LC_NUMERIC=Polish_Poland.1250;LC_TIME=C";
42 char *ret, buf[100];
44 ret = setlocale(20, "C");
45 ok(ret == NULL, "ret = %s\n", ret);
47 ret = setlocale(LC_ALL, "");
48 ok(ret != NULL, "ret == NULL\n");
50 ret = setlocale(LC_ALL, "C");
51 ok(!strcmp(ret, "C"), "ret = %s\n", ret);
53 ret = setlocale(LC_ALL, NULL);
54 ok(!strcmp(ret, "C"), "ret = %s\n", ret);
56 if(!setlocale(LC_NUMERIC, "Polish")
57 || !setlocale(LC_NUMERIC, "Greek")
58 || !setlocale(LC_NUMERIC, "German")
59 || !setlocale(LC_NUMERIC, "English")) {
60 win_skip("System with limited locales\n");
61 return;
64 ret = setlocale(LC_NUMERIC, "Polish");
65 ok(!strcmp(ret, "Polish_Poland.1250"), "ret = %s\n", ret);
67 ret = setlocale(LC_MONETARY, "Greek");
68 ok(!strcmp(ret, "Greek_Greece.1253"), "ret = %s\n", ret);
70 ret = setlocale(LC_ALL, NULL);
71 ok(!strcmp(ret, lc_all), "ret = %s\n", ret);
73 strcpy(buf, ret);
74 ret = setlocale(LC_ALL, buf);
75 ok(!strcmp(ret, lc_all), "ret = %s\n", ret);
77 ret = setlocale(LC_ALL, "German");
78 todo_wine ok(!strcmp(ret, "German_Germany.1252"), "ret = %s\n", ret);
80 /* This test shows that _country_synonyms table is incorrect */
81 /* It translates "America" to "US" */
82 ret = setlocale(LC_ALL, "America");
83 ok(ret == NULL, "ret = %s\n", ret);
85 ret = setlocale(LC_ALL, "american");
86 todo_wine 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 todo_wine 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 todo_wine 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 todo_wine 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 todo_wine 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 todo_wine 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 todo_wine ok(!strcmp(ret, "Chinese (Simplified)_People's Republic of China.936")
119 || broken(!strcmp(ret, "Chinese_Taiwan.950")), "ret = %s\n", ret);
121 ret = setlocale(LC_ALL, "chinese-simplified");
122 todo_wine 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 || broken(!strcmp(ret, "Chinese_People's Republic of China.936")), "ret = %s\n", ret);
127 ret = setlocale(LC_ALL, "chinese-traditional");
128 todo_wine ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
129 if(ret)
130 ok(!strcmp(ret, "Chinese (Traditional)_Taiwan.950")
131 || broken(!strcmp(ret, "Chinese_Taiwan.950")), "ret = %s\n", ret);
133 ret = setlocale(LC_ALL, "chs");
134 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
135 if(ret)
136 todo_wine ok(!strcmp(ret, "Chinese (Simplified)_People's Republic of China.936")
137 || broken(!strcmp(ret, "Chinese_People's Republic of China.936")), "ret = %s\n", ret);
139 ret = setlocale(LC_ALL, "cht");
140 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
141 if(ret)
142 todo_wine ok(!strcmp(ret, "Chinese (Traditional)_Taiwan.950")
143 || broken(!strcmp(ret, "Chinese_Taiwan.950")), "ret = %s\n", ret);
145 ret = setlocale(LC_ALL, "csy");
146 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
147 if(ret)
148 ok(!strcmp(ret, "Czech_Czech Republic.1250"), "ret = %s\n", ret);
150 ret = setlocale(LC_ALL, "czech");
151 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
152 if(ret)
153 ok(!strcmp(ret, "Czech_Czech Republic.1250"), "ret = %s\n", ret);
155 ret = setlocale(LC_ALL, "dan");
156 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
157 if(ret)
158 ok(!strcmp(ret, "Danish_Denmark.1252"), "ret = %s\n", ret);
160 ret = setlocale(LC_ALL, "danish");
161 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
162 if(ret)
163 ok(!strcmp(ret, "Danish_Denmark.1252"), "ret = %s\n", ret);
165 ret = setlocale(LC_ALL, "dea");
166 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
167 if(ret)
168 todo_wine ok(!strcmp(ret, "German_Austria.1252"), "ret = %s\n", ret);
170 ret = setlocale(LC_ALL, "des");
171 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
172 if(ret)
173 todo_wine ok(!strcmp(ret, "German_Switzerland.1252"), "ret = %s\n", ret);
175 ret = setlocale(LC_ALL, "deu");
176 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
177 if(ret)
178 todo_wine ok(!strcmp(ret, "German_Germany.1252"), "ret = %s\n", ret);
180 ret = setlocale(LC_ALL, "dutch");
181 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
182 if(ret)
183 todo_wine ok(!strcmp(ret, "Dutch_Netherlands.1252"), "ret = %s\n", ret);
185 ret = setlocale(LC_ALL, "dutch-belgian");
186 todo_wine ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
187 if(ret)
188 ok(!strcmp(ret, "Dutch_Belgium.1252")
189 || broken(!strcmp(ret, "Dutch_Netherlands.1252")), "ret = %s\n", ret);
191 ret = setlocale(LC_ALL, "ena");
192 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
193 if(ret)
194 todo_wine ok(!strcmp(ret, "English_Australia.1252")
195 || broken(!strcmp(ret, "English_United States.1252")), "ret = %s\n", ret);
197 ret = setlocale(LC_ALL, "ell");
198 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
199 if(ret)
200 ok(!strcmp(ret, "Greek_Greece.1253"), "ret = %s\n", ret);
202 ret = setlocale(LC_ALL, "enc");
203 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
204 if(ret)
205 todo_wine ok(!strcmp(ret, "English_Canada.1252")
206 || broken(!strcmp(ret, "English_United States.1252")), "ret = %s\n", ret);
208 ret = setlocale(LC_ALL, "eng");
209 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
210 if(ret)
211 todo_wine ok(!strcmp(ret, "English_United Kingdom.1252")
212 || broken(!strcmp(ret, "English_United States.1252")), "ret = %s\n", ret);
214 ret = setlocale(LC_ALL, "enu");
215 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
216 if(ret)
217 todo_wine ok(!strcmp(ret, "English_United States.1252"), "ret = %s\n", ret);
219 ret = setlocale(LC_ALL, "enz");
220 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
221 if(ret)
222 todo_wine ok(!strcmp(ret, "English_New Zealand.1252")
223 || broken(!strcmp(ret, "English_United States.1252")), "ret = %s\n", ret);
225 ret = setlocale(LC_ALL, "english");
226 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
227 if(ret)
228 todo_wine ok(!strcmp(ret, "English_United States.1252"), "ret = %s\n", ret);
230 ret = setlocale(LC_ALL, "english-american");
231 todo_wine ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
232 if(ret)
233 ok(!strcmp(ret, "English_United States.1252"), "ret = %s\n", ret);
235 ret = setlocale(LC_ALL, "english-aus");
236 todo_wine ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
237 if(ret)
238 ok(!strcmp(ret, "English_Australia.1252")
239 || broken(!strcmp(ret, "English_United States.1252")), "ret = %s\n", ret);
241 ret = setlocale(LC_ALL, "english-can");
242 todo_wine ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
243 if(ret)
244 ok(!strcmp(ret, "English_Canada.1252")
245 || broken(!strcmp(ret, "English_United States.1252")), "ret = %s\n", ret);
247 ret = setlocale(LC_ALL, "english-nz");
248 todo_wine ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
249 if(ret)
250 ok(!strcmp(ret, "English_New Zealand.1252")
251 || broken(!strcmp(ret, "English_United States.1252")), "ret = %s\n", ret);
253 ret = setlocale(LC_ALL, "english-uk");
254 todo_wine ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
255 if(ret)
256 ok(!strcmp(ret, "English_United Kingdom.1252")
257 || broken(!strcmp(ret, "English_United States.1252")), "ret = %s\n", ret);
259 ret = setlocale(LC_ALL, "english-us");
260 todo_wine ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
261 if(ret)
262 ok(!strcmp(ret, "English_United States.1252"), "ret = %s\n", ret);
264 ret = setlocale(LC_ALL, "english-usa");
265 todo_wine ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
266 if(ret)
267 ok(!strcmp(ret, "English_United States.1252"), "ret = %s\n", ret);
269 ret = setlocale(LC_ALL, "esm");
270 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
271 if(ret)
272 todo_wine ok(!strcmp(ret, "Spanish_Mexico.1252"), "ret = %s\n", ret);
274 ret = setlocale(LC_ALL, "esn");
275 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
276 if(ret)
277 todo_wine ok(!strcmp(ret, "Spanish_Spain.1252")
278 || broken(!strcmp(ret, "Spanish - Modern Sort_Spain.1252")), "ret = %s\n", ret);
280 ret = setlocale(LC_ALL, "esp");
281 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
282 if(ret)
283 todo_wine ok(!strcmp(ret, "Spanish_Spain.1252")
284 || broken(!strcmp(ret, "Spanish - Traditional Sort_Spain.1252")), "ret = %s\n", ret);
286 ret = setlocale(LC_ALL, "fin");
287 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
288 if(ret)
289 ok(!strcmp(ret, "Finnish_Finland.1252"), "ret = %s\n", ret);
291 ret = setlocale(LC_ALL, "finnish");
292 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
293 if(ret)
294 ok(!strcmp(ret, "Finnish_Finland.1252"), "ret = %s\n", ret);
296 ret = setlocale(LC_ALL, "fra");
297 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
298 if(ret)
299 todo_wine ok(!strcmp(ret, "French_France.1252"), "ret = %s\n", ret);
301 ret = setlocale(LC_ALL, "frb");
302 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
303 if(ret)
304 todo_wine ok(!strcmp(ret, "French_Belgium.1252")
305 || broken(!strcmp(ret, "French_France.1252")), "ret = %s\n", ret);
307 ret = setlocale(LC_ALL, "frc");
308 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
309 if(ret)
310 todo_wine ok(!strcmp(ret, "French_Canada.1252")
311 || broken(!strcmp(ret, "French_France.1252")), "ret = %s\n", ret);
313 ret = setlocale(LC_ALL, "french");
314 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
315 if(ret)
316 todo_wine ok(!strcmp(ret, "French_France.1252"), "ret = %s\n", ret);
318 ret = setlocale(LC_ALL, "french-belgian");
319 todo_wine ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
320 if(ret)
321 ok(!strcmp(ret, "French_Belgium.1252")
322 || broken(!strcmp(ret, "French_France.1252")), "ret = %s\n", ret);
324 ret = setlocale(LC_ALL, "french-canadian");
325 todo_wine ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
326 if(ret)
327 ok(!strcmp(ret, "French_Canada.1252")
328 || broken(!strcmp(ret, "French_France.1252")), "ret = %s\n", ret);
330 ret = setlocale(LC_ALL, "french-swiss");
331 todo_wine ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
332 if(ret)
333 ok(!strcmp(ret, "French_Switzerland.1252")
334 || broken(!strcmp(ret, "French_France.1252")), "ret = %s\n", ret);
336 ret = setlocale(LC_ALL, "frs");
337 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
338 if(ret)
339 todo_wine ok(!strcmp(ret, "French_Switzerland.1252")
340 || broken(!strcmp(ret, "French_France.1252")), "ret = %s\n", ret);
342 ret = setlocale(LC_ALL, "german");
343 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
344 if(ret)
345 todo_wine ok(!strcmp(ret, "German_Germany.1252"), "ret = %s\n", ret);
347 ret = setlocale(LC_ALL, "german-austrian");
348 todo_wine ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
349 if(ret)
350 ok(!strcmp(ret, "German_Austria.1252")
351 || broken(!strcmp(ret, "German_Germany.1252")), "ret = %s\n", ret);
353 ret = setlocale(LC_ALL, "german-swiss");
354 todo_wine ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
355 if(ret)
356 ok(!strcmp(ret, "German_Switzerland.1252")
357 || broken(!strcmp(ret, "German_Germany.1252")), "ret = %s\n", ret);
359 ret = setlocale(LC_ALL, "greek");
360 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
361 if(ret)
362 ok(!strcmp(ret, "Greek_Greece.1253"), "ret = %s\n", ret);
364 ret = setlocale(LC_ALL, "hun");
365 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
366 if(ret)
367 ok(!strcmp(ret, "Hungarian_Hungary.1250"), "ret = %s\n", ret);
369 ret = setlocale(LC_ALL, "hungarian");
370 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
371 if(ret)
372 ok(!strcmp(ret, "Hungarian_Hungary.1250"), "ret = %s\n", ret);
374 ret = setlocale(LC_ALL, "icelandic");
375 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
376 if(ret)
377 ok(!strcmp(ret, "Icelandic_Iceland.1252"), "ret = %s\n", ret);
379 ret = setlocale(LC_ALL, "isl");
380 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
381 if(ret)
382 ok(!strcmp(ret, "Icelandic_Iceland.1252"), "ret = %s\n", ret);
384 ret = setlocale(LC_ALL, "ita");
385 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
386 if(ret)
387 todo_wine ok(!strcmp(ret, "Italian_Italy.1252"), "ret = %s\n", ret);
389 ret = setlocale(LC_ALL, "italian");
390 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
391 if(ret)
392 todo_wine ok(!strcmp(ret, "Italian_Italy.1252"), "ret = %s\n", ret);
394 ret = setlocale(LC_ALL, "italian-swiss");
395 todo_wine ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
396 if(ret)
397 ok(!strcmp(ret, "Italian_Switzerland.1252") || broken(!strcmp(ret, "Italian_Italy.1252")), "ret = %s\n", ret);
399 ret = setlocale(LC_ALL, "its");
400 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
401 if(ret)
402 todo_wine ok(!strcmp(ret, "Italian_Switzerland.1252") || broken(!strcmp(ret, "Italian_Italy.1252")), "ret = %s\n", ret);
404 ret = setlocale(LC_ALL, "japanese");
405 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
406 if(ret)
407 ok(!strcmp(ret, "Japanese_Japan.932"), "ret = %s\n", ret);
409 ret = setlocale(LC_ALL, "jpn");
410 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
411 if(ret)
412 ok(!strcmp(ret, "Japanese_Japan.932"), "ret = %s\n", ret);
414 ret = setlocale(LC_ALL, "korean");
415 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
416 if(ret)
417 ok(!strcmp(ret, "Korean_Korea.949"), "ret = %s\n", ret);
419 ret = setlocale(LC_ALL, "korean");
420 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
421 if(ret)
422 ok(!strcmp(ret, "Korean_Korea.949"), "ret = %s\n", ret);
424 ret = setlocale(LC_ALL, "nlb");
425 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
426 if(ret)
427 todo_wine ok(!strcmp(ret, "Dutch_Belgium.1252")
428 || broken(!strcmp(ret, "Dutch_Netherlands.1252")), "ret = %s\n", ret);
430 ret = setlocale(LC_ALL, "nld");
431 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
432 if(ret)
433 todo_wine ok(!strcmp(ret, "Dutch_Netherlands.1252"), "ret = %s\n", ret);
435 ret = setlocale(LC_ALL, "non");
436 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
437 if(ret)
438 todo_wine ok((!strcmp( ret, "Norwegian-Nynorsk_Norway.1252"))
439 || broken(!strcmp(ret, "Norwegian (Bokmål)_Norway.1252"))
440 || broken(!strcmp(ret, "Norwegian (Nynorsk)_Norway.1252")), "ret = %s\n", ret);
442 ret = setlocale(LC_ALL, "nor");
443 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
444 if(ret)
445 todo_wine ok(!strcmp(ret, "Norwegian (Bokmål)_Norway.1252"), "ret = %s\n", ret);
447 ret = setlocale(LC_ALL, "norwegian-bokmal");
448 todo_wine ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
449 if(ret)
450 ok(!strcmp(ret, "Norwegian (Bokmål)_Norway.1252"), "ret = %s\n", ret);
452 ret = setlocale(LC_ALL, "norwegian-nynorsk");
453 todo_wine ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
454 if(ret)
455 ok(!strcmp(ret, "Norwegian-Nynorsk_Norway.1252")
456 || broken(!strcmp( ret, "Norwegian (Nynorsk)_Norway.1252"))
457 || broken(!strcmp(ret, "Norwegian (Bokmål)_Norway.1252")), "ret = %s\n", ret);
459 ret = setlocale(LC_ALL, "plk");
460 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
461 if(ret)
462 ok(!strcmp(ret, "Polish_Poland.1250"), "ret = %s\n", ret);
464 ret = setlocale(LC_ALL, "polish");
465 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
466 if(ret)
467 ok(!strcmp(ret, "Polish_Poland.1250"), "ret = %s\n", ret);
469 ret = setlocale(LC_ALL, "portugese");
470 todo_wine ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
471 if(ret)
472 ok(!strcmp(ret, "Portuguese_Brazil.1252"), "ret = %s\n", ret);
474 ret = setlocale(LC_ALL, "portuguese-brazil");
475 todo_wine ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
476 if(ret)
477 ok(!strcmp(ret, "Portuguese_Brazil.1252"), "ret = %s\n", ret);
479 ret = setlocale(LC_ALL, "ptb");
480 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
481 if(ret)
482 todo_wine ok(!strcmp(ret, "Portuguese_Brazil.1252"), "ret = %s\n", ret);
484 ret = setlocale(LC_ALL, "ptg");
485 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
486 if(ret)
487 todo_wine ok(!strcmp(ret, "Portuguese_Portugal.1252"), "ret = %s\n", ret);
489 ret = setlocale(LC_ALL, "rus");
490 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
491 if(ret)
492 ok(!strcmp(ret, "Russian_Russia.1251"), "ret = %s\n", ret);
494 ret = setlocale(LC_ALL, "russian");
495 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
496 if(ret)
497 ok(!strcmp(ret, "Russian_Russia.1251"), "ret = %s\n", ret);
499 ret = setlocale(LC_ALL, "sky");
500 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
501 if(ret)
502 ok(!strcmp(ret, "Slovak_Slovakia.1250"), "ret = %s\n", ret);
504 ret = setlocale(LC_ALL, "slovak");
505 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
506 if(ret)
507 ok(!strcmp(ret, "Slovak_Slovakia.1250"), "ret = %s\n", ret);
509 ret = setlocale(LC_ALL, "spanish");
510 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
511 if(ret)
512 todo_wine ok(!strcmp(ret, "Spanish_Spain.1252")
513 || broken(!strcmp(ret, "Spanish - Traditional Sort_Spain.1252")), "ret = %s\n", ret);
515 ret = setlocale(LC_ALL, "spanish-mexican");
516 todo_wine ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
517 if(ret)
518 ok(!strcmp(ret, "Spanish_Mexico.1252")
519 || broken(!strcmp(ret, "Spanish_Spain.1252")), "ret = %s\n", ret);
521 ret = setlocale(LC_ALL, "spanish-modern");
522 todo_wine ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
523 if(ret)
524 ok(!strcmp(ret, "Spanish - Modern Sort_Spain.1252")
525 || broken(!strcmp(ret, "Spanish_Spain.1252")), "ret = %s\n", ret);
527 ret = setlocale(LC_ALL, "sve");
528 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
529 if(ret)
530 ok(!strcmp(ret, "Swedish_Sweden.1252"), "ret = %s\n", ret);
532 ret = setlocale(LC_ALL, "swedish");
533 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
534 if(ret)
535 ok(!strcmp(ret, "Swedish_Sweden.1252"), "ret = %s\n", ret);
537 ret = setlocale(LC_ALL, "swiss");
538 todo_wine ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
539 if(ret)
540 ok(!strcmp(ret, "German_Switzerland.1252"), "ret = %s\n", ret);
542 ret = setlocale(LC_ALL, "trk");
543 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
544 if(ret)
545 ok(!strcmp(ret, "Turkish_Turkey.1254"), "ret = %s\n", ret);
547 ret = setlocale(LC_ALL, "turkish");
548 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
549 if(ret)
550 ok(!strcmp(ret, "Turkish_Turkey.1254"), "ret = %s\n", ret);
552 ret = setlocale(LC_ALL, "uk");
553 ok(ret != NULL, "ret == NULL\n");
554 if(ret)
555 todo_wine ok(!strcmp(ret, "English_United Kingdom.1252")
556 || broken(!strcmp(ret, "Ukrainian_Ukraine.1251")), "ret = %s\n", ret);
558 ret = setlocale(LC_ALL, "us");
559 todo_wine ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
560 if(ret)
561 ok(!strcmp(ret, "English_United States.1252"), "ret = %s\n", ret);
563 ret = setlocale(LC_ALL, "usa");
564 todo_wine ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
565 if(ret)
566 ok(!strcmp(ret, "English_United States.1252"), "ret = %s\n", ret);
568 ret = setlocale(LC_ALL, "US");
569 todo_wine ok(ret != NULL, "ret == NULL\n");
570 if(ret)
571 ok(!strcmp(ret, "English_United States.1252"), "ret = %s\n", ret);
574 static void test_crtGetStringTypeW(void)
576 static const wchar_t str0[] = { '0', '\0' };
577 static const wchar_t strA[] = { 'A', '\0' };
578 static const wchar_t str_space[] = { ' ', '\0' };
579 static const wchar_t str_null[] = { '\0', '\0' };
580 static const wchar_t str_rand[] = { 1234, '\0' };
582 const wchar_t *str[] = { str0, strA, str_space, str_null, str_rand };
584 WORD out_crt, out;
585 BOOL ret_crt, ret;
586 int i;
588 if(!p__crtGetStringTypeW) {
589 win_skip("Skipping __crtGetStringTypeW tests\n");
590 return;
593 if(!pmemcpy_s) {
594 win_skip("Too old version of msvcrt.dll\n");
595 return;
598 for(i=0; i<sizeof(str)/sizeof(*str); i++) {
599 ret_crt = p__crtGetStringTypeW(0, CT_CTYPE1, str[i], 1, &out_crt);
600 ret = GetStringTypeW(CT_CTYPE1, str[i], 1, &out);
601 ok(ret == ret_crt, "%d) ret_crt = %d\n", i, (int)ret_crt);
602 ok(out == out_crt, "%d) out_crt = %x, expected %x\n", i, (int)out_crt, (int)out);
604 ret_crt = p__crtGetStringTypeW(0, CT_CTYPE2, str[i], 1, &out_crt);
605 ret = GetStringTypeW(CT_CTYPE2, str[i], 1, &out);
606 ok(ret == ret_crt, "%d) ret_crt = %d\n", i, (int)ret_crt);
607 ok(out == out_crt, "%d) out_crt = %x, expected %x\n", i, (int)out_crt, (int)out);
609 ret_crt = p__crtGetStringTypeW(0, CT_CTYPE3, str[i], 1, &out_crt);
610 ret = GetStringTypeW(CT_CTYPE3, str[i], 1, &out);
611 ok(ret == ret_crt, "%d) ret_crt = %d\n", i, (int)ret_crt);
612 ok(out == out_crt, "%d) out_crt = %x, expected %x\n", i, (int)out_crt, (int)out);
615 ret = p__crtGetStringTypeW(0, 3, str[0], 1, &out);
616 ok(!ret, "ret == TRUE\n");
619 START_TEST(locale)
621 init();
623 test_crtGetStringTypeW();
624 test_setlocale();