|
|
@@ -17,11 +17,29 @@ namespace UnicodeTextTest
|
|
|
REQUIRE(g_testHooksLoaded);
|
|
|
|
|
|
// there are two tests, one to validate the expected value and validate the result of the call
|
|
|
- int compareStringResult = CompareStringW(LOCALE_USER_DEFAULT, NORM_IGNORECASE | SORT_DIGITSASNUMBERS, str1, -1, str2, -1);
|
|
|
+ int compareStringResult = CompareStringEx(LOCALE_NAME_USER_DEFAULT, NORM_IGNORECASE | SORT_DIGITSASNUMBERS, str1, -1, str2, -1, NULL, NULL, 0);
|
|
|
CHECK(compareStringResult != 0);
|
|
|
compareStringResult = compareStringResult - CSTR_EQUAL;
|
|
|
|
|
|
- int res = g_testHooks.pfLogicalCompareStringImpl(str1, str2);
|
|
|
+ int res = g_testHooks.pfLogicalCompareStringImpl(str1, static_cast<int>(wcslen(str1)), str2, static_cast<int>(wcslen(str2)));
|
|
|
+
|
|
|
+ //test to check that expected value passed is correct
|
|
|
+ REQUIRE(compareStringResult == expected);
|
|
|
+
|
|
|
+ //test to check that the result from call to LogicalStringCompareImpl is the expected value
|
|
|
+ REQUIRE(res == expected);
|
|
|
+ }
|
|
|
+
|
|
|
+ void TestNullCharacters(const WCHAR* str1, int str1size, const WCHAR* str2, int str2size, int expected)
|
|
|
+ {
|
|
|
+ REQUIRE(g_testHooksLoaded);
|
|
|
+
|
|
|
+ // there are two tests, one to validate the expected value and validate the result of the call
|
|
|
+ int compareStringResult = CompareStringEx(LOCALE_NAME_USER_DEFAULT, NORM_IGNORECASE | SORT_DIGITSASNUMBERS, str1, str1size, str2, str2size, NULL, NULL, 0);
|
|
|
+ CHECK(compareStringResult != 0);
|
|
|
+ compareStringResult = compareStringResult - CSTR_EQUAL;
|
|
|
+
|
|
|
+ int res = g_testHooks.pfLogicalCompareStringImpl(str1, str1size, str2, str2size);
|
|
|
|
|
|
//test to check that expected value passed is correct
|
|
|
REQUIRE(compareStringResult == expected);
|
|
|
@@ -88,4 +106,10 @@ namespace UnicodeTextTest
|
|
|
Test(_u("20sTRing"), _u("st2ring"), -1);
|
|
|
Test(_u("st3rING"), _u("st2riNG"), 1);
|
|
|
}
|
|
|
+
|
|
|
+ TEST_CASE("LogicalCompareString_EmbeddedNullCharacters", "[UnicodeText]")
|
|
|
+ {
|
|
|
+ TestNullCharacters(_u("\0\0ab\0\0c123def\0\0"), 15, _u("abc123def"), 9, 0);
|
|
|
+ }
|
|
|
+
|
|
|
}
|