Sebastian Lackner : kernel32/tests: Add test to show that CompareStringW aborts on first non-matching character.
Alexandre Julliard
julliard at wine.codeweavers.com
Mon Feb 15 09:41:49 CST 2016
Module: wine
Branch: master
Commit: 1bebee9c1b119d727991aee50451e36e0865f927
URL: http://source.winehq.org/git/wine.git/?a=commit;h=1bebee9c1b119d727991aee50451e36e0865f927
Author: Sebastian Lackner <sebastian at fds-team.de>
Date: Sat Feb 13 22:24:06 2016 +0100
kernel32/tests: Add test to show that CompareStringW aborts on first non-matching character.
Signed-off-by: Sebastian Lackner <sebastian at fds-team.de>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/kernel32/tests/locale.c | 31 +++++++++++++++++++++++++++++++
1 file changed, 31 insertions(+)
diff --git a/dlls/kernel32/tests/locale.c b/dlls/kernel32/tests/locale.c
index 4a9e540..6726fb9 100644
--- a/dlls/kernel32/tests/locale.c
+++ b/dlls/kernel32/tests/locale.c
@@ -1798,6 +1798,36 @@ static void test_CompareStringA(void)
"ret %d, error %d, expected value %d\n", ret, GetLastError(), CSTR_EQUAL);
}
+static void test_CompareStringW(void)
+{
+ WCHAR *str1, *str2;
+ SYSTEM_INFO si;
+ DWORD old_prot;
+ BOOL success;
+ char *buf;
+ int ret;
+
+ GetSystemInfo(&si);
+ buf = VirtualAlloc(NULL, si.dwPageSize * 4, MEM_COMMIT, PAGE_READWRITE);
+ ok(buf != NULL, "VirtualAlloc failed with %u\n", GetLastError());
+ success = VirtualProtect(buf + si.dwPageSize, si.dwPageSize, PAGE_NOACCESS, &old_prot);
+ ok(success, "VirtualProtect failed with %u\n", GetLastError());
+ success = VirtualProtect(buf + 3 * si.dwPageSize, si.dwPageSize, PAGE_NOACCESS, &old_prot);
+ ok(success, "VirtualProtect failed with %u\n", GetLastError());
+
+ str1 = (WCHAR *)(buf + si.dwPageSize - sizeof(WCHAR));
+ str2 = (WCHAR *)(buf + 3 * si.dwPageSize - sizeof(WCHAR));
+ *str1 = 'A';
+ *str2 = 'B';
+
+ /* CompareStringW should abort on the first non-matching character */
+ ret = CompareStringW(CP_ACP, 0, str1, 100, str2, 100);
+ ok(ret == CSTR_LESS_THAN, "expected CSTR_LESS_THAN, got %d\n", ret);
+
+ success = VirtualFree(buf, 0, MEM_RELEASE);
+ ok(success, "VirtualFree failed with %u\n", GetLastError());
+}
+
struct comparestringex_test {
const char *locale;
DWORD flags;
@@ -4791,6 +4821,7 @@ START_TEST(locale)
test_GetCurrencyFormatA(); /* Also tests the W version */
test_GetNumberFormatA(); /* Also tests the W version */
test_CompareStringA();
+ test_CompareStringW();
test_CompareStringEx();
test_LCMapStringA();
test_LCMapStringW();
More information about the wine-cvs
mailing list