From: Daniel Lehman dlehman25@gmail.com
--- dlls/msvcrt/tests/string.c | 84 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+)
diff --git a/dlls/msvcrt/tests/string.c b/dlls/msvcrt/tests/string.c index a14e95704f3..24902d96f27 100644 --- a/dlls/msvcrt/tests/string.c +++ b/dlls/msvcrt/tests/string.c @@ -4227,6 +4227,89 @@ static void test__tcsncoll(void) } }
+static void test__tcscoll(void) +{ + struct test { + const char *locale; + const char *str1; + const char *str2; + int exp; + BOOL todo; + }; + static const struct test tests[] = { + { "English", "ABCD", "ABCD", 0 }, + { "English", "ABC", "ABCD", -1 }, + { "English", "ABCD", "ABC", 1 }, + { "English", "ABCe", "ABCf", -1 }, + { "English", "abcd", "ABCD", -1 }, + { "English", "AB D", "AB-D", 1, TRUE }, + { "English", "AB D", "AB'D", 1, TRUE }, + + { "C", "ABCD", "ABCD", 0 }, + { "C", "ABC", "ABCD", -1 }, + { "C", "ABCD", "ABC", 1 }, + { "C", "ABCe", "ABCf", -1 }, + { "C", "abcd", "ABCD", 1 }, + { "C", "AB D", "AB-D", -1 }, + { "C", "AB D", "AB'D", -1 }, + }; + WCHAR str1W[16]; + WCHAR str2W[16]; + char str1[16]; + char str2[16]; + size_t len; + int i, ret; + + for (i = 0; i < ARRAY_SIZE(tests); i++) + { + if (!setlocale(LC_ALL, tests[i].locale)) + { + win_skip("%s locale _tcsncoll tests\n", tests[i].locale); + for (; i+1 < ARRAY_SIZE(tests); i++) + if (strcmp(tests[i].locale, tests[i+1].locale)) break; + continue; + } + + memset(str1, 0xee, sizeof(str1)); + strcpy(str1, tests[i].str1); + + memset(str2, 0xff, sizeof(str2)); + strcpy(str2, tests[i].str2); + + ret = strcoll(str1, str2); + if (!tests[i].exp) + ok(!ret, "expected 0, got %d for %s, %s for locale %s\n", + ret, str1, str2, tests[i].locale); + else if (tests[i].exp < 0) + ok(ret < 0, "expected < 0, got %d for %s, %s for locale %s\n", + ret, str1, str2, tests[i].locale); + else + todo_wine_if(tests[i].todo) + ok(ret > 0, "expected > 0, got %d for %s, %s for locale %s\n", + ret, str1, str2, tests[i].locale); + + memset(str1W, 0xee, sizeof(str1W)); + len = mbstowcs(str1W, str1, ARRAY_SIZE(str1W)); + str1W[len] = 0; + + memset(str2W, 0xff, sizeof(str2W)); + len = mbstowcs(str2W, str2, ARRAY_SIZE(str2W)); + str2W[len] = 0; + + ret = wcscoll(str1W, str2W); + if (!tests[i].exp) + ok(!ret, "expected 0, got %d for %s, %s for locale %s\n", + ret, str1, str2, tests[i].locale); + else if (tests[i].exp < 0) + ok(ret < 0, "expected < 0, got %d for %s, %s for locale %s\n", + ret, str1, str2, tests[i].locale); + else + todo_wine_if(tests[i].todo) + ok(ret > 0, "expected > 0, got %d for %s, %s for locale %s\n", + ret, str1, str2, tests[i].locale); + } +} + static void test__tcsnicoll(void) { struct test { @@ -4854,6 +4937,7 @@ START_TEST(string) test__memicmp_l(); test__strupr(); test__tcsncoll(); + test__tcscoll(); test__tcsnicoll(); test___strncnt(); test_C_locale();
From: Daniel Lehman dlehman25@gmail.com
--- dlls/msvcrt/string.c | 3 ++- dlls/msvcrt/tests/string.c | 7 ++----- dlls/msvcrt/wcs.c | 3 ++- 3 files changed, 6 insertions(+), 7 deletions(-)
diff --git a/dlls/msvcrt/string.c b/dlls/msvcrt/string.c index e6323da3b01..7f7959e81e6 100644 --- a/dlls/msvcrt/string.c +++ b/dlls/msvcrt/string.c @@ -1162,7 +1162,8 @@ int CDECL _strcoll_l( const char* str1, const char* str2, _locale_t locale )
if(!locinfo->lc_handle[LC_COLLATE]) return strcmp(str1, str2); - return CompareStringA(locinfo->lc_handle[LC_COLLATE], 0, str1, -1, str2, -1)-CSTR_EQUAL; + return CompareStringA(locinfo->lc_handle[LC_COLLATE], SORT_STRINGSORT, + str1, -1, str2, -1)-CSTR_EQUAL; }
/********************************************************************* diff --git a/dlls/msvcrt/tests/string.c b/dlls/msvcrt/tests/string.c index 24902d96f27..23f4205e785 100644 --- a/dlls/msvcrt/tests/string.c +++ b/dlls/msvcrt/tests/string.c @@ -4234,7 +4234,6 @@ static void test__tcscoll(void) const char *str1; const char *str2; int exp; - BOOL todo; }; static const struct test tests[] = { { "English", "ABCD", "ABCD", 0 }, @@ -4242,8 +4241,8 @@ static void test__tcscoll(void) { "English", "ABCD", "ABC", 1 }, { "English", "ABCe", "ABCf", -1 }, { "English", "abcd", "ABCD", -1 }, - { "English", "AB D", "AB-D", 1, TRUE }, - { "English", "AB D", "AB'D", 1, TRUE }, + { "English", "AB D", "AB-D", 1 }, + { "English", "AB D", "AB'D", 1 },
{ "C", "ABCD", "ABCD", 0 }, { "C", "ABC", "ABCD", -1 }, @@ -4284,7 +4283,6 @@ static void test__tcscoll(void) ok(ret < 0, "expected < 0, got %d for %s, %s for locale %s\n", ret, str1, str2, tests[i].locale); else - todo_wine_if(tests[i].todo) ok(ret > 0, "expected > 0, got %d for %s, %s for locale %s\n", ret, str1, str2, tests[i].locale);
@@ -4304,7 +4302,6 @@ static void test__tcscoll(void) ok(ret < 0, "expected < 0, got %d for %s, %s for locale %s\n", ret, str1, str2, tests[i].locale); else - todo_wine_if(tests[i].todo) ok(ret > 0, "expected > 0, got %d for %s, %s for locale %s\n", ret, str1, str2, tests[i].locale); } diff --git a/dlls/msvcrt/wcs.c b/dlls/msvcrt/wcs.c index af684e6be2e..1b7bc3e54e0 100644 --- a/dlls/msvcrt/wcs.c +++ b/dlls/msvcrt/wcs.c @@ -1994,7 +1994,8 @@ int CDECL _wcscoll_l(const wchar_t* str1, const wchar_t* str2, _locale_t locale)
if(!locinfo->lc_handle[LC_COLLATE]) return wcscmp(str1, str2); - return CompareStringW(locinfo->lc_handle[LC_COLLATE], 0, str1, -1, str2, -1)-CSTR_EQUAL; + return CompareStringW(locinfo->lc_handle[LC_COLLATE], SORT_STRINGSORT, + str1, -1, str2, -1)-CSTR_EQUAL; }
/*********************************************************************
This merge request was approved by Piotr Caban.