winpr/crt: Make TestUnicodeConversion endian-independent
Half of the tests expects strings in little endian byte order, half of
the tests expects byte order based on a current architecture, so it
obviously can't work on big endian machines. Wide char strings use
always little endian encoding since commit f722dc5
. Use only strings
in little endian to make the tests endian-independent.
This commit is contained in:
parent
44ce6b02ed
commit
1903537f09
@ -292,9 +292,9 @@ BOOL test_unicode_uppercasing(BYTE* lower, BYTE* upper)
|
||||
|
||||
BOOL test_ConvertFromUnicode_wrapper()
|
||||
{
|
||||
BYTE src1[] = "\x52\x00\x49\x00\x43\x00\x48\x00\x20\x00\x54\x00\x45\x00\x58\x00\x54\x00\x20\x00\x46\x00\x4f\x00\x52\x00\x4d\x00\x41\x00\x54\x00\x40\x00\x40\x00\x40\x00";
|
||||
BYTE src2[] = "\x52\x00\x49\x00\x43\x00\x48\x00\x20\x00\x54\x00\x45\x00\x58\x00\x54\x00\x20\x00\x46\x00\x4f\x00\x52\x00\x4d\x00\x41\x00\x54\x00\x00\x00";
|
||||
/* 00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 */
|
||||
WCHAR src1[] = { 'R','I','C','H',' ','T','E','X','T',' ','F','O','R','M','A','T','@','@','@' };
|
||||
WCHAR src2[] = { 'R','I','C','H',' ','T','E','X','T',' ','F','O','R','M','A','T', 0 };
|
||||
CHAR cmp0[] = { 'R','I','C','H',' ','T','E','X','T',' ','F','O','R','M','A','T', 0 };
|
||||
CHAR* dst = NULL;
|
||||
int i;
|
||||
@ -306,7 +306,7 @@ BOOL test_ConvertFromUnicode_wrapper()
|
||||
printf("Input UTF16 String:\n");
|
||||
string_hexdump((BYTE*) src1, 19 * sizeof(WCHAR));
|
||||
|
||||
i = ConvertFromUnicode(CP_UTF8, 0, src1, 16, &dst, 0, NULL, NULL);
|
||||
i = ConvertFromUnicode(CP_UTF8, 0, (WCHAR*)src1, 16, &dst, 0, NULL, NULL);
|
||||
if (i != 16)
|
||||
{
|
||||
fprintf(stderr, "ConvertFromUnicode failure A1: unexpectedly returned %d instead of 16\n", i);
|
||||
@ -336,9 +336,9 @@ BOOL test_ConvertFromUnicode_wrapper()
|
||||
/* Test null-terminated string */
|
||||
|
||||
printf("Input UTF16 String:\n");
|
||||
string_hexdump((BYTE*) src2, (_wcslen(src2) + 1 ) * sizeof(WCHAR));
|
||||
string_hexdump((BYTE*) src2, (_wcslen((WCHAR*)src2) + 1 ) * sizeof(WCHAR));
|
||||
|
||||
i = ConvertFromUnicode(CP_UTF8, 0, src2, -1, &dst, 0, NULL, NULL);
|
||||
i = ConvertFromUnicode(CP_UTF8, 0, (WCHAR*)src2, -1, &dst, 0, NULL, NULL);
|
||||
if (i != 17)
|
||||
{
|
||||
fprintf(stderr, "ConvertFromUnicode failure B1: unexpectedly returned %d instead of 17\n", i);
|
||||
@ -379,7 +379,7 @@ BOOL test_ConvertToUnicode_wrapper()
|
||||
/* 00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 */
|
||||
CHAR src1[] = { 'R','I','C','H',' ','T','E','X','T',' ','F','O','R','M','A','T','@','@','@' };
|
||||
CHAR src2[] = { 'R','I','C','H',' ','T','E','X','T',' ','F','O','R','M','A','T', 0 };
|
||||
WCHAR cmp0[] = { 'R','I','C','H',' ','T','E','X','T',' ','F','O','R','M','A','T', 0 };
|
||||
BYTE cmp0[] = "\x52\x00\x49\x00\x43\x00\x48\x00\x20\x00\x54\x00\x45\x00\x58\x00\x54\x00\x20\x00\x46\x00\x4f\x00\x52\x00\x4d\x00\x41\x00\x54\x00\x00\x00";
|
||||
WCHAR* dst = NULL;
|
||||
int i;
|
||||
|
||||
@ -406,7 +406,7 @@ BOOL test_ConvertToUnicode_wrapper()
|
||||
fprintf(stderr, "ConvertToUnicode failure A3: dst length is %d instead of 16\n", i);
|
||||
goto fail;
|
||||
}
|
||||
if (_wcscmp(dst, cmp0))
|
||||
if (_wcscmp(dst, (WCHAR*)cmp0))
|
||||
{
|
||||
fprintf(stderr, "ConvertToUnicode failure A4: data mismatch\n");
|
||||
goto fail;
|
||||
@ -438,7 +438,7 @@ BOOL test_ConvertToUnicode_wrapper()
|
||||
fprintf(stderr, "ConvertToUnicode failure B3: dst length is %d instead of 16\n", i);
|
||||
goto fail;
|
||||
}
|
||||
if (_wcscmp(dst, cmp0))
|
||||
if (_wcscmp(dst, (WCHAR*)cmp0))
|
||||
{
|
||||
fprintf(stderr, "ConvertToUnicode failure B: data mismatch\n");
|
||||
goto fail;
|
||||
|
Loading…
Reference in New Issue
Block a user