Commit 3bb92d77 authored by Akihiro Sagawa's avatar Akihiro Sagawa Committed by Alexandre Julliard

kernel32/tests: Refactor MB_ERR_INVALID_CHARS tests.

parent 6127c688
...@@ -1001,7 +1001,7 @@ static void test_utf7_decoding(void) ...@@ -1001,7 +1001,7 @@ static void test_utf7_decoding(void)
static void test_undefined_byte_char(void) static void test_undefined_byte_char(void)
{ {
static const struct tag_testset { static const struct tag_testset {
INT codepage; UINT codepage;
LPCSTR str; LPCSTR str;
BOOL is_error; BOOL is_error;
} testset[] = { } testset[] = {
...@@ -1017,6 +1017,7 @@ static void test_undefined_byte_char(void) ...@@ -1017,6 +1017,7 @@ static void test_undefined_byte_char(void)
{ 1257, "\xa5", TRUE }, { 1257, "\xa5", TRUE },
}; };
INT i, ret; INT i, ret;
DWORD err;
for (i = 0; i < ARRAY_SIZE(testset); i++) { for (i = 0; i < ARRAY_SIZE(testset); i++) {
if (! IsValidCodePage(testset[i].codepage)) if (! IsValidCodePage(testset[i].codepage))
...@@ -1028,23 +1029,22 @@ static void test_undefined_byte_char(void) ...@@ -1028,23 +1029,22 @@ static void test_undefined_byte_char(void)
SetLastError(0xdeadbeef); SetLastError(0xdeadbeef);
ret = MultiByteToWideChar(testset[i].codepage, MB_ERR_INVALID_CHARS, ret = MultiByteToWideChar(testset[i].codepage, MB_ERR_INVALID_CHARS,
testset[i].str, -1, NULL, 0); testset[i].str, -1, NULL, 0);
err = GetLastError();
if (testset[i].is_error) { if (testset[i].is_error) {
ok(ret == 0 && GetLastError() == ERROR_NO_UNICODE_TRANSLATION, ok(err == ERROR_NO_UNICODE_TRANSLATION, "Test %u: err is %u\n", i, err);
"ret is %d, GetLastError is %u (cp %d)\n", ok(ret == 0, "Test %u: ret is %d\n", i, ret);
ret, GetLastError(), testset[i].codepage);
} }
else { else {
ok(ret == strlen(testset[i].str)+1 && GetLastError() == 0xdeadbeef, ok(err == 0xdeadbeef, "Test %u: err is %u\n", i, err);
"ret is %d, GetLastError is %u (cp %d)\n", ok(ret == 2, "Test %u: ret is %d\n", i, ret);
ret, GetLastError(), testset[i].codepage);
} }
SetLastError(0xdeadbeef); SetLastError(0xdeadbeef);
ret = MultiByteToWideChar(testset[i].codepage, 0, ret = MultiByteToWideChar(testset[i].codepage, 0,
testset[i].str, -1, NULL, 0); testset[i].str, -1, NULL, 0);
ok(ret == strlen(testset[i].str)+1 && GetLastError() == 0xdeadbeef, err = GetLastError();
"ret is %d, GetLastError is %u (cp %d)\n", ok(err == 0xdeadbeef, "Test %u: err is %u\n", i, err);
ret, GetLastError(), testset[i].codepage); ok(ret == 2, "Test %u: ret is %d\n", i, ret);
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment