Commit 14f41641 authored by Alex Henrie's avatar Alex Henrie Committed by Alexandre Julliard

kernel32/tests: Add UTF-7 stray + sign removal tests.

parent 5d43ef68
......@@ -527,6 +527,73 @@ static void test_utf7_encoding(void)
}
}
static void test_utf7_decoding(void)
{
char input[32];
WCHAR output[32], expected[32];
int i, len, expected_len;
static const signed char base64_decoding_table[] =
{
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 0x00-0x0F */
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 0x10-0x1F */
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 62, -1, -1, -1, 63, /* 0x20-0x2F */
52, 53, 54, 55, 56, 57, 58, 59, 60, 61, -1, -1, -1, -1, -1, -1, /* 0x30-0x3F */
-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, /* 0x40-0x4F */
15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, -1, -1, -1, -1, -1, /* 0x50-0x5F */
-1, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, /* 0x60-0x6F */
41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, -1, -1, -1, -1, -1 /* 0x70-0x7F */
};
if (MultiByteToWideChar(CP_UTF7, 0, "foobar", -1, NULL, 0) == 0 &&
GetLastError() == ERROR_CALL_NOT_IMPLEMENTED)
{
skip("UTF-7 decoding not implemented\n");
return;
}
/* test which one-byte characters remove stray + signs */
for (i = 0; i < 256; i++)
{
sprintf(input, "+%c+AAA", i);
memset(output, 0x23, sizeof(output) - sizeof(WCHAR));
output[sizeof(output) / sizeof(WCHAR) - 1] = 0;
len = MultiByteToWideChar(CP_UTF7, 0, input, 7, output, sizeof(output) / sizeof(WCHAR) - 1);
if (i == '-')
{
/* removes the - sign */
expected_len = 3;
expected[0] = 0x002B;
expected[1] = 0;
expected[2] = 0;
}
else if (i <= 0x7F && base64_decoding_table[i] != -1)
{
/* absorbs the character into the base64 sequence */
expected_len = 2;
expected[0] = (base64_decoding_table[i] << 10) | 0x03E0;
expected[1] = 0;
}
else
{
/* removes the + sign */
expected_len = 3;
expected[0] = i;
expected[1] = 0;
expected[2] = 0;
}
expected[expected_len] = 0x2323;
ok(len == expected_len, "i=0x%02x: expected len=%i, got len=%i\n", i, expected_len, len);
ok(memcmp(output, expected, (expected_len + 1) * sizeof(WCHAR)) == 0,
"i=0x%02x: expected output=%s, got output=%s\n",
i, wine_dbgstr_wn(expected, expected_len + 1), wine_dbgstr_wn(output, expected_len + 1));
}
}
static void test_undefined_byte_char(void)
{
static const struct tag_testset {
......@@ -734,6 +801,7 @@ START_TEST(codepage)
test_string_conversion(&bUsedDefaultChar);
test_utf7_encoding();
test_utf7_decoding();
test_undefined_byte_char();
test_threadcp();
......
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