Daniel Lehman : msvcrt/tests: Add tests for _strncoll/_wcsncoll.
Alexandre Julliard
julliard at winehq.org
Mon Aug 20 13:26:10 CDT 2018
Module: wine
Branch: master
Commit: 9aa7a42a9f1b750e91007ff722a3a7867e4f35e9
URL: https://source.winehq.org/git/wine.git/?a=commit;h=9aa7a42a9f1b750e91007ff722a3a7867e4f35e9
Author: Daniel Lehman <dlehman at esri.com>
Date: Fri Aug 17 18:51:17 2018 +0200
msvcrt/tests: Add tests for _strncoll/_wcsncoll.
Signed-off-by: Daniel Lehman <dlehman at esri.com>
Signed-off-by: Piotr Caban <piotr at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/msvcrt/tests/string.c | 86 ++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 86 insertions(+)
diff --git a/dlls/msvcrt/tests/string.c b/dlls/msvcrt/tests/string.c
index 744035a..86f49db 100644
--- a/dlls/msvcrt/tests/string.c
+++ b/dlls/msvcrt/tests/string.c
@@ -3387,6 +3387,91 @@ static void test__strupr(void)
VirtualFree(mem, sizeof(str), MEM_RELEASE);
}
+static void test__tcsncoll(void)
+{
+ struct test {
+ const char *locale;
+ const char *str1;
+ const char *str2;
+ size_t count;
+ int exp;
+ };
+ static const struct test tests[] = {
+ { "English", "ABCD", "ABCD", 4, 0 },
+ { "English", "ABCD", "ABCD", 10, 0 },
+
+ { "English", "ABC", "ABCD", 3, 0 },
+ { "English", "ABC", "ABCD", 4, -1 },
+ { "English", "ABC", "ABCD", 10, -1 },
+
+ { "English", "ABCD", "ABC", 3, 0 },
+ { "English", "ABCD", "ABC", 4, 1 },
+ { "English", "ABCD", "ABC", 10, 1 },
+
+ { "English", "ABCe", "ABCf", 3, 0 },
+ { "English", "abcd", "ABCD", 10, -1 },
+
+ { "C", "ABCD", "ABCD", 4, 0 },
+ { "C", "ABCD", "ABCD", 10, 0 },
+
+ { "C", "ABC", "ABCD", 3, 0 },
+ { "C", "ABC", "ABCD", 10, -1 },
+
+ { "C", "ABCD", "ABC", 3, 0 },
+ { "C", "ABCD", "ABC", 10, 1 },
+
+ { "C", "ABCe", "ABCf", 3, 0 },
+ { "C", "abcd", "ABCD", 10, 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 = _strncoll(str1, str2, tests[i].count);
+ if (!tests[i].exp)
+ ok(!ret, "expected 0, got %d for %s, %s, %d\n", ret, str1, str2, (int)tests[i].count);
+ else if (tests[i].exp < 0)
+ ok(ret < 0, "expected < 0, got %d for %s, %s, %d\n", ret, str1, str2, (int)tests[i].count);
+ else
+ ok(ret > 0, "expected > 0, got %d for %s, %s, %d\n", ret, str1, str2, (int)tests[i].count);
+
+ 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 = _wcsncoll(str1W, str2W, tests[i].count);
+ if (!tests[i].exp)
+ ok(!ret, "expected 0, got %d for %s, %s, %d\n", ret, str1, str2, (int)tests[i].count);
+ else if (tests[i].exp < 0)
+ ok(ret < 0, "expected < 0, got %d for %s, %s, %d\n", ret, str1, str2, (int)tests[i].count);
+ else
+ ok(ret > 0, "expected > 0, got %d for %s, %s, %d\n", ret, str1, str2, (int)tests[i].count);
+ }
+}
+
START_TEST(string)
{
char mem[100];
@@ -3510,4 +3595,5 @@ START_TEST(string)
test__memicmp();
test__memicmp_l();
test__strupr();
+ test__tcsncoll();
}
More information about the wine-cvs
mailing list