0e8d0dd84a25d76c5a55925bd8dd94ccc680cd2a
[reactos.git] / rostests / winetests / msvcrt / locale.c
1 /*
2 * Unit test suite for locale functions.
3 *
4 * Copyright 2010 Piotr Caban for CodeWeavers
5 *
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.
10 *
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.
15 *
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
19 */
20
21 #include <locale.h>
22
23 #include "wine/test.h"
24 #include "winnls.h"
25
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
29 static void init(void)
30 {
31 HMODULE hmod = GetModuleHandleA("msvcrt.dll");
32
33 p__crtGetStringTypeW = (void*)GetProcAddress(hmod, "__crtGetStringTypeW");
34 pmemcpy_s = (void*)GetProcAddress(hmod, "memcpy_s");
35 }
36
37 static void test_setlocale(void)
38 {
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";
41
42 char *ret, buf[100];
43
44 ret = setlocale(20, "C");
45 ok(ret == NULL, "ret = %s\n", ret);
46
47 ret = setlocale(LC_ALL, "");
48 ok(ret != NULL, "ret == NULL\n");
49
50 ret = setlocale(LC_ALL, "C");
51 ok(!strcmp(ret, "C"), "ret = %s\n", ret);
52
53 ret = setlocale(LC_ALL, NULL);
54 ok(!strcmp(ret, "C"), "ret = %s\n", ret);
55
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;
62 }
63
64 ret = setlocale(LC_NUMERIC, "Polish");
65 ok(!strcmp(ret, "Polish_Poland.1250"), "ret = %s\n", ret);
66
67 ret = setlocale(LC_MONETARY, "Greek");
68 ok(!strcmp(ret, "Greek_Greece.1253"), "ret = %s\n", ret);
69
70 ret = setlocale(LC_ALL, NULL);
71 ok(!strcmp(ret, lc_all), "ret = %s\n", ret);
72
73 strcpy(buf, ret);
74 ret = setlocale(LC_ALL, buf);
75 ok(!strcmp(ret, lc_all), "ret = %s\n", ret);
76
77 ret = setlocale(LC_ALL, "German");
78 ok(!strcmp(ret, "German_Germany.1252"), "ret = %s\n", ret);
79
80 ret = setlocale(LC_ALL, "american");
81 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
82 if(ret)
83 ok(!strcmp(ret, "English_United States.1252"), "ret = %s\n", ret);
84
85 ret = setlocale(LC_ALL, "american english");
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);
89
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);
94
95 ret = setlocale(LC_ALL, "australian");
96 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
97 if(ret)
98 ok(!strcmp(ret, "English_Australia.1252"), "ret = %s\n", ret);
99
100 ret = setlocale(LC_ALL, "belgian");
101 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
102 if(ret)
103 ok(!strcmp(ret, "Dutch_Belgium.1252"), "ret = %s\n", ret);
104
105 ret = setlocale(LC_ALL, "canadian");
106 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
107 if(ret)
108 ok(!strcmp(ret, "English_Canada.1252"), "ret = %s\n", ret);
109
110 ret = setlocale(LC_ALL, "chinese");
111 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
112 if(ret)
113 ok(!strcmp(ret, "Chinese (Simplified)_People's Republic of China.936")
114 || broken(!strcmp(ret, "Chinese_Taiwan.950")), "ret = %s\n", ret);
115
116 ret = setlocale(LC_ALL, "chinese-simplified");
117 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
118 if(ret)
119 ok(!strcmp(ret, "Chinese (Simplified)_People's Republic of China.936")
120 || broken(!strcmp(ret, "Chinese_People's Republic of China.936"))
121 || broken(!strcmp(ret, "Chinese_Taiwan.950")), "ret = %s\n", ret);
122
123 ret = setlocale(LC_ALL, "chinese-traditional");
124 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
125 if(ret)
126 ok(!strcmp(ret, "Chinese (Traditional)_Taiwan.950")
127 || broken(!strcmp(ret, "Chinese_Taiwan.950")), "ret = %s\n", ret);
128
129 ret = setlocale(LC_ALL, "chs");
130 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
131 if(ret)
132 ok(!strcmp(ret, "Chinese (Simplified)_People's Republic of China.936")
133 || broken(!strcmp(ret, "Chinese_People's Republic of China.936")), "ret = %s\n", ret);
134
135 ret = setlocale(LC_ALL, "cht");
136 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
137 if(ret)
138 ok(!strcmp(ret, "Chinese (Traditional)_Taiwan.950")
139 || broken(!strcmp(ret, "Chinese_Taiwan.950")), "ret = %s\n", ret);
140
141 ret = setlocale(LC_ALL, "csy");
142 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
143 if(ret)
144 ok(!strcmp(ret, "Czech_Czech Republic.1250"), "ret = %s\n", ret);
145
146 ret = setlocale(LC_ALL, "czech");
147 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
148 if(ret)
149 ok(!strcmp(ret, "Czech_Czech Republic.1250"), "ret = %s\n", ret);
150
151 ret = setlocale(LC_ALL, "dan");
152 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
153 if(ret)
154 ok(!strcmp(ret, "Danish_Denmark.1252"), "ret = %s\n", ret);
155
156 ret = setlocale(LC_ALL, "danish");
157 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
158 if(ret)
159 ok(!strcmp(ret, "Danish_Denmark.1252"), "ret = %s\n", ret);
160
161 ret = setlocale(LC_ALL, "dea");
162 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
163 if(ret)
164 ok(!strcmp(ret, "German_Austria.1252"), "ret = %s\n", ret);
165
166 ret = setlocale(LC_ALL, "des");
167 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
168 if(ret)
169 ok(!strcmp(ret, "German_Switzerland.1252"), "ret = %s\n", ret);
170
171 ret = setlocale(LC_ALL, "deu");
172 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
173 if(ret)
174 ok(!strcmp(ret, "German_Germany.1252"), "ret = %s\n", ret);
175
176 ret = setlocale(LC_ALL, "dutch");
177 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
178 if(ret)
179 ok(!strcmp(ret, "Dutch_Netherlands.1252"), "ret = %s\n", ret);
180
181 ret = setlocale(LC_ALL, "dutch-belgian");
182 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
183 if(ret)
184 ok(!strcmp(ret, "Dutch_Belgium.1252")
185 || broken(!strcmp(ret, "Dutch_Netherlands.1252")), "ret = %s\n", ret);
186
187 ret = setlocale(LC_ALL, "ena");
188 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
189 if(ret)
190 ok(!strcmp(ret, "English_Australia.1252")
191 || broken(!strcmp(ret, "English_United States.1252")), "ret = %s\n", ret);
192
193 ret = setlocale(LC_ALL, "ell");
194 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
195 if(ret)
196 ok(!strcmp(ret, "Greek_Greece.1253"), "ret = %s\n", ret);
197
198 ret = setlocale(LC_ALL, "enc");
199 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
200 if(ret)
201 ok(!strcmp(ret, "English_Canada.1252")
202 || broken(!strcmp(ret, "English_United States.1252")), "ret = %s\n", ret);
203
204 ret = setlocale(LC_ALL, "eng");
205 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
206 if(ret)
207 ok(!strcmp(ret, "English_United Kingdom.1252")
208 || broken(!strcmp(ret, "English_United States.1252")), "ret = %s\n", ret);
209
210 ret = setlocale(LC_ALL, "enu");
211 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
212 if(ret)
213 ok(!strcmp(ret, "English_United States.1252"), "ret = %s\n", ret);
214
215 ret = setlocale(LC_ALL, "enz");
216 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
217 if(ret)
218 ok(!strcmp(ret, "English_New Zealand.1252")
219 || broken(!strcmp(ret, "English_United States.1252")), "ret = %s\n", ret);
220
221 ret = setlocale(LC_ALL, "english");
222 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
223 if(ret)
224 ok(!strcmp(ret, "English_United States.1252"), "ret = %s\n", ret);
225
226 ret = setlocale(LC_ALL, "english-american");
227 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
228 if(ret)
229 ok(!strcmp(ret, "English_United States.1252"), "ret = %s\n", ret);
230
231 ret = setlocale(LC_ALL, "english-aus");
232 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
233 if(ret)
234 ok(!strcmp(ret, "English_Australia.1252")
235 || broken(!strcmp(ret, "English_United States.1252")), "ret = %s\n", ret);
236
237 ret = setlocale(LC_ALL, "english-can");
238 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
239 if(ret)
240 ok(!strcmp(ret, "English_Canada.1252")
241 || broken(!strcmp(ret, "English_United States.1252")), "ret = %s\n", ret);
242
243 ret = setlocale(LC_ALL, "english-nz");
244 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
245 if(ret)
246 ok(!strcmp(ret, "English_New Zealand.1252")
247 || broken(!strcmp(ret, "English_United States.1252")), "ret = %s\n", ret);
248
249 ret = setlocale(LC_ALL, "english-uk");
250 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
251 if(ret)
252 ok(!strcmp(ret, "English_United Kingdom.1252")
253 || broken(!strcmp(ret, "English_United States.1252")), "ret = %s\n", ret);
254
255 ret = setlocale(LC_ALL, "english-us");
256 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
257 if(ret)
258 ok(!strcmp(ret, "English_United States.1252"), "ret = %s\n", ret);
259
260 ret = setlocale(LC_ALL, "english-usa");
261 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
262 if(ret)
263 ok(!strcmp(ret, "English_United States.1252"), "ret = %s\n", ret);
264
265 ret = setlocale(LC_ALL, "esm");
266 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
267 if(ret)
268 ok(!strcmp(ret, "Spanish_Mexico.1252"), "ret = %s\n", ret);
269
270 ret = setlocale(LC_ALL, "esn");
271 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
272 if(ret)
273 ok(!strcmp(ret, "Spanish_Spain.1252")
274 || broken(!strcmp(ret, "Spanish - Modern Sort_Spain.1252")), "ret = %s\n", ret);
275
276 ret = setlocale(LC_ALL, "esp");
277 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
278 if(ret)
279 ok(!strcmp(ret, "Spanish_Spain.1252")
280 || broken(!strcmp(ret, "Spanish - Traditional Sort_Spain.1252")), "ret = %s\n", ret);
281
282 ret = setlocale(LC_ALL, "fin");
283 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
284 if(ret)
285 ok(!strcmp(ret, "Finnish_Finland.1252"), "ret = %s\n", ret);
286
287 ret = setlocale(LC_ALL, "finnish");
288 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
289 if(ret)
290 ok(!strcmp(ret, "Finnish_Finland.1252"), "ret = %s\n", ret);
291
292 ret = setlocale(LC_ALL, "fra");
293 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
294 if(ret)
295 ok(!strcmp(ret, "French_France.1252"), "ret = %s\n", ret);
296
297 ret = setlocale(LC_ALL, "frb");
298 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
299 if(ret)
300 ok(!strcmp(ret, "French_Belgium.1252")
301 || broken(!strcmp(ret, "French_France.1252")), "ret = %s\n", ret);
302
303 ret = setlocale(LC_ALL, "frc");
304 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
305 if(ret)
306 ok(!strcmp(ret, "French_Canada.1252")
307 || broken(!strcmp(ret, "French_France.1252")), "ret = %s\n", ret);
308
309 ret = setlocale(LC_ALL, "french");
310 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
311 if(ret)
312 ok(!strcmp(ret, "French_France.1252"), "ret = %s\n", ret);
313
314 ret = setlocale(LC_ALL, "french-belgian");
315 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
316 if(ret)
317 ok(!strcmp(ret, "French_Belgium.1252")
318 || broken(!strcmp(ret, "French_France.1252")), "ret = %s\n", ret);
319
320 ret = setlocale(LC_ALL, "french-canadian");
321 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
322 if(ret)
323 ok(!strcmp(ret, "French_Canada.1252")
324 || broken(!strcmp(ret, "French_France.1252")), "ret = %s\n", ret);
325
326 ret = setlocale(LC_ALL, "french-swiss");
327 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
328 if(ret)
329 ok(!strcmp(ret, "French_Switzerland.1252")
330 || broken(!strcmp(ret, "French_France.1252")), "ret = %s\n", ret);
331
332 ret = setlocale(LC_ALL, "frs");
333 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
334 if(ret)
335 ok(!strcmp(ret, "French_Switzerland.1252")
336 || broken(!strcmp(ret, "French_France.1252")), "ret = %s\n", ret);
337
338 ret = setlocale(LC_ALL, "german");
339 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
340 if(ret)
341 ok(!strcmp(ret, "German_Germany.1252"), "ret = %s\n", ret);
342
343 ret = setlocale(LC_ALL, "german-austrian");
344 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
345 if(ret)
346 ok(!strcmp(ret, "German_Austria.1252")
347 || broken(!strcmp(ret, "German_Germany.1252")), "ret = %s\n", ret);
348
349 ret = setlocale(LC_ALL, "german-swiss");
350 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
351 if(ret)
352 ok(!strcmp(ret, "German_Switzerland.1252")
353 || broken(!strcmp(ret, "German_Germany.1252")), "ret = %s\n", ret);
354
355 ret = setlocale(LC_ALL, "greek");
356 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
357 if(ret)
358 ok(!strcmp(ret, "Greek_Greece.1253"), "ret = %s\n", ret);
359
360 ret = setlocale(LC_ALL, "hun");
361 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
362 if(ret)
363 ok(!strcmp(ret, "Hungarian_Hungary.1250"), "ret = %s\n", ret);
364
365 ret = setlocale(LC_ALL, "hungarian");
366 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
367 if(ret)
368 ok(!strcmp(ret, "Hungarian_Hungary.1250"), "ret = %s\n", ret);
369
370 ret = setlocale(LC_ALL, "icelandic");
371 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
372 if(ret)
373 ok(!strcmp(ret, "Icelandic_Iceland.1252"), "ret = %s\n", ret);
374
375 ret = setlocale(LC_ALL, "isl");
376 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
377 if(ret)
378 ok(!strcmp(ret, "Icelandic_Iceland.1252"), "ret = %s\n", ret);
379
380 ret = setlocale(LC_ALL, "ita");
381 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
382 if(ret)
383 ok(!strcmp(ret, "Italian_Italy.1252"), "ret = %s\n", ret);
384
385 ret = setlocale(LC_ALL, "italian");
386 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
387 if(ret)
388 ok(!strcmp(ret, "Italian_Italy.1252"), "ret = %s\n", ret);
389
390 ret = setlocale(LC_ALL, "italian-swiss");
391 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
392 if(ret)
393 ok(!strcmp(ret, "Italian_Switzerland.1252")
394 || broken(!strcmp(ret, "Italian_Italy.1252")), "ret = %s\n", ret);
395
396 ret = setlocale(LC_ALL, "its");
397 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
398 if(ret)
399 ok(!strcmp(ret, "Italian_Switzerland.1252")
400 || broken(!strcmp(ret, "Italian_Italy.1252")), "ret = %s\n", ret);
401
402 ret = setlocale(LC_ALL, "japanese");
403 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
404 if(ret)
405 ok(!strcmp(ret, "Japanese_Japan.932"), "ret = %s\n", ret);
406
407 ret = setlocale(LC_ALL, "jpn");
408 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
409 if(ret)
410 ok(!strcmp(ret, "Japanese_Japan.932"), "ret = %s\n", ret);
411
412 ret = setlocale(LC_ALL, "korean");
413 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
414 if(ret)
415 ok(!strcmp(ret, "Korean_Korea.949"), "ret = %s\n", ret);
416
417 ret = setlocale(LC_ALL, "korean");
418 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
419 if(ret)
420 ok(!strcmp(ret, "Korean_Korea.949"), "ret = %s\n", ret);
421
422 ret = setlocale(LC_ALL, "nlb");
423 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
424 if(ret)
425 ok(!strcmp(ret, "Dutch_Belgium.1252")
426 || broken(!strcmp(ret, "Dutch_Netherlands.1252")), "ret = %s\n", ret);
427
428 ret = setlocale(LC_ALL, "nld");
429 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
430 if(ret)
431 ok(!strcmp(ret, "Dutch_Netherlands.1252"), "ret = %s\n", ret);
432
433 ret = setlocale(LC_ALL, "non");
434 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
435 if(ret)
436 ok(!strcmp( ret, "Norwegian-Nynorsk_Norway.1252")
437 || !strcmp(ret, "Norwegian (Nynorsk)_Norway.1252")
438 || broken(!strcmp(ret, "Norwegian (Bokm\xe5l)_Norway.1252"))
439 || broken(!strcmp(ret, "Norwegian_Norway.1252")), "ret = %s\n", ret);
440
441 ret = setlocale(LC_ALL, "nor");
442 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
443 if(ret)
444 ok(!strcmp(ret, "Norwegian (Bokm\xe5l)_Norway.1252")
445 || !strcmp(ret, "Norwegian (Bokmal)_Norway.1252")
446 || broken(!strcmp(ret, "Norwegian_Norway.1252")), "ret = %s\n", ret);
447
448 ret = setlocale(LC_ALL, "norwegian-bokmal");
449 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
450 if(ret)
451 ok(!strcmp(ret, "Norwegian (Bokm\xe5l)_Norway.1252")
452 || !strcmp(ret, "Norwegian (Bokmal)_Norway.1252")
453 || broken(!strcmp(ret, "Norwegian_Norway.1252")), "ret = %s\n", ret);
454
455 ret = setlocale(LC_ALL, "norwegian-nynorsk");
456 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
457 if(ret)
458 ok(!strcmp(ret, "Norwegian-Nynorsk_Norway.1252")
459 || !strcmp(ret, "Norwegian (Nynorsk)_Norway.1252")
460 || broken(!strcmp(ret, "Norwegian_Norway.1252"))
461 || broken(!strcmp(ret, "Norwegian (Bokmal)_Norway.1252"))
462 || broken(!strcmp(ret, "Norwegian (Bokm\xe5l)_Norway.1252")), "ret = %s\n", ret);
463
464 ret = setlocale(LC_ALL, "plk");
465 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
466 if(ret)
467 ok(!strcmp(ret, "Polish_Poland.1250"), "ret = %s\n", ret);
468
469 ret = setlocale(LC_ALL, "polish");
470 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
471 if(ret)
472 ok(!strcmp(ret, "Polish_Poland.1250"), "ret = %s\n", ret);
473
474 ret = setlocale(LC_ALL, "portugese");
475 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
476 if(ret)
477 ok(!strcmp(ret, "Portuguese_Brazil.1252"), "ret = %s\n", ret);
478
479 ret = setlocale(LC_ALL, "portuguese-brazil");
480 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
481 if(ret)
482 ok(!strcmp(ret, "Portuguese_Brazil.1252"), "ret = %s\n", ret);
483
484 ret = setlocale(LC_ALL, "ptb");
485 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
486 if(ret)
487 ok(!strcmp(ret, "Portuguese_Brazil.1252"), "ret = %s\n", ret);
488
489 ret = setlocale(LC_ALL, "ptg");
490 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
491 if(ret)
492 ok(!strcmp(ret, "Portuguese_Portugal.1252"), "ret = %s\n", ret);
493
494 ret = setlocale(LC_ALL, "rus");
495 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
496 if(ret)
497 ok(!strcmp(ret, "Russian_Russia.1251"), "ret = %s\n", ret);
498
499 ret = setlocale(LC_ALL, "russian");
500 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
501 if(ret)
502 ok(!strcmp(ret, "Russian_Russia.1251"), "ret = %s\n", ret);
503
504 ret = setlocale(LC_ALL, "sky");
505 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
506 if(ret)
507 ok(!strcmp(ret, "Slovak_Slovakia.1250"), "ret = %s\n", ret);
508
509 ret = setlocale(LC_ALL, "slovak");
510 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
511 if(ret)
512 ok(!strcmp(ret, "Slovak_Slovakia.1250"), "ret = %s\n", ret);
513
514 ret = setlocale(LC_ALL, "spanish");
515 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
516 if(ret)
517 ok(!strcmp(ret, "Spanish_Spain.1252")
518 || broken(!strcmp(ret, "Spanish - Traditional Sort_Spain.1252")), "ret = %s\n", ret);
519
520 ret = setlocale(LC_ALL, "spanish-mexican");
521 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
522 if(ret)
523 ok(!strcmp(ret, "Spanish_Mexico.1252")
524 || broken(!strcmp(ret, "Spanish_Spain.1252")), "ret = %s\n", ret);
525
526 ret = setlocale(LC_ALL, "spanish-modern");
527 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
528 if(ret)
529 ok(!strcmp(ret, "Spanish - Modern Sort_Spain.1252")
530 || !strcmp(ret, "Spanish_Spain.1252"), "ret = %s\n", ret);
531
532 ret = setlocale(LC_ALL, "sve");
533 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
534 if(ret)
535 ok(!strcmp(ret, "Swedish_Sweden.1252"), "ret = %s\n", ret);
536
537 ret = setlocale(LC_ALL, "swedish");
538 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
539 if(ret)
540 ok(!strcmp(ret, "Swedish_Sweden.1252"), "ret = %s\n", ret);
541
542 ret = setlocale(LC_ALL, "swiss");
543 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
544 if(ret)
545 ok(!strcmp(ret, "German_Switzerland.1252"), "ret = %s\n", ret);
546
547 ret = setlocale(LC_ALL, "trk");
548 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
549 if(ret)
550 ok(!strcmp(ret, "Turkish_Turkey.1254"), "ret = %s\n", ret);
551
552 ret = setlocale(LC_ALL, "turkish");
553 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
554 if(ret)
555 ok(!strcmp(ret, "Turkish_Turkey.1254"), "ret = %s\n", ret);
556
557 ret = setlocale(LC_ALL, "uk");
558 ok(ret != NULL, "ret == NULL\n");
559 if(ret)
560 ok(!strcmp(ret, "English_United Kingdom.1252")
561 || broken(!strcmp(ret, "Ukrainian_Ukraine.1251")), "ret = %s\n", ret);
562
563 ret = setlocale(LC_ALL, "us");
564 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
565 if(ret)
566 ok(!strcmp(ret, "English_United States.1252"), "ret = %s\n", ret);
567
568 ret = setlocale(LC_ALL, "usa");
569 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
570 if(ret)
571 ok(!strcmp(ret, "English_United States.1252"), "ret = %s\n", ret);
572 }
573
574 static void test_crtGetStringTypeW(void)
575 {
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' };
581
582 const wchar_t *str[] = { str0, strA, str_space, str_null, str_rand };
583
584 WORD out_crt, out;
585 BOOL ret_crt, ret;
586 int i;
587
588 if(!p__crtGetStringTypeW) {
589 win_skip("Skipping __crtGetStringTypeW tests\n");
590 return;
591 }
592
593 if(!pmemcpy_s) {
594 win_skip("Too old version of msvcrt.dll\n");
595 return;
596 }
597
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);
603
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);
608
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);
613 }
614
615 ret = p__crtGetStringTypeW(0, 3, str[0], 1, &out);
616 ok(!ret, "ret == TRUE\n");
617 }
618
619 START_TEST(locale)
620 {
621 init();
622
623 test_crtGetStringTypeW();
624 test_setlocale();
625 }