[MSVCRT_WINETEST]: Sync to Wine 1.5.13.
[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 void* __cdecl _Gettnames(void);
29
30 static void init(void)
31 {
32 HMODULE hmod = GetModuleHandleA("msvcrt.dll");
33
34 p__crtGetStringTypeW = (void*)GetProcAddress(hmod, "__crtGetStringTypeW");
35 pmemcpy_s = (void*)GetProcAddress(hmod, "memcpy_s");
36 }
37
38 static void test_setlocale(void)
39 {
40 static const char lc_all[] = "LC_COLLATE=C;LC_CTYPE=C;"
41 "LC_MONETARY=Greek_Greece.1253;LC_NUMERIC=Polish_Poland.1250;LC_TIME=C";
42
43 char *ret, buf[100];
44
45 ret = setlocale(20, "C");
46 ok(ret == NULL, "ret = %s\n", ret);
47
48 ret = setlocale(LC_ALL, "");
49 ok(ret != NULL, "ret == NULL\n");
50
51 ret = setlocale(LC_ALL, "C");
52 ok(!strcmp(ret, "C"), "ret = %s\n", ret);
53
54 ret = setlocale(LC_ALL, NULL);
55 ok(!strcmp(ret, "C"), "ret = %s\n", ret);
56
57 if(!setlocale(LC_NUMERIC, "Polish")
58 || !setlocale(LC_NUMERIC, "Greek")
59 || !setlocale(LC_NUMERIC, "German")
60 || !setlocale(LC_NUMERIC, "English")) {
61 win_skip("System with limited locales\n");
62 return;
63 }
64
65 ret = setlocale(LC_NUMERIC, "Polish");
66 ok(!strcmp(ret, "Polish_Poland.1250"), "ret = %s\n", ret);
67
68 ret = setlocale(LC_MONETARY, "Greek");
69 ok(!strcmp(ret, "Greek_Greece.1253"), "ret = %s\n", ret);
70
71 ret = setlocale(LC_ALL, NULL);
72 ok(!strcmp(ret, lc_all), "ret = %s\n", ret);
73
74 strcpy(buf, ret);
75 ret = setlocale(LC_ALL, buf);
76 ok(!strcmp(ret, lc_all), "ret = %s\n", ret);
77
78 ret = setlocale(LC_ALL, "German");
79 ok(!strcmp(ret, "German_Germany.1252"), "ret = %s\n", ret);
80
81 ret = setlocale(LC_ALL, "american");
82 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
83 if(ret)
84 ok(!strcmp(ret, "English_United States.1252"), "ret = %s\n", ret);
85
86 ret = setlocale(LC_ALL, "american english");
87 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
88 if(ret)
89 ok(!strcmp(ret, "English_United States.1252"), "ret = %s\n", ret);
90
91 ret = setlocale(LC_ALL, "american-english");
92 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
93 if(ret)
94 ok(!strcmp(ret, "English_United States.1252"), "ret = %s\n", ret);
95
96 ret = setlocale(LC_ALL, "australian");
97 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
98 if(ret)
99 ok(!strcmp(ret, "English_Australia.1252"), "ret = %s\n", ret);
100
101 ret = setlocale(LC_ALL, "belgian");
102 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
103 if(ret)
104 ok(!strcmp(ret, "Dutch_Belgium.1252"), "ret = %s\n", ret);
105
106 ret = setlocale(LC_ALL, "canadian");
107 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
108 if(ret)
109 ok(!strcmp(ret, "English_Canada.1252"), "ret = %s\n", ret);
110
111 ret = setlocale(LC_ALL, "chinese");
112 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
113 if(ret)
114 ok(!strcmp(ret, "Chinese (Simplified)_People's Republic of China.936")
115 || broken(!strcmp(ret, "Chinese_Taiwan.950")), "ret = %s\n", ret);
116
117 ret = setlocale(LC_ALL, "chinese-simplified");
118 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
119 if(ret)
120 ok(!strcmp(ret, "Chinese (Simplified)_People's Republic of China.936")
121 || broken(!strcmp(ret, "Chinese_People's Republic of China.936"))
122 || broken(!strcmp(ret, "Chinese_Taiwan.950")), "ret = %s\n", ret);
123
124 ret = setlocale(LC_ALL, "chinese-traditional");
125 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
126 if(ret)
127 ok(!strcmp(ret, "Chinese (Traditional)_Taiwan.950")
128 || broken(!strcmp(ret, "Chinese_Taiwan.950")), "ret = %s\n", ret);
129
130 ret = setlocale(LC_ALL, "chs");
131 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
132 if(ret)
133 ok(!strcmp(ret, "Chinese (Simplified)_People's Republic of China.936")
134 || broken(!strcmp(ret, "Chinese_People's Republic of China.936")), "ret = %s\n", ret);
135
136 ret = setlocale(LC_ALL, "cht");
137 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
138 if(ret)
139 ok(!strcmp(ret, "Chinese (Traditional)_Taiwan.950")
140 || broken(!strcmp(ret, "Chinese_Taiwan.950")), "ret = %s\n", ret);
141
142 ret = setlocale(LC_ALL, "csy");
143 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
144 if(ret)
145 ok(!strcmp(ret, "Czech_Czech Republic.1250"), "ret = %s\n", ret);
146
147 ret = setlocale(LC_ALL, "czech");
148 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
149 if(ret)
150 ok(!strcmp(ret, "Czech_Czech Republic.1250"), "ret = %s\n", ret);
151
152 ret = setlocale(LC_ALL, "dan");
153 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
154 if(ret)
155 ok(!strcmp(ret, "Danish_Denmark.1252"), "ret = %s\n", ret);
156
157 ret = setlocale(LC_ALL, "danish");
158 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
159 if(ret)
160 ok(!strcmp(ret, "Danish_Denmark.1252"), "ret = %s\n", ret);
161
162 ret = setlocale(LC_ALL, "dea");
163 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
164 if(ret)
165 ok(!strcmp(ret, "German_Austria.1252"), "ret = %s\n", ret);
166
167 ret = setlocale(LC_ALL, "des");
168 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
169 if(ret)
170 ok(!strcmp(ret, "German_Switzerland.1252"), "ret = %s\n", ret);
171
172 ret = setlocale(LC_ALL, "deu");
173 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
174 if(ret)
175 ok(!strcmp(ret, "German_Germany.1252"), "ret = %s\n", ret);
176
177 ret = setlocale(LC_ALL, "dutch");
178 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
179 if(ret)
180 ok(!strcmp(ret, "Dutch_Netherlands.1252"), "ret = %s\n", ret);
181
182 ret = setlocale(LC_ALL, "dutch-belgian");
183 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
184 if(ret)
185 ok(!strcmp(ret, "Dutch_Belgium.1252")
186 || broken(!strcmp(ret, "Dutch_Netherlands.1252")), "ret = %s\n", ret);
187
188 ret = setlocale(LC_ALL, "ena");
189 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
190 if(ret)
191 ok(!strcmp(ret, "English_Australia.1252")
192 || broken(!strcmp(ret, "English_United States.1252")), "ret = %s\n", ret);
193
194 ret = setlocale(LC_ALL, "ell");
195 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
196 if(ret)
197 ok(!strcmp(ret, "Greek_Greece.1253"), "ret = %s\n", ret);
198
199 ret = setlocale(LC_ALL, "enc");
200 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
201 if(ret)
202 ok(!strcmp(ret, "English_Canada.1252")
203 || broken(!strcmp(ret, "English_United States.1252")), "ret = %s\n", ret);
204
205 ret = setlocale(LC_ALL, "eng");
206 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
207 if(ret)
208 ok(!strcmp(ret, "English_United Kingdom.1252")
209 || broken(!strcmp(ret, "English_United States.1252")), "ret = %s\n", ret);
210
211 ret = setlocale(LC_ALL, "enu");
212 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
213 if(ret)
214 ok(!strcmp(ret, "English_United States.1252"), "ret = %s\n", ret);
215
216 ret = setlocale(LC_ALL, "enz");
217 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
218 if(ret)
219 ok(!strcmp(ret, "English_New Zealand.1252")
220 || broken(!strcmp(ret, "English_United States.1252")), "ret = %s\n", ret);
221
222 ret = setlocale(LC_ALL, "english");
223 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
224 if(ret)
225 ok(!strcmp(ret, "English_United States.1252"), "ret = %s\n", ret);
226
227 ret = setlocale(LC_ALL, "english-american");
228 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
229 if(ret)
230 ok(!strcmp(ret, "English_United States.1252"), "ret = %s\n", ret);
231
232 ret = setlocale(LC_ALL, "english-aus");
233 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
234 if(ret)
235 ok(!strcmp(ret, "English_Australia.1252")
236 || broken(!strcmp(ret, "English_United States.1252")), "ret = %s\n", ret);
237
238 ret = setlocale(LC_ALL, "english-can");
239 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
240 if(ret)
241 ok(!strcmp(ret, "English_Canada.1252")
242 || broken(!strcmp(ret, "English_United States.1252")), "ret = %s\n", ret);
243
244 ret = setlocale(LC_ALL, "english-nz");
245 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
246 if(ret)
247 ok(!strcmp(ret, "English_New Zealand.1252")
248 || broken(!strcmp(ret, "English_United States.1252")), "ret = %s\n", ret);
249
250 ret = setlocale(LC_ALL, "english-uk");
251 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
252 if(ret)
253 ok(!strcmp(ret, "English_United Kingdom.1252")
254 || broken(!strcmp(ret, "English_United States.1252")), "ret = %s\n", ret);
255
256 ret = setlocale(LC_ALL, "english-us");
257 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
258 if(ret)
259 ok(!strcmp(ret, "English_United States.1252"), "ret = %s\n", ret);
260
261 ret = setlocale(LC_ALL, "english-usa");
262 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
263 if(ret)
264 ok(!strcmp(ret, "English_United States.1252"), "ret = %s\n", ret);
265
266 ret = setlocale(LC_ALL, "esm");
267 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
268 if(ret)
269 ok(!strcmp(ret, "Spanish_Mexico.1252"), "ret = %s\n", ret);
270
271 ret = setlocale(LC_ALL, "esn");
272 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
273 if(ret)
274 ok(!strcmp(ret, "Spanish_Spain.1252")
275 || broken(!strcmp(ret, "Spanish - Modern Sort_Spain.1252")), "ret = %s\n", ret);
276
277 ret = setlocale(LC_ALL, "esp");
278 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
279 if(ret)
280 ok(!strcmp(ret, "Spanish_Spain.1252")
281 || broken(!strcmp(ret, "Spanish - Traditional Sort_Spain.1252")), "ret = %s\n", ret);
282
283 ret = setlocale(LC_ALL, "fin");
284 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
285 if(ret)
286 ok(!strcmp(ret, "Finnish_Finland.1252"), "ret = %s\n", ret);
287
288 ret = setlocale(LC_ALL, "finnish");
289 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
290 if(ret)
291 ok(!strcmp(ret, "Finnish_Finland.1252"), "ret = %s\n", ret);
292
293 ret = setlocale(LC_ALL, "fra");
294 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
295 if(ret)
296 ok(!strcmp(ret, "French_France.1252"), "ret = %s\n", ret);
297
298 ret = setlocale(LC_ALL, "frb");
299 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
300 if(ret)
301 ok(!strcmp(ret, "French_Belgium.1252")
302 || broken(!strcmp(ret, "French_France.1252")), "ret = %s\n", ret);
303
304 ret = setlocale(LC_ALL, "frc");
305 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
306 if(ret)
307 ok(!strcmp(ret, "French_Canada.1252")
308 || broken(!strcmp(ret, "French_France.1252")), "ret = %s\n", ret);
309
310 ret = setlocale(LC_ALL, "french");
311 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
312 if(ret)
313 ok(!strcmp(ret, "French_France.1252"), "ret = %s\n", ret);
314
315 ret = setlocale(LC_ALL, "french-belgian");
316 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
317 if(ret)
318 ok(!strcmp(ret, "French_Belgium.1252")
319 || broken(!strcmp(ret, "French_France.1252")), "ret = %s\n", ret);
320
321 ret = setlocale(LC_ALL, "french-canadian");
322 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
323 if(ret)
324 ok(!strcmp(ret, "French_Canada.1252")
325 || broken(!strcmp(ret, "French_France.1252")), "ret = %s\n", ret);
326
327 ret = setlocale(LC_ALL, "french-swiss");
328 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
329 if(ret)
330 ok(!strcmp(ret, "French_Switzerland.1252")
331 || broken(!strcmp(ret, "French_France.1252")), "ret = %s\n", ret);
332
333 ret = setlocale(LC_ALL, "frs");
334 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
335 if(ret)
336 ok(!strcmp(ret, "French_Switzerland.1252")
337 || broken(!strcmp(ret, "French_France.1252")), "ret = %s\n", ret);
338
339 ret = setlocale(LC_ALL, "german");
340 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
341 if(ret)
342 ok(!strcmp(ret, "German_Germany.1252"), "ret = %s\n", ret);
343
344 ret = setlocale(LC_ALL, "german-austrian");
345 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
346 if(ret)
347 ok(!strcmp(ret, "German_Austria.1252")
348 || broken(!strcmp(ret, "German_Germany.1252")), "ret = %s\n", ret);
349
350 ret = setlocale(LC_ALL, "german-swiss");
351 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
352 if(ret)
353 ok(!strcmp(ret, "German_Switzerland.1252")
354 || broken(!strcmp(ret, "German_Germany.1252")), "ret = %s\n", ret);
355
356 ret = setlocale(LC_ALL, "greek");
357 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
358 if(ret)
359 ok(!strcmp(ret, "Greek_Greece.1253"), "ret = %s\n", ret);
360
361 ret = setlocale(LC_ALL, "hun");
362 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
363 if(ret)
364 ok(!strcmp(ret, "Hungarian_Hungary.1250"), "ret = %s\n", ret);
365
366 ret = setlocale(LC_ALL, "hungarian");
367 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
368 if(ret)
369 ok(!strcmp(ret, "Hungarian_Hungary.1250"), "ret = %s\n", ret);
370
371 ret = setlocale(LC_ALL, "icelandic");
372 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
373 if(ret)
374 ok(!strcmp(ret, "Icelandic_Iceland.1252"), "ret = %s\n", ret);
375
376 ret = setlocale(LC_ALL, "isl");
377 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
378 if(ret)
379 ok(!strcmp(ret, "Icelandic_Iceland.1252"), "ret = %s\n", ret);
380
381 ret = setlocale(LC_ALL, "ita");
382 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
383 if(ret)
384 ok(!strcmp(ret, "Italian_Italy.1252"), "ret = %s\n", ret);
385
386 ret = setlocale(LC_ALL, "italian");
387 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
388 if(ret)
389 ok(!strcmp(ret, "Italian_Italy.1252"), "ret = %s\n", ret);
390
391 ret = setlocale(LC_ALL, "italian-swiss");
392 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
393 if(ret)
394 ok(!strcmp(ret, "Italian_Switzerland.1252")
395 || broken(!strcmp(ret, "Italian_Italy.1252")), "ret = %s\n", ret);
396
397 ret = setlocale(LC_ALL, "its");
398 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
399 if(ret)
400 ok(!strcmp(ret, "Italian_Switzerland.1252")
401 || broken(!strcmp(ret, "Italian_Italy.1252")), "ret = %s\n", ret);
402
403 ret = setlocale(LC_ALL, "japanese");
404 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
405 if(ret)
406 ok(!strcmp(ret, "Japanese_Japan.932"), "ret = %s\n", ret);
407
408 ret = setlocale(LC_ALL, "jpn");
409 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
410 if(ret)
411 ok(!strcmp(ret, "Japanese_Japan.932"), "ret = %s\n", ret);
412
413 ret = setlocale(LC_ALL, "korean");
414 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
415 if(ret)
416 ok(!strcmp(ret, "Korean_Korea.949"), "ret = %s\n", ret);
417
418 ret = setlocale(LC_ALL, "korean");
419 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
420 if(ret)
421 ok(!strcmp(ret, "Korean_Korea.949"), "ret = %s\n", ret);
422
423 ret = setlocale(LC_ALL, "nlb");
424 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
425 if(ret)
426 ok(!strcmp(ret, "Dutch_Belgium.1252")
427 || broken(!strcmp(ret, "Dutch_Netherlands.1252")), "ret = %s\n", ret);
428
429 ret = setlocale(LC_ALL, "nld");
430 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
431 if(ret)
432 ok(!strcmp(ret, "Dutch_Netherlands.1252"), "ret = %s\n", ret);
433
434 ret = setlocale(LC_ALL, "non");
435 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
436 if(ret)
437 ok(!strcmp( ret, "Norwegian-Nynorsk_Norway.1252")
438 || !strcmp(ret, "Norwegian (Nynorsk)_Norway.1252")
439 || broken(!strcmp(ret, "Norwegian (Bokm\xe5l)_Norway.1252"))
440 || broken(!strcmp(ret, "Norwegian_Norway.1252")), "ret = %s\n", ret);
441
442 ret = setlocale(LC_ALL, "nor");
443 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
444 if(ret)
445 ok(!strcmp(ret, "Norwegian (Bokm\xe5l)_Norway.1252")
446 || !strcmp(ret, "Norwegian (Bokmal)_Norway.1252")
447 || broken(!strcmp(ret, "Norwegian_Norway.1252")), "ret = %s\n", ret);
448
449 ret = setlocale(LC_ALL, "norwegian-bokmal");
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);
455
456 ret = setlocale(LC_ALL, "norwegian-nynorsk");
457 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
458 if(ret)
459 ok(!strcmp(ret, "Norwegian-Nynorsk_Norway.1252")
460 || !strcmp(ret, "Norwegian (Nynorsk)_Norway.1252")
461 || broken(!strcmp(ret, "Norwegian_Norway.1252"))
462 || broken(!strcmp(ret, "Norwegian (Bokmal)_Norway.1252"))
463 || broken(!strcmp(ret, "Norwegian (Bokm\xe5l)_Norway.1252")), "ret = %s\n", ret);
464
465 ret = setlocale(LC_ALL, "plk");
466 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
467 if(ret)
468 ok(!strcmp(ret, "Polish_Poland.1250"), "ret = %s\n", ret);
469
470 ret = setlocale(LC_ALL, "polish");
471 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
472 if(ret)
473 ok(!strcmp(ret, "Polish_Poland.1250"), "ret = %s\n", ret);
474
475 ret = setlocale(LC_ALL, "portuguese");
476 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
477 if(ret)
478 ok(!strcmp(ret, "Portuguese_Brazil.1252")
479 || broken(!strcmp(ret, "Portuguese_Portugal.1252")) /* NT4 */, "ret = %s\n", ret);
480
481 ret = setlocale(LC_ALL, "portuguese-brazil");
482 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
483 if(ret)
484 ok(!strcmp(ret, "Portuguese_Brazil.1252"), "ret = %s\n", ret);
485
486 ret = setlocale(LC_ALL, "ptb");
487 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
488 if(ret)
489 ok(!strcmp(ret, "Portuguese_Brazil.1252"), "ret = %s\n", ret);
490
491 ret = setlocale(LC_ALL, "ptg");
492 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
493 if(ret)
494 ok(!strcmp(ret, "Portuguese_Portugal.1252"), "ret = %s\n", ret);
495
496 ret = setlocale(LC_ALL, "rus");
497 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
498 if(ret)
499 ok(!strcmp(ret, "Russian_Russia.1251"), "ret = %s\n", ret);
500
501 ret = setlocale(LC_ALL, "russian");
502 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
503 if(ret)
504 ok(!strcmp(ret, "Russian_Russia.1251"), "ret = %s\n", ret);
505
506 ret = setlocale(LC_ALL, "sky");
507 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
508 if(ret)
509 ok(!strcmp(ret, "Slovak_Slovakia.1250"), "ret = %s\n", ret);
510
511 ret = setlocale(LC_ALL, "slovak");
512 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
513 if(ret)
514 ok(!strcmp(ret, "Slovak_Slovakia.1250"), "ret = %s\n", ret);
515
516 ret = setlocale(LC_ALL, "spanish");
517 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
518 if(ret)
519 ok(!strcmp(ret, "Spanish_Spain.1252")
520 || broken(!strcmp(ret, "Spanish - Traditional Sort_Spain.1252")), "ret = %s\n", ret);
521
522 ret = setlocale(LC_ALL, "spanish-mexican");
523 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
524 if(ret)
525 ok(!strcmp(ret, "Spanish_Mexico.1252")
526 || broken(!strcmp(ret, "Spanish_Spain.1252")), "ret = %s\n", ret);
527
528 ret = setlocale(LC_ALL, "spanish-modern");
529 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
530 if(ret)
531 ok(!strcmp(ret, "Spanish - Modern Sort_Spain.1252")
532 || !strcmp(ret, "Spanish_Spain.1252"), "ret = %s\n", ret);
533
534 ret = setlocale(LC_ALL, "sve");
535 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
536 if(ret)
537 ok(!strcmp(ret, "Swedish_Sweden.1252"), "ret = %s\n", ret);
538
539 ret = setlocale(LC_ALL, "swedish");
540 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
541 if(ret)
542 ok(!strcmp(ret, "Swedish_Sweden.1252"), "ret = %s\n", ret);
543
544 ret = setlocale(LC_ALL, "swiss");
545 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
546 if(ret)
547 ok(!strcmp(ret, "German_Switzerland.1252"), "ret = %s\n", ret);
548
549 ret = setlocale(LC_ALL, "trk");
550 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
551 if(ret)
552 ok(!strcmp(ret, "Turkish_Turkey.1254"), "ret = %s\n", ret);
553
554 ret = setlocale(LC_ALL, "turkish");
555 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
556 if(ret)
557 ok(!strcmp(ret, "Turkish_Turkey.1254"), "ret = %s\n", ret);
558
559 ret = setlocale(LC_ALL, "uk");
560 ok(ret != NULL, "ret == NULL\n");
561 if(ret)
562 ok(!strcmp(ret, "English_United Kingdom.1252")
563 || broken(!strcmp(ret, "Ukrainian_Ukraine.1251")), "ret = %s\n", ret);
564
565 ret = setlocale(LC_ALL, "us");
566 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
567 if(ret)
568 ok(!strcmp(ret, "English_United States.1252"), "ret = %s\n", ret);
569
570 ret = setlocale(LC_ALL, "usa");
571 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
572 if(ret)
573 ok(!strcmp(ret, "English_United States.1252"), "ret = %s\n", ret);
574 }
575
576 static void test_crtGetStringTypeW(void)
577 {
578 static const wchar_t str0[] = { '0', '\0' };
579 static const wchar_t strA[] = { 'A', '\0' };
580 static const wchar_t str_space[] = { ' ', '\0' };
581 static const wchar_t str_null[] = { '\0', '\0' };
582 static const wchar_t str_rand[] = { 1234, '\0' };
583
584 const wchar_t *str[] = { str0, strA, str_space, str_null, str_rand };
585
586 WORD out_crt, out;
587 BOOL ret_crt, ret;
588 int i;
589
590 if(!p__crtGetStringTypeW) {
591 win_skip("Skipping __crtGetStringTypeW tests\n");
592 return;
593 }
594
595 if(!pmemcpy_s) {
596 win_skip("Too old version of msvcrt.dll\n");
597 return;
598 }
599
600 for(i=0; i<sizeof(str)/sizeof(*str); i++) {
601 ret_crt = p__crtGetStringTypeW(0, CT_CTYPE1, str[i], 1, &out_crt);
602 ret = GetStringTypeW(CT_CTYPE1, str[i], 1, &out);
603 ok(ret == ret_crt, "%d) ret_crt = %d\n", i, (int)ret_crt);
604 ok(out == out_crt, "%d) out_crt = %x, expected %x\n", i, (int)out_crt, (int)out);
605
606 ret_crt = p__crtGetStringTypeW(0, CT_CTYPE2, str[i], 1, &out_crt);
607 ret = GetStringTypeW(CT_CTYPE2, str[i], 1, &out);
608 ok(ret == ret_crt, "%d) ret_crt = %d\n", i, (int)ret_crt);
609 ok(out == out_crt, "%d) out_crt = %x, expected %x\n", i, (int)out_crt, (int)out);
610
611 ret_crt = p__crtGetStringTypeW(0, CT_CTYPE3, str[i], 1, &out_crt);
612 ret = GetStringTypeW(CT_CTYPE3, str[i], 1, &out);
613 ok(ret == ret_crt, "%d) ret_crt = %d\n", i, (int)ret_crt);
614 ok(out == out_crt, "%d) out_crt = %x, expected %x\n", i, (int)out_crt, (int)out);
615 }
616
617 ret = p__crtGetStringTypeW(0, 3, str[0], 1, &out);
618 ok(!ret, "ret == TRUE\n");
619 }
620
621 static void test__Gettnames(void)
622 {
623 struct {
624 char *str[43];
625 LCID lcid;
626 int unk[2];
627 wchar_t *wstr[43];
628 char data[1];
629 } *ret;
630 int size;
631
632 if(!setlocale(LC_ALL, "english"))
633 return;
634
635 ret = _Gettnames();
636 size = ret->data-(char*)ret;
637 /* Newer version of the structure stores both ascii and unicode strings.
638 * Unicode strings are only initialized on Windows 7
639 */
640 if(sizeof(void*) == 8)
641 ok(size==0x2c0 || broken(size==0x170), "strucure size: %x\n", size);
642 else
643 ok(size==0x164 || broken(size==0xb8), "strucure size: %x\n", size);
644
645 ok(!strcmp(ret->str[0], "Sun"), "ret->str[0] = %s\n", ret->str[0]);
646 ok(!strcmp(ret->str[1], "Mon"), "ret->str[1] = %s\n", ret->str[1]);
647 ok(!strcmp(ret->str[2], "Tue"), "ret->str[2] = %s\n", ret->str[2]);
648 ok(!strcmp(ret->str[3], "Wed"), "ret->str[3] = %s\n", ret->str[3]);
649 ok(!strcmp(ret->str[4], "Thu"), "ret->str[4] = %s\n", ret->str[4]);
650 ok(!strcmp(ret->str[5], "Fri"), "ret->str[5] = %s\n", ret->str[5]);
651 ok(!strcmp(ret->str[6], "Sat"), "ret->str[6] = %s\n", ret->str[6]);
652 ok(!strcmp(ret->str[7], "Sunday"), "ret->str[7] = %s\n", ret->str[7]);
653 ok(!strcmp(ret->str[8], "Monday"), "ret->str[8] = %s\n", ret->str[8]);
654 ok(!strcmp(ret->str[9], "Tuesday"), "ret->str[9] = %s\n", ret->str[9]);
655 ok(!strcmp(ret->str[10], "Wednesday"), "ret->str[10] = %s\n", ret->str[10]);
656 ok(!strcmp(ret->str[11], "Thursday"), "ret->str[11] = %s\n", ret->str[11]);
657 ok(!strcmp(ret->str[12], "Friday"), "ret->str[12] = %s\n", ret->str[12]);
658 ok(!strcmp(ret->str[13], "Saturday"), "ret->str[13] = %s\n", ret->str[13]);
659 ok(!strcmp(ret->str[14], "Jan"), "ret->str[14] = %s\n", ret->str[14]);
660 ok(!strcmp(ret->str[15], "Feb"), "ret->str[15] = %s\n", ret->str[15]);
661 ok(!strcmp(ret->str[16], "Mar"), "ret->str[16] = %s\n", ret->str[16]);
662 ok(!strcmp(ret->str[17], "Apr"), "ret->str[17] = %s\n", ret->str[17]);
663 ok(!strcmp(ret->str[18], "May"), "ret->str[18] = %s\n", ret->str[18]);
664 ok(!strcmp(ret->str[19], "Jun"), "ret->str[19] = %s\n", ret->str[19]);
665 ok(!strcmp(ret->str[20], "Jul"), "ret->str[20] = %s\n", ret->str[20]);
666 ok(!strcmp(ret->str[21], "Aug"), "ret->str[21] = %s\n", ret->str[21]);
667 ok(!strcmp(ret->str[22], "Sep"), "ret->str[22] = %s\n", ret->str[22]);
668 ok(!strcmp(ret->str[23], "Oct"), "ret->str[23] = %s\n", ret->str[23]);
669 ok(!strcmp(ret->str[24], "Nov"), "ret->str[24] = %s\n", ret->str[24]);
670 ok(!strcmp(ret->str[25], "Dec"), "ret->str[25] = %s\n", ret->str[25]);
671 ok(!strcmp(ret->str[26], "January"), "ret->str[26] = %s\n", ret->str[26]);
672 ok(!strcmp(ret->str[27], "February"), "ret->str[27] = %s\n", ret->str[27]);
673 ok(!strcmp(ret->str[28], "March"), "ret->str[28] = %s\n", ret->str[28]);
674 ok(!strcmp(ret->str[29], "April"), "ret->str[29] = %s\n", ret->str[29]);
675 ok(!strcmp(ret->str[30], "May"), "ret->str[30] = %s\n", ret->str[30]);
676 ok(!strcmp(ret->str[31], "June"), "ret->str[31] = %s\n", ret->str[31]);
677 ok(!strcmp(ret->str[32], "July"), "ret->str[32] = %s\n", ret->str[32]);
678 ok(!strcmp(ret->str[33], "August"), "ret->str[33] = %s\n", ret->str[33]);
679 ok(!strcmp(ret->str[34], "September"), "ret->str[34] = %s\n", ret->str[34]);
680 ok(!strcmp(ret->str[35], "October"), "ret->str[35] = %s\n", ret->str[35]);
681 ok(!strcmp(ret->str[36], "November"), "ret->str[36] = %s\n", ret->str[36]);
682 ok(!strcmp(ret->str[37], "December"), "ret->str[37] = %s\n", ret->str[37]);
683 ok(!strcmp(ret->str[38], "AM"), "ret->str[38] = %s\n", ret->str[38]);
684 ok(!strcmp(ret->str[39], "PM"), "ret->str[39] = %s\n", ret->str[39]);
685 ok(!strcmp(ret->str[40], "M/d/yyyy") || broken(!strcmp(ret->str[40], "M/d/yy"))/*NT*/,
686 "ret->str[40] = %s\n", ret->str[40]);
687 ok(!strcmp(ret->str[41], "dddd, MMMM dd, yyyy"), "ret->str[41] = %s\n", ret->str[41]);
688 free(ret);
689
690 if(!setlocale(LC_TIME, "german"))
691 return;
692
693 ret = _Gettnames();
694 ok(!strcmp(ret->str[0], "So"), "ret->str[0] = %s\n", ret->str[0]);
695 ok(!strcmp(ret->str[1], "Mo"), "ret->str[1] = %s\n", ret->str[1]);
696 ok(!strcmp(ret->str[2], "Di"), "ret->str[2] = %s\n", ret->str[2]);
697 ok(!strcmp(ret->str[3], "Mi"), "ret->str[3] = %s\n", ret->str[3]);
698 ok(!strcmp(ret->str[4], "Do"), "ret->str[4] = %s\n", ret->str[4]);
699 ok(!strcmp(ret->str[5], "Fr"), "ret->str[5] = %s\n", ret->str[5]);
700 ok(!strcmp(ret->str[6], "Sa"), "ret->str[6] = %s\n", ret->str[6]);
701 ok(!strcmp(ret->str[7], "Sonntag"), "ret->str[7] = %s\n", ret->str[7]);
702 ok(!strcmp(ret->str[8], "Montag"), "ret->str[8] = %s\n", ret->str[8]);
703 ok(!strcmp(ret->str[9], "Dienstag"), "ret->str[9] = %s\n", ret->str[9]);
704 ok(!strcmp(ret->str[10], "Mittwoch"), "ret->str[10] = %s\n", ret->str[10]);
705 ok(!strcmp(ret->str[11], "Donnerstag"), "ret->str[11] = %s\n", ret->str[11]);
706 ok(!strcmp(ret->str[12], "Freitag"), "ret->str[12] = %s\n", ret->str[12]);
707 ok(!strcmp(ret->str[13], "Samstag"), "ret->str[13] = %s\n", ret->str[13]);
708 ok(!strcmp(ret->str[14], "Jan"), "ret->str[14] = %s\n", ret->str[14]);
709 ok(!strcmp(ret->str[15], "Feb"), "ret->str[15] = %s\n", ret->str[15]);
710 ok(!strcmp(ret->str[16], "Mrz"), "ret->str[16] = %s\n", ret->str[16]);
711 ok(!strcmp(ret->str[17], "Apr"), "ret->str[17] = %s\n", ret->str[17]);
712 ok(!strcmp(ret->str[18], "Mai"), "ret->str[18] = %s\n", ret->str[18]);
713 ok(!strcmp(ret->str[19], "Jun"), "ret->str[19] = %s\n", ret->str[19]);
714 ok(!strcmp(ret->str[20], "Jul"), "ret->str[20] = %s\n", ret->str[20]);
715 ok(!strcmp(ret->str[21], "Aug"), "ret->str[21] = %s\n", ret->str[21]);
716 ok(!strcmp(ret->str[22], "Sep"), "ret->str[22] = %s\n", ret->str[22]);
717 ok(!strcmp(ret->str[23], "Okt"), "ret->str[23] = %s\n", ret->str[23]);
718 ok(!strcmp(ret->str[24], "Nov"), "ret->str[24] = %s\n", ret->str[24]);
719 ok(!strcmp(ret->str[25], "Dez"), "ret->str[25] = %s\n", ret->str[25]);
720 ok(!strcmp(ret->str[26], "Januar"), "ret->str[26] = %s\n", ret->str[26]);
721 ok(!strcmp(ret->str[27], "Februar"), "ret->str[27] = %s\n", ret->str[27]);
722 ok(!strcmp(ret->str[29], "April"), "ret->str[29] = %s\n", ret->str[29]);
723 ok(!strcmp(ret->str[30], "Mai"), "ret->str[30] = %s\n", ret->str[30]);
724 ok(!strcmp(ret->str[31], "Juni"), "ret->str[31] = %s\n", ret->str[31]);
725 ok(!strcmp(ret->str[32], "Juli"), "ret->str[32] = %s\n", ret->str[32]);
726 ok(!strcmp(ret->str[33], "August"), "ret->str[33] = %s\n", ret->str[33]);
727 ok(!strcmp(ret->str[34], "September"), "ret->str[34] = %s\n", ret->str[34]);
728 ok(!strcmp(ret->str[35], "Oktober"), "ret->str[35] = %s\n", ret->str[35]);
729 ok(!strcmp(ret->str[36], "November"), "ret->str[36] = %s\n", ret->str[36]);
730 ok(!strcmp(ret->str[37], "Dezember"), "ret->str[37] = %s\n", ret->str[37]);
731 ok(!strcmp(ret->str[38], ""), "ret->str[38] = %s\n", ret->str[38]);
732 ok(!strcmp(ret->str[39], ""), "ret->str[39] = %s\n", ret->str[39]);
733 ok(!strcmp(ret->str[40], "dd.MM.yyyy") || broken(!strcmp(ret->str[40], "dd.MM.yy"))/*NT*/,
734 "ret->str[40] = %s\n", ret->str[40]);
735 ok(!strcmp(ret->str[41], "dddd, d. MMMM yyyy"), "ret->str[41] = %s\n", ret->str[41]);
736 free(ret);
737
738 setlocale(LC_ALL, "C");
739 }
740
741 START_TEST(locale)
742 {
743 init();
744
745 test_crtGetStringTypeW();
746 test_setlocale();
747 test__Gettnames();
748 }