[PATCH 1/4] msvcrt/tests: Test wcstoi64 with various Unicode digits.
Lauri Kenttä
lauri.kentta at gmail.com
Wed Jan 25 09:02:23 CST 2017
Test all Unicode digits which Windows seems to support.
"CJK Ideograph, First" is interesting to test 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).
v2:
Add U+0F20 digits and verify that the list is complete with the
following program (run under Windows to see the accepted digits):
#include <stdio.h>
#include <windows.h>
int main() {
WCHAR buf[4] = {0}, *end;
int i, nl = 0;
for (buf[0] = '0'; buf[0] != 0; ++buf[0]) {
end = buf;
i = _wcstoi64(buf, &end, 36);
if (end != buf) {
printf("U+%04X = %d\n", buf[0], i);
nl = 0;
} else if (!nl++) {
printf("\n");
}
}
return 0;
}
v3:
Test zero+10 correctly in base 16 (where it could be accepted by
accident) instead of base 10 (where it would be rejected anyway).
Also add a test for superscript one (¹).
Signed-off-by: Lauri Kenttä <lauri.kentta at gmail.com>
---
dlls/msvcrt/tests/string.c | 31 +++++++++++++++++++++++++++++++
1 file changed, 31 insertions(+)
diff --git a/dlls/msvcrt/tests/string.c b/dlls/msvcrt/tests/string.c
index 8e78695d29..c377abf4bc 100644
--- a/dlls/msvcrt/tests/string.c
+++ b/dlls/msvcrt/tests/string.c
@@ -2828,10 +2828,19 @@ 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 superscript1[] = { 0xb9, 0 }; /* SUPERSCRIPT ONE */
+ 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[] = {
+ 0x660, 0x6f0, 0x966, 0x9e6, 0xa66, 0xae6, 0xb66, 0xc66, 0xce6,
+ 0xd66, 0xe50, 0xed0, 0xf20, 0x1040, 0x17e0, 0x1810, 0xff10
+ };
+ int i;
__int64 res;
unsigned __int64 ures;
@@ -2847,6 +2856,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);
@@ -2854,8 +2865,14 @@ static void test__wcstoi64(void)
todo_wine ok(res == 9, "res != 9\n");
res = p_wcstoi64(fullwidth, NULL, 10);
todo_wine ok(res == 9, "res != 9\n");
+ res = p_wcstoi64(superscript1, NULL, 10);
+ ok(res == 0, "res != 0\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");
@@ -2869,8 +2886,22 @@ static void test__wcstoi64(void)
todo_wine ok(ures == 9, "ures != 9\n");
ures = p_wcstoui64(fullwidth, NULL, 10);
todo_wine ok(ures == 9, "ures != 9\n");
+ ures = p_wcstoui64(superscript1, NULL, 10);
+ ok(ures == 0, "ures != 0\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 = U+%04X: got %d, expected 405\n", zeros[i], (int)res);
+ tmp[1] = zeros[i] + 10;
+ res = p_wcstoi64(tmp, NULL, 16);
+ todo_wine ok(res == 4, "with zero = U+%04X: got %d, expected 4\n", zeros[i], (int)res);
+ }
return;
}
--
2.11.0
More information about the wine-patches
mailing list