From b8f33aa59c5040855e290b00bab3310233f91a67 Mon Sep 17 00:00:00 2001 From: Ondrej Holy Date: Wed, 8 Jun 2016 11:43:11 +0200 Subject: [PATCH] winpr/crt: Make TestString endian-independent Wide char strings use always little endian encoding since commit f722dc5. Use only strings in little endian to make the tests endian-independent. --- winpr/libwinpr/crt/test/TestString.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/winpr/libwinpr/crt/test/TestString.c b/winpr/libwinpr/crt/test/TestString.c index 663e357..25484a2 100644 --- a/winpr/libwinpr/crt/test/TestString.c +++ b/winpr/libwinpr/crt/test/TestString.c @@ -16,6 +16,10 @@ static WCHAR testToken1W[] = { 'q', 'u', 'i', 'c', 'k', '\0' }; static WCHAR testToken2W[] = { 'b', 'r', 'o', 'w', 'n', '\0' }; static WCHAR testToken3W[] = { 'f', 'o', 'x', '\0' }; +#define testToken1W_Length ((sizeof(testToken1W) / sizeof(WCHAR)) - 1) +#define testToken2W_Length ((sizeof(testToken2W) / sizeof(WCHAR)) - 1) +#define testToken3W_Length ((sizeof(testToken3W) / sizeof(WCHAR)) - 1) + static WCHAR testTokensW[] = { 'q', 'u', 'i', 'c', 'k', '\r', '\n', @@ -23,8 +27,12 @@ static WCHAR testTokensW[] = 'f', 'o', 'x', '\r', '\n', '\0' }; +#define testTokensW_Length ((sizeof(testTokensW) / sizeof(WCHAR)) - 1) + static WCHAR testDelimiter[] = { '\r', '\n', '\0' }; +#define testDelimiter_Length ((sizeof(testDelimiter) / sizeof(WCHAR)) - 1) + int TestString(int argc, char* argv[]) { WCHAR* p; @@ -32,6 +40,16 @@ int TestString(int argc, char* argv[]) size_t length; WCHAR* context; +#ifdef __BIG_ENDIAN__ + /* Be sure that we always use LE encoded string */ + ByteSwapUnicode(testStringW, testStringW_Length); + ByteSwapUnicode(testToken1W, testToken1W_Length); + ByteSwapUnicode(testToken2W, testToken2W_Length); + ByteSwapUnicode(testToken3W, testToken3W_Length); + ByteSwapUnicode(testTokensW, testTokensW_Length); + ByteSwapUnicode(testDelimiter, testDelimiter_Length); +#endif + /* _wcslen */ length = _wcslen(testStringW); -- 2.7.4