Daniel Lehman dlehman@esri.com writes:
+static void test_threadcp(void) +{
- CPINFOEXA cpi;
- int i, ret;
- UINT cp;
- LCID last;
- struct test
- {
LCID lcid;
UINT defacp;
UINT threadcp;
- } lcids[] =
- {
{ 0x0409 /* 1033 - English - United States */, 1252, 1252 /* ANSI Latin 1 */},
{ 0x0439 /* 1081 - Hindi - India */, 0 /* None */, 1252 /* ANSI Latin 1 */},
{ 0x0419 /* 1049 - Russian - Russia */, 1251, 1251 /* ANSI Cyrillic */},
{ 0x0411 /* 1041 - Japanese - Japan */, 932, 932 /* Shift-JIS */}
- };
- last = GetThreadLocale();
- for (i = 0; i < sizeof(lcids)/sizeof(lcids[0]); i++)
- {
SetThreadLocale(lcids[i].lcid);
GetLocaleInfoA(lcids[i].lcid, LOCALE_IDEFAULTANSICODEPAGE|LOCALE_RETURN_NUMBER, (LPSTR)&cp, sizeof(cp));
ok(cp == lcids[i].defacp, "wrong codepage %i for lcid %04x, should be %04x\n", cp, lcids[i].defacp, cp);
memset(&cpi, 0, sizeof(cpi));
GetCPInfoExA(CP_ACP, 0, &cpi);
ok(cpi.CodePage == 1252 /* ANSI Latin 1 */, "wrong codepage %i for lcid %04x, should be 1252\n",
cpi.CodePage, lcids[i].lcid);
SetLastError(0xdeadbeef);
ret = WideCharToMultiByte(CP_ACP, 0, foobarW, -1, NULL, 0, NULL, NULL);
ok(ret == 7, "ret is %d (%04x)\n", ret, lcids[i].lcid);
ok(GetLastError() == 0xdeadbeef, "GetLastError() is %u (%04x)\n", GetLastError(), lcids[i].lcid);
GetCPInfoExA(CP_THREAD_ACP, 0, &cpi);
ok(cpi.CodePage == lcids[i].threadcp, "wrong codepage %i for lcid %04x, should be %i\n",
cpi.CodePage, lcids[i].lcid, lcids[i].threadcp);
SetLastError(0xdeadbeef);
ret = WideCharToMultiByte(CP_THREAD_ACP, 0, foobarW, -1, NULL, 0, NULL, NULL);
ok(ret == 7, "ret is %d (%04x)\n", ret, lcids[i].lcid);
ok(GetLastError() == 0xdeadbeef, "GetLastError() is %u (%04x)\n", GetLastError(), lcids[i].lcid);
- }
- SetThreadLocale(last);
That's better, but you should use appropriate constants for the locale ids, and test the other functions that use get_codepage_table to make sure the behavior is common to all of them.