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 static int (__cdecl *p___mb_cur_max_func)(void); 29 static int *(__cdecl *p__p___mb_cur_max)(void); 30 void* __cdecl _Gettnames(void); 31 32 static 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 42 static 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 55 ret = setlocale(LC_ALL, NULL); 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 72 ret = setlocale(LC_ALL, NULL); 73 ok(!strcmp(ret, lc_all), "ret = %s\n", ret); 74 75 strcpy(buf, ret); 76 ret = setlocale(LC_ALL, buf); 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 todo_wine 148 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n"); 149 if(ret) 150 { 151 trace("Chinese_China.936=%s\n", ret); 152 todo_wine 153 ok(!strcmp(ret, "Chinese (Simplified)_People's Republic of China.936") /* Vista - Win7 */ 154 || !strcmp(ret, "Chinese (Simplified)_China.936") /* Win8 - Win10 */ 155 || broken(!strcmp(ret, "Chinese_People's Republic of China.936")), "ret = %s\n", ret); 156 } 157 158 ret = setlocale(LC_ALL, "csy"); 159 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n"); 160 if(ret) 161 ok(!strcmp(ret, "Czech_Czech Republic.1250"), "ret = %s\n", ret); 162 163 ret = setlocale(LC_ALL, "czech"); 164 ok(ret != NULL || broken (ret == NULL), "ret == NULL\n"); 165 if(ret) 166 ok(!strcmp(ret, "Czech_Czech Republic.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."); 601 GetLocaleInfoA(MAKELCID(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), SORT_DEFAULT), 602 LOCALE_IDEFAULTANSICODEPAGE, buf+strlen(buf), 80); 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."); 610 GetLocaleInfoA(MAKELCID(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), SORT_DEFAULT), 611 LOCALE_IDEFAULTCODEPAGE, buf+strlen(buf), 80); 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 619 static void test_crtGetStringTypeW(void) 620 { 621 static const wchar_t str0[] = { '0', '\0' }; 622 static const wchar_t strA[] = { 'A', '\0' }; 623 static const wchar_t str_space[] = { ' ', '\0' }; 624 static const wchar_t str_null[] = { '\0', '\0' }; 625 static const wchar_t str_rand[] = { 1234, '\0' }; 626 627 const wchar_t *str[] = { str0, strA, str_space, str_null, str_rand }; 628 629 WORD out_crt, out; 630 BOOL ret_crt, ret; 631 int i; 632 633 if(!p__crtGetStringTypeW) { 634 win_skip("Skipping __crtGetStringTypeW tests\n"); 635 return; 636 } 637 638 if(!pmemcpy_s) { 639 win_skip("Too old version of msvcrt.dll\n"); 640 return; 641 } 642 643 for(i=0; i<sizeof(str)/sizeof(*str); i++) { 644 ret_crt = p__crtGetStringTypeW(0, CT_CTYPE1, str[i], 1, &out_crt); 645 ret = GetStringTypeW(CT_CTYPE1, str[i], 1, &out); 646 ok(ret == ret_crt, "%d) ret_crt = %d\n", i, (int)ret_crt); 647 ok(out == out_crt, "%d) out_crt = %x, expected %x\n", i, (int)out_crt, (int)out); 648 649 ret_crt = p__crtGetStringTypeW(0, CT_CTYPE2, str[i], 1, &out_crt); 650 ret = GetStringTypeW(CT_CTYPE2, str[i], 1, &out); 651 ok(ret == ret_crt, "%d) ret_crt = %d\n", i, (int)ret_crt); 652 ok(out == out_crt, "%d) out_crt = %x, expected %x\n", i, (int)out_crt, (int)out); 653 654 ret_crt = p__crtGetStringTypeW(0, CT_CTYPE3, str[i], 1, &out_crt); 655 ret = GetStringTypeW(CT_CTYPE3, str[i], 1, &out); 656 ok(ret == ret_crt, "%d) ret_crt = %d\n", i, (int)ret_crt); 657 ok(out == out_crt, "%d) out_crt = %x, expected %x\n", i, (int)out_crt, (int)out); 658 } 659 660 ret = p__crtGetStringTypeW(0, 3, str[0], 1, &out); 661 ok(!ret, "ret == TRUE\n"); 662 } 663 664 static void test__Gettnames(void) 665 { 666 struct { 667 char *str[43]; 668 LCID lcid; 669 int unk[2]; 670 wchar_t *wstr[43]; 671 char data[1]; 672 } *ret; 673 int size; 674 char buf[64]; 675 676 if(!setlocale(LC_ALL, "english")) 677 return; 678 679 ret = _Gettnames(); 680 size = ret->str[0]-(char*)ret; 681 /* Newer version of the structure stores both ascii and unicode strings. 682 * Unicode strings are only initialized on Windows 7 683 */ 684 if(sizeof(void*) == 8) 685 ok(size==0x2c0 || broken(size==0x168), "structure size: %x\n", size); 686 else 687 ok(size==0x164 || broken(size==0xb8), "structure size: %x\n", size); 688 689 ok(!strcmp(ret->str[0], "Sun"), "ret->str[0] = %s\n", ret->str[0]); 690 ok(!strcmp(ret->str[1], "Mon"), "ret->str[1] = %s\n", ret->str[1]); 691 ok(!strcmp(ret->str[2], "Tue"), "ret->str[2] = %s\n", ret->str[2]); 692 ok(!strcmp(ret->str[3], "Wed"), "ret->str[3] = %s\n", ret->str[3]); 693 ok(!strcmp(ret->str[4], "Thu"), "ret->str[4] = %s\n", ret->str[4]); 694 ok(!strcmp(ret->str[5], "Fri"), "ret->str[5] = %s\n", ret->str[5]); 695 ok(!strcmp(ret->str[6], "Sat"), "ret->str[6] = %s\n", ret->str[6]); 696 ok(!strcmp(ret->str[7], "Sunday"), "ret->str[7] = %s\n", ret->str[7]); 697 ok(!strcmp(ret->str[8], "Monday"), "ret->str[8] = %s\n", ret->str[8]); 698 ok(!strcmp(ret->str[9], "Tuesday"), "ret->str[9] = %s\n", ret->str[9]); 699 ok(!strcmp(ret->str[10], "Wednesday"), "ret->str[10] = %s\n", ret->str[10]); 700 ok(!strcmp(ret->str[11], "Thursday"), "ret->str[11] = %s\n", ret->str[11]); 701 ok(!strcmp(ret->str[12], "Friday"), "ret->str[12] = %s\n", ret->str[12]); 702 ok(!strcmp(ret->str[13], "Saturday"), "ret->str[13] = %s\n", ret->str[13]); 703 ok(!strcmp(ret->str[14], "Jan"), "ret->str[14] = %s\n", ret->str[14]); 704 ok(!strcmp(ret->str[15], "Feb"), "ret->str[15] = %s\n", ret->str[15]); 705 ok(!strcmp(ret->str[16], "Mar"), "ret->str[16] = %s\n", ret->str[16]); 706 ok(!strcmp(ret->str[17], "Apr"), "ret->str[17] = %s\n", ret->str[17]); 707 ok(!strcmp(ret->str[18], "May"), "ret->str[18] = %s\n", ret->str[18]); 708 ok(!strcmp(ret->str[19], "Jun"), "ret->str[19] = %s\n", ret->str[19]); 709 ok(!strcmp(ret->str[20], "Jul"), "ret->str[20] = %s\n", ret->str[20]); 710 ok(!strcmp(ret->str[21], "Aug"), "ret->str[21] = %s\n", ret->str[21]); 711 ok(!strcmp(ret->str[22], "Sep"), "ret->str[22] = %s\n", ret->str[22]); 712 ok(!strcmp(ret->str[23], "Oct"), "ret->str[23] = %s\n", ret->str[23]); 713 ok(!strcmp(ret->str[24], "Nov"), "ret->str[24] = %s\n", ret->str[24]); 714 ok(!strcmp(ret->str[25], "Dec"), "ret->str[25] = %s\n", ret->str[25]); 715 ok(!strcmp(ret->str[26], "January"), "ret->str[26] = %s\n", ret->str[26]); 716 ok(!strcmp(ret->str[27], "February"), "ret->str[27] = %s\n", ret->str[27]); 717 ok(!strcmp(ret->str[28], "March"), "ret->str[28] = %s\n", ret->str[28]); 718 ok(!strcmp(ret->str[29], "April"), "ret->str[29] = %s\n", ret->str[29]); 719 ok(!strcmp(ret->str[30], "May"), "ret->str[30] = %s\n", ret->str[30]); 720 ok(!strcmp(ret->str[31], "June"), "ret->str[31] = %s\n", ret->str[31]); 721 ok(!strcmp(ret->str[32], "July"), "ret->str[32] = %s\n", ret->str[32]); 722 ok(!strcmp(ret->str[33], "August"), "ret->str[33] = %s\n", ret->str[33]); 723 ok(!strcmp(ret->str[34], "September"), "ret->str[34] = %s\n", ret->str[34]); 724 ok(!strcmp(ret->str[35], "October"), "ret->str[35] = %s\n", ret->str[35]); 725 ok(!strcmp(ret->str[36], "November"), "ret->str[36] = %s\n", ret->str[36]); 726 ok(!strcmp(ret->str[37], "December"), "ret->str[37] = %s\n", ret->str[37]); 727 ok(!strcmp(ret->str[38], "AM"), "ret->str[38] = %s\n", ret->str[38]); 728 ok(!strcmp(ret->str[39], "PM"), "ret->str[39] = %s\n", ret->str[39]); 729 ok(!strcmp(ret->str[40], "M/d/yyyy") || broken(!strcmp(ret->str[40], "M/d/yy"))/*NT*/, 730 "ret->str[40] = %s\n", ret->str[40]); 731 size = GetLocaleInfoA(MAKELCID(LANG_ENGLISH, SORT_DEFAULT), 732 LOCALE_SLONGDATE|LOCALE_NOUSEROVERRIDE, buf, sizeof(buf)); 733 ok(size, "GetLocaleInfo failed: %x\n", GetLastError()); 734 ok(!strcmp(ret->str[41], buf), "ret->str[41] = %s, expected %s\n", ret->str[41], buf); 735 free(ret); 736 737 if(!setlocale(LC_TIME, "german")) 738 return; 739 740 ret = _Gettnames(); 741 ok(!strcmp(ret->str[0], "So"), "ret->str[0] = %s\n", ret->str[0]); 742 ok(!strcmp(ret->str[1], "Mo"), "ret->str[1] = %s\n", ret->str[1]); 743 ok(!strcmp(ret->str[2], "Di"), "ret->str[2] = %s\n", ret->str[2]); 744 ok(!strcmp(ret->str[3], "Mi"), "ret->str[3] = %s\n", ret->str[3]); 745 ok(!strcmp(ret->str[4], "Do"), "ret->str[4] = %s\n", ret->str[4]); 746 ok(!strcmp(ret->str[5], "Fr"), "ret->str[5] = %s\n", ret->str[5]); 747 ok(!strcmp(ret->str[6], "Sa"), "ret->str[6] = %s\n", ret->str[6]); 748 ok(!strcmp(ret->str[7], "Sonntag"), "ret->str[7] = %s\n", ret->str[7]); 749 ok(!strcmp(ret->str[8], "Montag"), "ret->str[8] = %s\n", ret->str[8]); 750 ok(!strcmp(ret->str[9], "Dienstag"), "ret->str[9] = %s\n", ret->str[9]); 751 ok(!strcmp(ret->str[10], "Mittwoch"), "ret->str[10] = %s\n", ret->str[10]); 752 ok(!strcmp(ret->str[11], "Donnerstag"), "ret->str[11] = %s\n", ret->str[11]); 753 ok(!strcmp(ret->str[12], "Freitag"), "ret->str[12] = %s\n", ret->str[12]); 754 ok(!strcmp(ret->str[13], "Samstag"), "ret->str[13] = %s\n", ret->str[13]); 755 ok(!strcmp(ret->str[14], "Jan"), "ret->str[14] = %s\n", ret->str[14]); 756 ok(!strcmp(ret->str[15], "Feb"), "ret->str[15] = %s\n", ret->str[15]); 757 ok(!strcmp(ret->str[16], "Mrz"), "ret->str[16] = %s\n", ret->str[16]); 758 ok(!strcmp(ret->str[17], "Apr"), "ret->str[17] = %s\n", ret->str[17]); 759 ok(!strcmp(ret->str[18], "Mai"), "ret->str[18] = %s\n", ret->str[18]); 760 ok(!strcmp(ret->str[19], "Jun"), "ret->str[19] = %s\n", ret->str[19]); 761 ok(!strcmp(ret->str[20], "Jul"), "ret->str[20] = %s\n", ret->str[20]); 762 ok(!strcmp(ret->str[21], "Aug"), "ret->str[21] = %s\n", ret->str[21]); 763 ok(!strcmp(ret->str[22], "Sep"), "ret->str[22] = %s\n", ret->str[22]); 764 ok(!strcmp(ret->str[23], "Okt"), "ret->str[23] = %s\n", ret->str[23]); 765 ok(!strcmp(ret->str[24], "Nov"), "ret->str[24] = %s\n", ret->str[24]); 766 ok(!strcmp(ret->str[25], "Dez"), "ret->str[25] = %s\n", ret->str[25]); 767 ok(!strcmp(ret->str[26], "Januar"), "ret->str[26] = %s\n", ret->str[26]); 768 ok(!strcmp(ret->str[27], "Februar"), "ret->str[27] = %s\n", ret->str[27]); 769 ok(!strcmp(ret->str[29], "April"), "ret->str[29] = %s\n", ret->str[29]); 770 ok(!strcmp(ret->str[30], "Mai"), "ret->str[30] = %s\n", ret->str[30]); 771 ok(!strcmp(ret->str[31], "Juni"), "ret->str[31] = %s\n", ret->str[31]); 772 ok(!strcmp(ret->str[32], "Juli"), "ret->str[32] = %s\n", ret->str[32]); 773 ok(!strcmp(ret->str[33], "August"), "ret->str[33] = %s\n", ret->str[33]); 774 ok(!strcmp(ret->str[34], "September"), "ret->str[34] = %s\n", ret->str[34]); 775 ok(!strcmp(ret->str[35], "Oktober"), "ret->str[35] = %s\n", ret->str[35]); 776 ok(!strcmp(ret->str[36], "November"), "ret->str[36] = %s\n", ret->str[36]); 777 ok(!strcmp(ret->str[37], "Dezember"), "ret->str[37] = %s\n", ret->str[37]); 778 ok(!strcmp(ret->str[38], ""), "ret->str[38] = %s\n", ret->str[38]); 779 ok(!strcmp(ret->str[39], ""), "ret->str[39] = %s\n", ret->str[39]); 780 ok(!strcmp(ret->str[40], "dd.MM.yyyy") || broken(!strcmp(ret->str[40], "dd.MM.yy"))/*NT*/, 781 "ret->str[40] = %s\n", ret->str[40]); 782 ok(!strcmp(ret->str[41], "dddd, d. MMMM yyyy"), "ret->str[41] = %s\n", ret->str[41]); 783 free(ret); 784 785 setlocale(LC_ALL, "C"); 786 } 787 788 static void test___mb_cur_max_func(void) 789 { 790 int mb_cur_max; 791 792 setlocale(LC_ALL, "C"); 793 794 /* for newer Windows */ 795 if(!p___mb_cur_max_func) 796 win_skip("Skipping ___mb_cur_max_func tests\n"); 797 else { 798 mb_cur_max = p___mb_cur_max_func(); 799 ok(mb_cur_max == 1, "mb_cur_max = %d, expected 1\n", mb_cur_max); 800 801 /* some old Windows don't set chinese */ 802 if (!setlocale(LC_ALL, "chinese")) 803 win_skip("Skipping test with chinese locale\n"); 804 else { 805 mb_cur_max = p___mb_cur_max_func(); 806 ok(mb_cur_max == 2, "mb_cur_max = %d, expected 2\n", mb_cur_max); 807 setlocale(LC_ALL, "C"); 808 } 809 } 810 811 /* for older Windows */ 812 if (!p__p___mb_cur_max) 813 win_skip("Skipping __p___mb_cur_max tests\n"); 814 else { 815 mb_cur_max = *p__p___mb_cur_max(); 816 ok(mb_cur_max == 1, "mb_cur_max = %d, expected 1\n", mb_cur_max); 817 818 /* some old Windows don't set chinese */ 819 if (!setlocale(LC_ALL, "chinese")) 820 win_skip("Skipping test with chinese locale\n"); 821 else { 822 mb_cur_max = *p__p___mb_cur_max(); 823 ok(mb_cur_max == 2, "mb_cur_max = %d, expected 2\n", mb_cur_max); 824 setlocale(LC_ALL, "C"); 825 } 826 } 827 } 828 829 START_TEST(locale) 830 { 831 init(); 832 833 test_crtGetStringTypeW(); 834 test_setlocale(); 835 test__Gettnames(); 836 test___mb_cur_max_func(); 837 } 838