kernel32/tests: Refactor MB_ERR_INVALID_CHARS tests.

Signed-off-by: Akihiro Sagawa <sagawa.aki@gmail.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Akihiro Sagawa 2019-12-16 22:39:39 +09:00 committed by Alexandre Julliard
parent 6127c688ea
commit 3bb92d7773
1 changed files with 10 additions and 10 deletions

View File

@ -1001,7 +1001,7 @@ static void test_utf7_decoding(void)
static void test_undefined_byte_char(void)
{
static const struct tag_testset {
INT codepage;
UINT codepage;
LPCSTR str;
BOOL is_error;
} testset[] = {
@ -1017,6 +1017,7 @@ static void test_undefined_byte_char(void)
{ 1257, "\xa5", TRUE },
};
INT i, ret;
DWORD err;
for (i = 0; i < ARRAY_SIZE(testset); i++) {
if (! IsValidCodePage(testset[i].codepage))
@ -1028,23 +1029,22 @@ static void test_undefined_byte_char(void)
SetLastError(0xdeadbeef);
ret = MultiByteToWideChar(testset[i].codepage, MB_ERR_INVALID_CHARS,
testset[i].str, -1, NULL, 0);
err = GetLastError();
if (testset[i].is_error) {
ok(ret == 0 && GetLastError() == ERROR_NO_UNICODE_TRANSLATION,
"ret is %d, GetLastError is %u (cp %d)\n",
ret, GetLastError(), testset[i].codepage);
ok(err == ERROR_NO_UNICODE_TRANSLATION, "Test %u: err is %u\n", i, err);
ok(ret == 0, "Test %u: ret is %d\n", i, ret);
}
else {
ok(ret == strlen(testset[i].str)+1 && GetLastError() == 0xdeadbeef,
"ret is %d, GetLastError is %u (cp %d)\n",
ret, GetLastError(), testset[i].codepage);
ok(err == 0xdeadbeef, "Test %u: err is %u\n", i, err);
ok(ret == 2, "Test %u: ret is %d\n", i, ret);
}
SetLastError(0xdeadbeef);
ret = MultiByteToWideChar(testset[i].codepage, 0,
testset[i].str, -1, NULL, 0);
ok(ret == strlen(testset[i].str)+1 && GetLastError() == 0xdeadbeef,
"ret is %d, GetLastError is %u (cp %d)\n",
ret, GetLastError(), testset[i].codepage);
err = GetLastError();
ok(err == 0xdeadbeef, "Test %u: err is %u\n", i, err);
ok(ret == 2, "Test %u: ret is %d\n", i, ret);
}
}