ReactOS 0.4.16-dev-336-gb667d82
locale.c
Go to the documentation of this file.
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
26static BOOL (__cdecl *p__crtGetStringTypeW)(DWORD, DWORD, const wchar_t*, int, WORD*);
27static int (__cdecl *pmemcpy_s)(void *, size_t, void*, size_t);
28static int (__cdecl *p___mb_cur_max_func)(void);
29static int *(__cdecl *p__p___mb_cur_max)(void);
30void* __cdecl _Gettnames(void);
31
32static void init(void)
33{
34 HMODULE hmod = GetModuleHandleA("msvcrt.dll");
35
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");
40}
41
42static void test_setlocale(void)
43{
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";
46
47 char *ret, buf[100];
48
49 ret = setlocale(20, "C");
50 ok(ret == NULL, "ret = %s\n", ret);
51
52 ret = setlocale(LC_ALL, "C");
53 ok(!strcmp(ret, "C"), "ret = %s\n", ret);
54
56 ok(!strcmp(ret, "C"), "ret = %s\n", ret);
57
58 if(!setlocale(LC_NUMERIC, "Polish")
59 || !setlocale(LC_NUMERIC, "Greek")
60 || !setlocale(LC_NUMERIC, "German")
61 || !setlocale(LC_NUMERIC, "English")) {
62 win_skip("System with limited locales\n");
63 return;
64 }
65
66 ret = setlocale(LC_NUMERIC, "Polish");
67 ok(!strcmp(ret, "Polish_Poland.1250"), "ret = %s\n", ret);
68
69 ret = setlocale(LC_MONETARY, "Greek");
70 ok(!strcmp(ret, "Greek_Greece.1253"), "ret = %s\n", ret);
71
73 ok(!strcmp(ret, lc_all), "ret = %s\n", ret);
74
75 strcpy(buf, ret);
77 ok(!strcmp(ret, lc_all), "ret = %s\n", ret);
78
79 ret = setlocale(LC_ALL, "German");
80 ok(!strcmp(ret, "German_Germany.1252"), "ret = %s\n", ret);
81
82 ret = setlocale(LC_ALL, "american");
83 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
84 if(ret)
85 ok(!strcmp(ret, "English_United States.1252"), "ret = %s\n", ret);
86
87 ret = setlocale(LC_ALL, "american english");
88 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
89 if(ret)
90 ok(!strcmp(ret, "English_United States.1252"), "ret = %s\n", ret);
91
92 ret = setlocale(LC_ALL, "american-english");
93 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
94 if(ret)
95 ok(!strcmp(ret, "English_United States.1252"), "ret = %s\n", ret);
96
97 ret = setlocale(LC_ALL, "australian");
98 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
99 if(ret)
100 ok(!strcmp(ret, "English_Australia.1252"), "ret = %s\n", ret);
101
102 ret = setlocale(LC_ALL, "belgian");
103 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
104 if(ret)
105 ok(!strcmp(ret, "Dutch_Belgium.1252"), "ret = %s\n", ret);
106
107 ret = setlocale(LC_ALL, "canadian");
108 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
109 if(ret)
110 ok(!strcmp(ret, "English_Canada.1252"), "ret = %s\n", ret);
111
112 ret = setlocale(LC_ALL, "chinese");
113 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
114 if(ret)
115 ok(!strcmp(ret, "Chinese (Simplified)_People's Republic of China.936")
116 || !strcmp(ret, "Chinese (Simplified)_China.936")
117 || broken(!strcmp(ret, "Chinese_Taiwan.950")), "ret = %s\n", ret);
118
119 ret = setlocale(LC_ALL, "chinese-simplified");
120 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
121 if(ret)
122 ok(!strcmp(ret, "Chinese (Simplified)_People's Republic of China.936")
123 || !strcmp(ret, "Chinese (Simplified)_China.936")
124 || broken(!strcmp(ret, "Chinese_People's Republic of China.936"))
125 || broken(!strcmp(ret, "Chinese_Taiwan.950")), "ret = %s\n", ret);
126
127 ret = setlocale(LC_ALL, "chinese-traditional");
128 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);
132
133 ret = setlocale(LC_ALL, "chs");
134 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
135 if(ret)
136 ok(!strcmp(ret, "Chinese (Simplified)_People's Republic of China.936")
137 || !strcmp(ret, "Chinese (Simplified)_China.936")
138 || broken(!strcmp(ret, "Chinese_People's Republic of China.936")), "ret = %s\n", ret);
139
140 ret = setlocale(LC_ALL, "cht");
141 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
142 if(ret)
143 ok(!strcmp(ret, "Chinese (Traditional)_Taiwan.950")
144 || broken(!strcmp(ret, "Chinese_Taiwan.950")), "ret = %s\n", ret);
145
146 ret = setlocale(LC_ALL, "Chinese_China.936");
147 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
148 if(ret)
149 {
150 trace("Chinese_China.936=%s\n", ret);
151 ok(!strcmp(ret, "Chinese (Simplified)_People's Republic of China.936") /* Vista - Win7 */
152 || !strcmp(ret, "Chinese (Simplified)_China.936") /* Win8 - Win10 */
153 || broken(!strcmp(ret, "Chinese_People's Republic of China.936")), "ret = %s\n", ret);
154 }
155
156 ret = setlocale(LC_ALL, "csy");
157 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
158 if(ret)
159 ok(!strcmp(ret, "Czech_Czech Republic.1250")
160 || !strcmp(ret, "Czech_Czechia.1250"), "ret = %s\n", ret);
161
162 ret = setlocale(LC_ALL, "czech");
163 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
164 if(ret)
165 ok(!strcmp(ret, "Czech_Czech Republic.1250")
166 || !strcmp(ret, "Czech_Czechia.1250"), "ret = %s\n", ret);
167
168 ret = setlocale(LC_ALL, "dan");
169 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
170 if(ret)
171 ok(!strcmp(ret, "Danish_Denmark.1252"), "ret = %s\n", ret);
172
173 ret = setlocale(LC_ALL, "danish");
174 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
175 if(ret)
176 ok(!strcmp(ret, "Danish_Denmark.1252"), "ret = %s\n", ret);
177
178 ret = setlocale(LC_ALL, "dea");
179 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
180 if(ret)
181 ok(!strcmp(ret, "German_Austria.1252"), "ret = %s\n", ret);
182
183 ret = setlocale(LC_ALL, "des");
184 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
185 if(ret)
186 ok(!strcmp(ret, "German_Switzerland.1252"), "ret = %s\n", ret);
187
188 ret = setlocale(LC_ALL, "deu");
189 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
190 if(ret)
191 ok(!strcmp(ret, "German_Germany.1252"), "ret = %s\n", ret);
192
193 ret = setlocale(LC_ALL, "dutch");
194 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
195 if(ret)
196 ok(!strcmp(ret, "Dutch_Netherlands.1252"), "ret = %s\n", ret);
197
198 ret = setlocale(LC_ALL, "dutch-belgian");
199 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
200 if(ret)
201 ok(!strcmp(ret, "Dutch_Belgium.1252")
202 || broken(!strcmp(ret, "Dutch_Netherlands.1252")), "ret = %s\n", ret);
203
204 ret = setlocale(LC_ALL, "ena");
205 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
206 if(ret)
207 ok(!strcmp(ret, "English_Australia.1252")
208 || broken(!strcmp(ret, "English_United States.1252")), "ret = %s\n", ret);
209
210 ret = setlocale(LC_ALL, "ell");
211 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
212 if(ret)
213 ok(!strcmp(ret, "Greek_Greece.1253"), "ret = %s\n", ret);
214
215 ret = setlocale(LC_ALL, "enc");
216 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
217 if(ret)
218 ok(!strcmp(ret, "English_Canada.1252")
219 || broken(!strcmp(ret, "English_United States.1252")), "ret = %s\n", ret);
220
221 ret = setlocale(LC_ALL, "eng");
222 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
223 if(ret)
224 ok(!strcmp(ret, "English_United Kingdom.1252")
225 || broken(!strcmp(ret, "English_United States.1252")), "ret = %s\n", ret);
226
227 ret = setlocale(LC_ALL, "enu");
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, "enz");
233 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
234 if(ret)
235 ok(!strcmp(ret, "English_New Zealand.1252")
236 || broken(!strcmp(ret, "English_United States.1252")), "ret = %s\n", ret);
237
238 ret = setlocale(LC_ALL, "english");
239 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
240 if(ret)
241 ok(!strcmp(ret, "English_United States.1252"), "ret = %s\n", ret);
242
243 ret = setlocale(LC_ALL, "english-american");
244 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
245 if(ret)
246 ok(!strcmp(ret, "English_United States.1252"), "ret = %s\n", ret);
247
248 ret = setlocale(LC_ALL, "english-aus");
249 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
250 if(ret)
251 ok(!strcmp(ret, "English_Australia.1252")
252 || broken(!strcmp(ret, "English_United States.1252")), "ret = %s\n", ret);
253
254 ret = setlocale(LC_ALL, "english-can");
255 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
256 if(ret)
257 ok(!strcmp(ret, "English_Canada.1252")
258 || broken(!strcmp(ret, "English_United States.1252")), "ret = %s\n", ret);
259
260 ret = setlocale(LC_ALL, "english-nz");
261 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
262 if(ret)
263 ok(!strcmp(ret, "English_New Zealand.1252")
264 || broken(!strcmp(ret, "English_United States.1252")), "ret = %s\n", ret);
265
266 ret = setlocale(LC_ALL, "english-uk");
267 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
268 if(ret)
269 ok(!strcmp(ret, "English_United Kingdom.1252")
270 || broken(!strcmp(ret, "English_United States.1252")), "ret = %s\n", ret);
271
272 ret = setlocale(LC_ALL, "english-us");
273 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
274 if(ret)
275 ok(!strcmp(ret, "English_United States.1252"), "ret = %s\n", ret);
276
277 ret = setlocale(LC_ALL, "english-usa");
278 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
279 if(ret)
280 ok(!strcmp(ret, "English_United States.1252"), "ret = %s\n", ret);
281
282 ret = setlocale(LC_ALL, "esm");
283 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
284 if(ret)
285 ok(!strcmp(ret, "Spanish_Mexico.1252"), "ret = %s\n", ret);
286
287 ret = setlocale(LC_ALL, "esn");
288 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
289 if(ret)
290 ok(!strcmp(ret, "Spanish_Spain.1252")
291 || broken(!strcmp(ret, "Spanish - Modern Sort_Spain.1252")), "ret = %s\n", ret);
292
293 ret = setlocale(LC_ALL, "esp");
294 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
295 if(ret)
296 ok(!strcmp(ret, "Spanish_Spain.1252")
297 || broken(!strcmp(ret, "Spanish - Traditional Sort_Spain.1252")), "ret = %s\n", ret);
298
299 ret = setlocale(LC_ALL, "fin");
300 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
301 if(ret)
302 ok(!strcmp(ret, "Finnish_Finland.1252"), "ret = %s\n", ret);
303
304 ret = setlocale(LC_ALL, "finnish");
305 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
306 if(ret)
307 ok(!strcmp(ret, "Finnish_Finland.1252"), "ret = %s\n", ret);
308
309 ret = setlocale(LC_ALL, "fra");
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, "frb");
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, "frc");
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");
327 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
328 if(ret)
329 ok(!strcmp(ret, "French_France.1252"), "ret = %s\n", ret);
330
331 ret = setlocale(LC_ALL, "french-belgian");
332 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
333 if(ret)
334 ok(!strcmp(ret, "French_Belgium.1252")
335 || broken(!strcmp(ret, "French_France.1252")), "ret = %s\n", ret);
336
337 ret = setlocale(LC_ALL, "french-canadian");
338 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
339 if(ret)
340 ok(!strcmp(ret, "French_Canada.1252")
341 || broken(!strcmp(ret, "French_France.1252")), "ret = %s\n", ret);
342
343 ret = setlocale(LC_ALL, "french-swiss");
344 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
345 if(ret)
346 ok(!strcmp(ret, "French_Switzerland.1252")
347 || broken(!strcmp(ret, "French_France.1252")), "ret = %s\n", ret);
348
349 ret = setlocale(LC_ALL, "frs");
350 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
351 if(ret)
352 ok(!strcmp(ret, "French_Switzerland.1252")
353 || broken(!strcmp(ret, "French_France.1252")), "ret = %s\n", ret);
354
355 ret = setlocale(LC_ALL, "german");
356 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
357 if(ret)
358 ok(!strcmp(ret, "German_Germany.1252"), "ret = %s\n", ret);
359
360 ret = setlocale(LC_ALL, "german-austrian");
361 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
362 if(ret)
363 ok(!strcmp(ret, "German_Austria.1252")
364 || broken(!strcmp(ret, "German_Germany.1252")), "ret = %s\n", ret);
365
366 ret = setlocale(LC_ALL, "german-swiss");
367 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
368 if(ret)
369 ok(!strcmp(ret, "German_Switzerland.1252")
370 || broken(!strcmp(ret, "German_Germany.1252")), "ret = %s\n", ret);
371
372 ret = setlocale(LC_ALL, "greek");
373 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
374 if(ret)
375 ok(!strcmp(ret, "Greek_Greece.1253"), "ret = %s\n", ret);
376
377 ret = setlocale(LC_ALL, "hun");
378 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
379 if(ret)
380 ok(!strcmp(ret, "Hungarian_Hungary.1250"), "ret = %s\n", ret);
381
382 ret = setlocale(LC_ALL, "hungarian");
383 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
384 if(ret)
385 ok(!strcmp(ret, "Hungarian_Hungary.1250"), "ret = %s\n", ret);
386
387 ret = setlocale(LC_ALL, "icelandic");
388 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
389 if(ret)
390 ok(!strcmp(ret, "Icelandic_Iceland.1252"), "ret = %s\n", ret);
391
392 ret = setlocale(LC_ALL, "isl");
393 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
394 if(ret)
395 ok(!strcmp(ret, "Icelandic_Iceland.1252"), "ret = %s\n", ret);
396
397 ret = setlocale(LC_ALL, "ita");
398 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
399 if(ret)
400 ok(!strcmp(ret, "Italian_Italy.1252"), "ret = %s\n", ret);
401
402 ret = setlocale(LC_ALL, "italian");
403 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
404 if(ret)
405 ok(!strcmp(ret, "Italian_Italy.1252"), "ret = %s\n", ret);
406
407 ret = setlocale(LC_ALL, "italian-swiss");
408 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
409 if(ret)
410 ok(!strcmp(ret, "Italian_Switzerland.1252")
411 || broken(!strcmp(ret, "Italian_Italy.1252")), "ret = %s\n", ret);
412
413 ret = setlocale(LC_ALL, "its");
414 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
415 if(ret)
416 ok(!strcmp(ret, "Italian_Switzerland.1252")
417 || broken(!strcmp(ret, "Italian_Italy.1252")), "ret = %s\n", ret);
418
419 ret = setlocale(LC_ALL, "japanese");
420 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
421 if(ret)
422 ok(!strcmp(ret, "Japanese_Japan.932"), "ret = %s\n", ret);
423
424 ret = setlocale(LC_ALL, "jpn");
425 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
426 if(ret)
427 ok(!strcmp(ret, "Japanese_Japan.932"), "ret = %s\n", ret);
428
429 ret = setlocale(LC_ALL, "korean");
430 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
431 if(ret)
432 ok(!strcmp(ret, "Korean_Korea.949"), "ret = %s\n", ret);
433
434 ret = setlocale(LC_ALL, "korean");
435 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
436 if(ret)
437 ok(!strcmp(ret, "Korean_Korea.949"), "ret = %s\n", ret);
438
439 ret = setlocale(LC_ALL, "nlb");
440 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
441 if(ret)
442 ok(!strcmp(ret, "Dutch_Belgium.1252")
443 || broken(!strcmp(ret, "Dutch_Netherlands.1252")), "ret = %s\n", ret);
444
445 ret = setlocale(LC_ALL, "nld");
446 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
447 if(ret)
448 ok(!strcmp(ret, "Dutch_Netherlands.1252"), "ret = %s\n", ret);
449
450 ret = setlocale(LC_ALL, "non");
451 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
452 if(ret)
453 ok(!strcmp( ret, "Norwegian-Nynorsk_Norway.1252") /* XP - Win10 */
454 || !strcmp(ret, "Norwegian (Nynorsk)_Norway.1252")
455 || broken(!strcmp(ret, "Norwegian (Bokm\xe5l)_Norway.1252"))
456 || broken(!strcmp(ret, "Norwegian_Norway.1252")), /* WinME */
457 "ret = %s\n", ret);
458
459 ret = setlocale(LC_ALL, "nor");
460 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
461 if(ret)
462 ok(!strcmp(ret, "Norwegian (Bokm\xe5l)_Norway.1252") /* XP - Win8 */
463 || !strcmp(ret, "Norwegian Bokm\xe5l_Norway.1252") /* Win10 */
464 || !strcmp(ret, "Norwegian (Bokmal)_Norway.1252")
465 || broken(!strcmp(ret, "Norwegian_Norway.1252")), /* WinME */
466 "ret = %s\n", ret);
467
468 ret = setlocale(LC_ALL, "norwegian-bokmal");
469 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
470 if(ret)
471 ok(!strcmp(ret, "Norwegian (Bokm\xe5l)_Norway.1252") /* XP - Win8 */
472 || !strcmp(ret, "Norwegian Bokm\xe5l_Norway.1252") /* Win10 */
473 || !strcmp(ret, "Norwegian (Bokmal)_Norway.1252")
474 || broken(!strcmp(ret, "Norwegian_Norway.1252")), /* WinME */
475 "ret = %s\n", ret);
476
477 ret = setlocale(LC_ALL, "norwegian-nynorsk");
478 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
479 if(ret)
480 ok(!strcmp(ret, "Norwegian-Nynorsk_Norway.1252") /* Vista - Win10 */
481 || !strcmp(ret, "Norwegian (Nynorsk)_Norway.1252")
482 || broken(!strcmp(ret, "Norwegian_Norway.1252")) /* WinME */
483 || broken(!strcmp(ret, "Norwegian (Bokmal)_Norway.1252"))
484 || broken(!strcmp(ret, "Norwegian (Bokm\xe5l)_Norway.1252")) /* XP & 2003 */,
485 "ret = %s\n", ret);
486
487 ret = setlocale(LC_ALL, "plk");
488 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
489 if(ret)
490 ok(!strcmp(ret, "Polish_Poland.1250"), "ret = %s\n", ret);
491
492 ret = setlocale(LC_ALL, "polish");
493 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
494 if(ret)
495 ok(!strcmp(ret, "Polish_Poland.1250"), "ret = %s\n", ret);
496
497 ret = setlocale(LC_ALL, "portuguese");
498 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
499 if(ret)
500 ok(!strcmp(ret, "Portuguese_Brazil.1252")
501 || broken(!strcmp(ret, "Portuguese_Portugal.1252")) /* NT4 */, "ret = %s\n", ret);
502
503 ret = setlocale(LC_ALL, "portuguese-brazil");
504 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
505 if(ret)
506 ok(!strcmp(ret, "Portuguese_Brazil.1252"), "ret = %s\n", ret);
507
508 ret = setlocale(LC_ALL, "ptb");
509 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
510 if(ret)
511 ok(!strcmp(ret, "Portuguese_Brazil.1252"), "ret = %s\n", ret);
512
513 ret = setlocale(LC_ALL, "ptg");
514 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
515 if(ret)
516 ok(!strcmp(ret, "Portuguese_Portugal.1252"), "ret = %s\n", ret);
517
518 ret = setlocale(LC_ALL, "rus");
519 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
520 if(ret)
521 ok(!strcmp(ret, "Russian_Russia.1251"), "ret = %s\n", ret);
522
523 ret = setlocale(LC_ALL, "russian");
524 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
525 if(ret)
526 ok(!strcmp(ret, "Russian_Russia.1251"), "ret = %s\n", ret);
527
528 ret = setlocale(LC_ALL, "sky");
529 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
530 if(ret)
531 ok(!strcmp(ret, "Slovak_Slovakia.1250"), "ret = %s\n", ret);
532
533 ret = setlocale(LC_ALL, "slovak");
534 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
535 if(ret)
536 ok(!strcmp(ret, "Slovak_Slovakia.1250"), "ret = %s\n", ret);
537
538 ret = setlocale(LC_ALL, "spanish");
539 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
540 if(ret)
541 ok(!strcmp(ret, "Spanish_Spain.1252")
542 || broken(!strcmp(ret, "Spanish - Traditional Sort_Spain.1252")), "ret = %s\n", ret);
543
544 ret = setlocale(LC_ALL, "spanish-mexican");
545 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
546 if(ret)
547 ok(!strcmp(ret, "Spanish_Mexico.1252")
548 || broken(!strcmp(ret, "Spanish_Spain.1252")), "ret = %s\n", ret);
549
550 ret = setlocale(LC_ALL, "spanish-modern");
551 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
552 if(ret)
553 ok(!strcmp(ret, "Spanish - Modern Sort_Spain.1252")
554 || !strcmp(ret, "Spanish_Spain.1252"), "ret = %s\n", ret);
555
556 ret = setlocale(LC_ALL, "sve");
557 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
558 if(ret)
559 ok(!strcmp(ret, "Swedish_Sweden.1252"), "ret = %s\n", ret);
560
561 ret = setlocale(LC_ALL, "swedish");
562 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
563 if(ret)
564 ok(!strcmp(ret, "Swedish_Sweden.1252"), "ret = %s\n", ret);
565
566 ret = setlocale(LC_ALL, "swiss");
567 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
568 if(ret)
569 ok(!strcmp(ret, "German_Switzerland.1252"), "ret = %s\n", ret);
570
571 ret = setlocale(LC_ALL, "trk");
572 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
573 if(ret)
574 ok(!strcmp(ret, "Turkish_Turkey.1254"), "ret = %s\n", ret);
575
576 ret = setlocale(LC_ALL, "turkish");
577 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
578 if(ret)
579 ok(!strcmp(ret, "Turkish_Turkey.1254"), "ret = %s\n", ret);
580
581 ret = setlocale(LC_ALL, "uk");
582 ok(ret != NULL, "ret == NULL\n");
583 if(ret)
584 ok(!strcmp(ret, "English_United Kingdom.1252")
585 || broken(!strcmp(ret, "Ukrainian_Ukraine.1251")), "ret = %s\n", ret);
586
587 ret = setlocale(LC_ALL, "us");
588 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
589 if(ret)
590 ok(!strcmp(ret, "English_United States.1252"), "ret = %s\n", ret);
591
592 ret = setlocale(LC_ALL, "usa");
593 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
594 if(ret)
595 ok(!strcmp(ret, "English_United States.1252"), "ret = %s\n", ret);
596
597 ret = setlocale(LC_ALL, "English_United States.ACP");
598 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
599 if(ret) {
600 strcpy(buf, "English_United States.");
603 ok(!strcmp(ret, buf), "ret = %s, expected %s\n", ret, buf);
604 }
605
606 ret = setlocale(LC_ALL, "English_United States.OCP");
607 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n");
608 if(ret) {
609 strcpy(buf, "English_United States.");
612 ok(!strcmp(ret, buf), "ret = %s, expected %s\n", ret, buf);
613 }
614
615 ret = setlocale(LC_ALL, "English_United States.UTF8");
616 ok(ret == NULL, "ret != NULL\n");
617
618 ret = setlocale(LC_ALL, "en-US");
619 ok(ret == NULL || broken (ret != NULL), "ret != NULL\n"); /* XP & 2003 */
620}
621
622static void test_crtGetStringTypeW(void)
623{
624 static const wchar_t str0[] = { '0', '\0' };
625 static const wchar_t strA[] = { 'A', '\0' };
626 static const wchar_t str_space[] = { ' ', '\0' };
627 static const wchar_t str_null[] = { '\0', '\0' };
628 static const wchar_t str_rand[] = { 1234, '\0' };
629
630 const wchar_t *str[] = { str0, strA, str_space, str_null, str_rand };
631
632 WORD out_crt, out;
633 BOOL ret_crt, ret;
634 int i;
635
636 if(!p__crtGetStringTypeW) {
637 win_skip("Skipping __crtGetStringTypeW tests\n");
638 return;
639 }
640
641 if(!pmemcpy_s) {
642 win_skip("Too old version of msvcrt.dll\n");
643 return;
644 }
645
646 for(i=0; i<ARRAY_SIZE(str); i++) {
647 ret_crt = p__crtGetStringTypeW(0, CT_CTYPE1, str[i], 1, &out_crt);
649 ok(ret == ret_crt, "%d) ret_crt = %d\n", i, (int)ret_crt);
650 ok(out == out_crt, "%d) out_crt = %x, expected %x\n", i, (int)out_crt, (int)out);
651
652 ret_crt = p__crtGetStringTypeW(0, CT_CTYPE2, str[i], 1, &out_crt);
654 ok(ret == ret_crt, "%d) ret_crt = %d\n", i, (int)ret_crt);
655 ok(out == out_crt, "%d) out_crt = %x, expected %x\n", i, (int)out_crt, (int)out);
656
657 ret_crt = p__crtGetStringTypeW(0, CT_CTYPE3, str[i], 1, &out_crt);
659 ok(ret == ret_crt, "%d) ret_crt = %d\n", i, (int)ret_crt);
660 ok(out == out_crt, "%d) out_crt = %x, expected %x\n", i, (int)out_crt, (int)out);
661 }
662
663 ret = p__crtGetStringTypeW(0, 3, str[0], 1, &out);
664 ok(!ret, "ret == TRUE\n");
665}
666
667static void test__Gettnames(void)
668{
669 static const DWORD time_data[] = {
685 };
686
687 struct {
688 char *str[43];
689 LCID lcid;
690 int unk[2];
691 wchar_t *wstr[43];
692 char data[1];
693 } *ret;
694 int size;
695 char buf[64];
696 int i;
697
698 if(!setlocale(LC_ALL, "english"))
699 return;
700
701 ret = _Gettnames();
702 size = ret->str[0]-(char*)ret;
703 /* Newer version of the structure stores both ascii and unicode strings.
704 * Unicode strings are only initialized on Windows 7
705 */
706 if(sizeof(void*) == 8)
707 ok(size==0x2c0 || broken(size==0x168), "structure size: %x\n", size);
708 else
709 ok(size==0x164 || broken(size==0xb8), "structure size: %x\n", size);
710
711 for (i = 0; i < ARRAY_SIZE(time_data); i++)
712 {
714 time_data[i], buf, sizeof(buf));
715 ok(size, "GetLocaleInfo failed: %x\n", GetLastError());
716 ok(!strcmp(ret->str[i], buf), "ret->str[%i] = %s, expected %s\n", i, ret->str[i], buf);
717 }
718
719 free(ret);
720
721 if(!setlocale(LC_TIME, "german"))
722 return;
723
724 ret = _Gettnames();
725 for (i = 0; i < ARRAY_SIZE(time_data); i++)
726 {
728 time_data[i], buf, sizeof(buf));
729 ok(size, "GetLocaleInfo failed: %x\n", GetLastError());
730 ok(!strcmp(ret->str[i], buf), "ret->str[%i] = %s, expected %s\n", i, ret->str[i], buf);
731 }
732 free(ret);
733
734 setlocale(LC_ALL, "C");
735}
736
737static void test___mb_cur_max_func(void)
738{
739 int mb_cur_max;
740
741 setlocale(LC_ALL, "C");
742
743 /* for newer Windows */
744 if(!p___mb_cur_max_func)
745 win_skip("Skipping ___mb_cur_max_func tests\n");
746 else {
747 mb_cur_max = p___mb_cur_max_func();
748 ok(mb_cur_max == 1, "mb_cur_max = %d, expected 1\n", mb_cur_max);
749
750 /* some old Windows don't set chinese */
751 if (!setlocale(LC_ALL, "chinese"))
752 win_skip("Skipping test with chinese locale\n");
753 else {
754 mb_cur_max = p___mb_cur_max_func();
755 ok(mb_cur_max == 2, "mb_cur_max = %d, expected 2\n", mb_cur_max);
756 setlocale(LC_ALL, "C");
757 }
758 }
759
760 /* for older Windows */
762 skip("Skipping __p___mb_cur_max tests\n");
763 else {
764 mb_cur_max = *p__p___mb_cur_max();
765 ok(mb_cur_max == 1, "mb_cur_max = %d, expected 1\n", mb_cur_max);
766
767 /* some old Windows don't set chinese */
768 if (!setlocale(LC_ALL, "chinese"))
769 win_skip("Skipping test with chinese locale\n");
770 else {
771 mb_cur_max = *p__p___mb_cur_max();
772 ok(mb_cur_max == 2, "mb_cur_max = %d, expected 2\n", mb_cur_max);
773 setlocale(LC_ALL, "C");
774 }
775 }
776}
777
779{
780 init();
781
786}
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
#define __cdecl
Definition: accygwin.h:79
#define trace
Definition: atltest.h:70
#define ok(value,...)
Definition: atltest.h:57
#define skip(...)
Definition: atltest.h:64
#define broken(x)
Definition: atltest.h:178
#define START_TEST(x)
Definition: atltest.h:75
#define ARRAY_SIZE(A)
Definition: main.h:20
Definition: _locale.h:75
#define free
Definition: debug_ros.c:5
#define NULL
Definition: types.h:112
#define GetProcAddress(x, y)
Definition: compat.h:753
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
Definition: loader.c:812
INT WINAPI GetLocaleInfoA(LCID lcid, LCTYPE lctype, LPSTR buffer, INT len)
Definition: locale.c:1600
BOOL WINAPI GetStringTypeW(DWORD type, LPCWSTR src, INT count, LPWORD chartype)
Definition: locale.c:3095
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
unsigned short WORD
Definition: ntddk_ex.h:93
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
GLsizeiptr size
Definition: glext.h:5919
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define LC_NUMERIC
Definition: locale.h:21
#define LC_MONETARY
Definition: locale.h:20
#define LC_ALL
Definition: locale.h:17
#define LC_TIME
Definition: locale.h:22
static PEXPLICIT_ACCESSW *static HMODULE hmod
Definition: security.c:143
static DWORD
Definition: locale.c:78
static void init(void)
Definition: locale.c:32
static void test__Gettnames(void)
Definition: locale.c:667
static void test_crtGetStringTypeW(void)
Definition: locale.c:622
void *__cdecl _Gettnames(void)
Definition: locale.c:485
static const wchar_t WORD *static size_t
Definition: locale.c:27
static void test_setlocale(void)
Definition: locale.c:42
static int *__cdecl * p__p___mb_cur_max(void)
static void test___mb_cur_max_func(void)
Definition: locale.c:737
char strA[12]
Definition: clipboard.c:2028
#define BOOL
Definition: nt_native.h:43
#define SORT_DEFAULT
#define MAKELCID(lgid, srtid)
static FILE * out
Definition: regtests2xml.c:44
const WCHAR * str
#define MAKELANGID(p, s)
Definition: nls.h:15
#define LANG_GERMAN
Definition: nls.h:62
#define LANG_ENGLISH
Definition: nls.h:52
DWORD LCID
Definition: nls.h:13
#define SUBLANG_ENGLISH_US
Definition: nls.h:222
#define win_skip
Definition: test.h:163
#define setlocale(n, s)
Definition: locale.h:46
int ret
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
#define LOCALE_SABBREVMONTHNAME10
Definition: winnls.h:115
#define LOCALE_SMONTHNAME12
Definition: winnls.h:104
#define LOCALE_IDEFAULTCODEPAGE
Definition: winnls.h:39
#define LOCALE_SMONTHNAME5
Definition: winnls.h:97
#define LOCALE_SDAYNAME5
Definition: winnls.h:83
#define LOCALE_SABBREVMONTHNAME9
Definition: winnls.h:114
#define LOCALE_SABBREVMONTHNAME11
Definition: winnls.h:116
#define LOCALE_SABBREVDAYNAME5
Definition: winnls.h:90
#define LOCALE_SABBREVDAYNAME2
Definition: winnls.h:87
#define LOCALE_SABBREVMONTHNAME2
Definition: winnls.h:107
#define LOCALE_SMONTHNAME3
Definition: winnls.h:95
#define CT_CTYPE2
Definition: winnls.h:240
#define LOCALE_SMONTHNAME11
Definition: winnls.h:103
#define LOCALE_SMONTHNAME8
Definition: winnls.h:100
#define CT_CTYPE3
Definition: winnls.h:241
#define CT_CTYPE1
Definition: winnls.h:239
#define LOCALE_SMONTHNAME4
Definition: winnls.h:96
#define LOCALE_SDAYNAME1
Definition: winnls.h:79
#define LOCALE_SLONGDATE
Definition: winnls.h:63
#define LOCALE_SMONTHNAME7
Definition: winnls.h:99
#define LOCALE_S1159
Definition: winnls.h:73
#define LOCALE_SSHORTDATE
Definition: winnls.h:62
#define LOCALE_SABBREVMONTHNAME4
Definition: winnls.h:109
#define LOCALE_SABBREVDAYNAME4
Definition: winnls.h:89
#define LOCALE_SMONTHNAME1
Definition: winnls.h:93
#define LOCALE_SABBREVMONTHNAME3
Definition: winnls.h:108
#define LOCALE_SDAYNAME7
Definition: winnls.h:85
#define LOCALE_SDAYNAME2
Definition: winnls.h:80
#define LOCALE_SABBREVMONTHNAME1
Definition: winnls.h:106
#define LOCALE_IDEFAULTANSICODEPAGE
Definition: winnls.h:40
#define LOCALE_SABBREVDAYNAME6
Definition: winnls.h:91
#define LOCALE_SMONTHNAME2
Definition: winnls.h:94
#define LOCALE_STIMEFORMAT
Definition: winnls.h:64
#define LOCALE_SABBREVDAYNAME1
Definition: winnls.h:86
#define LOCALE_SABBREVMONTHNAME6
Definition: winnls.h:111
#define LOCALE_SMONTHNAME6
Definition: winnls.h:98
#define LOCALE_SDAYNAME3
Definition: winnls.h:81
#define LOCALE_S2359
Definition: winnls.h:74
#define LOCALE_SABBREVDAYNAME3
Definition: winnls.h:88
#define LOCALE_SABBREVMONTHNAME5
Definition: winnls.h:110
#define LOCALE_SABBREVMONTHNAME7
Definition: winnls.h:112
#define LOCALE_SABBREVMONTHNAME8
Definition: winnls.h:113
#define LOCALE_SDAYNAME4
Definition: winnls.h:82
#define LOCALE_SMONTHNAME10
Definition: winnls.h:102
#define LOCALE_SMONTHNAME9
Definition: winnls.h:101
#define LOCALE_SABBREVMONTHNAME12
Definition: winnls.h:117
#define LOCALE_SDAYNAME6
Definition: winnls.h:84
#define LOCALE_SABBREVDAYNAME7
Definition: winnls.h:92