[PATCH 1/3] msvcrt/tests: Test wcstoi64 with various Unicode digits.

Lauri Kenttä lauri.kentta at gmail.com
Tue Dec 13 12:48:24 CST 2016


The list of possible Unicode zeros was found here:
https://unicode-table.com/en/search/?q=%22digit+zero%22
Then I removed those that didn't work in Windows.

"CJK Ideograph, First" is interesting test case because it could be
read as 1 (in theory) but it isn't.

The two other added test strings are interesting because they show
that different kinds of digits may be mixed and that hex/oct prefix
(0x or 0) works even if the 0 is not ASCII (here tested with THAI).

Signed-off-by: Lauri Kenttä <lauri.kentta at gmail.com>
---
 dlls/msvcrt/tests/string.c | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/dlls/msvcrt/tests/string.c b/dlls/msvcrt/tests/string.c
index 8e78695..1bfd585 100644
--- a/dlls/msvcrt/tests/string.c
+++ b/dlls/msvcrt/tests/string.c
@@ -2828,10 +2828,18 @@ static void test__wcstoi64(void)
 {
     static const WCHAR digit[] = { '9', 0 };
     static const WCHAR stock[] = { 0x3231, 0 }; /* PARENTHESIZED IDEOGRAPH STOCK */
+    static const WCHAR cjk_1[] = { 0x4e00, 0 }; /* CJK Ideograph, First */
     static const WCHAR tamil[] = { 0x0bef, 0 }; /* TAMIL DIGIT NINE */
     static const WCHAR thai[]  = { 0x0e59, 0 }; /* THAI DIGIT NINE */
     static const WCHAR fullwidth[] = { 0xff19, 0 }; /* FULLWIDTH DIGIT NINE */
+    static const WCHAR minus_0x91[]  = { '-', 0x0e50, 'x', 0xff19, '1', 0 };
+    static const WCHAR plus_071[]  = { '+', 0x0e50, 0xff17, '1', 0 };
     static const WCHAR hex[] = { 0xff19, 'f', 0x0e59, 0xff46, 0 };
+    static const WCHAR zeros[] = {
+        0xe50, 0xed0, 0x1040, 0x17e0, 0x1810, 0x660, 0x6f0, 0xff10,
+        0x966, 0x9e6, 0xa66, 0xae6, 0xb66, 0xc66, 0xce6, 0xd66
+    };
+    int i;
 
     __int64 res;
     unsigned __int64 ures;
@@ -2847,6 +2855,8 @@ static void test__wcstoi64(void)
     res = p_wcstoi64(stock, &endpos, 10);
     ok(res == 0, "res != 0\n");
     ok(endpos == stock, "Incorrect endpos (%p-%p)\n", stock, endpos);
+    res = p_wcstoi64(cjk_1, NULL, 0);
+    ok(res == 0, "res != 0\n");
     res = p_wcstoi64(tamil, &endpos, 10);
     ok(res == 0, "res != 0\n");
     ok(endpos == tamil, "Incorrect endpos (%p-%p)\n", tamil, endpos);
@@ -2856,6 +2866,10 @@ static void test__wcstoi64(void)
     todo_wine ok(res == 9, "res != 9\n");
     res = p_wcstoi64(hex, NULL, 16);
     todo_wine ok(res == 0x9f9, "res != 0x9f9\n");
+    res = p_wcstoi64(minus_0x91, NULL, 0);
+    todo_wine ok(res == -0x91, "res != -0x91\n");
+    res = p_wcstoi64(plus_071, NULL, 0);
+    todo_wine ok(res == 071, "res != 071\n");
 
     ures = p_wcstoui64(digit, NULL, 10);
     ok(ures == 9, "ures != 9\n");
@@ -2871,6 +2885,15 @@ static void test__wcstoi64(void)
     todo_wine ok(ures == 9, "ures != 9\n");
     ures = p_wcstoui64(hex, NULL, 16);
     todo_wine ok(ures == 0x9f9, "ures != 0x9f9\n");
+    ures = p_wcstoui64(plus_071, NULL, 0);
+    todo_wine ok(ures == 071, "ures != 071\n");
+
+    /* Test various unicode digits */
+    for (i = 0; i < sizeof(zeros) / sizeof(zeros[0]); ++i) {
+        WCHAR tmp[] = {zeros[i]+4, zeros[i], zeros[i]+5, 0};
+        res = p_wcstoi64(tmp, NULL, 0);
+        todo_wine ok(res == 405, "with zero = %#x: got %d, expected 405\n", zeros[i], (int)res);
+    }
 
     return;
 }
-- 
2.10.2




More information about the wine-patches mailing list