Changhui Liu : kernel32/tests: Add tests for MultiByteToWideChar in DBCS codepage.

Alexandre Julliard julliard at wine.codeweavers.com
Mon Feb 8 10:09:21 CST 2016


Module: wine
Branch: master
Commit: e776421232996729a0e350c31d56f696bd47e429
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=e776421232996729a0e350c31d56f696bd47e429

Author: Changhui Liu <liuchanghui at linuxdeepin.com>
Date:   Sat Feb  6 14:09:13 2016 +0800

kernel32/tests: Add tests for MultiByteToWideChar in DBCS codepage.

Signed-off-by: Changhui Liu <liuchanghui at linuxdeepin.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/kernel32/tests/codepage.c | 60 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 60 insertions(+)

diff --git a/dlls/kernel32/tests/codepage.c b/dlls/kernel32/tests/codepage.c
index 6718a3b..7293acc 100644
--- a/dlls/kernel32/tests/codepage.c
+++ b/dlls/kernel32/tests/codepage.c
@@ -1136,6 +1136,64 @@ static void test_threadcp(void)
     SetThreadLocale(last);
 }
 
+static void test_dbcs_to_widechar(void)
+{
+    int i, count, count2;
+    WCHAR wbuf[2];
+    unsigned char buf[] = {0xbf, 0xb4, 0xc7};
+    static const DWORD flags[] = {
+        MB_PRECOMPOSED,
+        MB_COMPOSITE,
+
+        MB_PRECOMPOSED|MB_USEGLYPHCHARS,
+        MB_COMPOSITE  |MB_USEGLYPHCHARS,
+
+        MB_PRECOMPOSED|MB_ERR_INVALID_CHARS,
+        MB_COMPOSITE  |MB_ERR_INVALID_CHARS,
+
+        MB_PRECOMPOSED|MB_ERR_INVALID_CHARS|MB_USEGLYPHCHARS,
+        MB_COMPOSITE  |MB_ERR_INVALID_CHARS|MB_USEGLYPHCHARS,
+    };
+
+    for (i = 0; i < sizeof(flags)/sizeof(DWORD); ++i)
+    {
+        wbuf[0] = 0xffff;
+        wbuf[1] = 0xffff;
+        count = MultiByteToWideChar(936, flags[i], (char*)&buf[0], 2, NULL, 0);
+        count2 = MultiByteToWideChar(936, flags[i], (char*)&buf[0], 2, wbuf, count);
+
+        ok(count == 1, "%04x: returned %d (expected 1)\n", flags[i], count);
+        ok(count2 == 1, "%04x: returned %d (expected 1)\n", flags[i], count2);
+        ok(wbuf[0] == 0x770b, "%04x: returned %04x (expected 770b)\n", flags[i], wbuf[0]);
+        ok(wbuf[1] == 0xffff, "%04x: returned %04x (expected ffff)\n", flags[i], wbuf[1]);
+    }
+
+    for (i = 0; i < sizeof(flags)/sizeof(DWORD); ++i)
+    {
+        wbuf[0] = 0xffff;
+        wbuf[1] = 0xffff;
+        count = MultiByteToWideChar(936, flags[i], (char*)&buf[0], 3, NULL, 0);
+        SetLastError( 0xdeadbeef );
+        count2 = MultiByteToWideChar(936, flags[i], (char*)&buf[0], 3, wbuf, count);
+
+        if (flags[i] & MB_ERR_INVALID_CHARS)
+        {
+            ok(count == 0, "%04x: returned %d (expected 0)\n", flags[i], count);
+            ok(count2 == 0, "%04x: returned %d (expected 0)\n", flags[i], count2);
+            ok(GetLastError() == ERROR_NO_UNICODE_TRANSLATION, "%04x: returned %d (expected %d)\n",
+               flags[i], GetLastError(), ERROR_NO_UNICODE_TRANSLATION);
+        }
+        else
+        {
+            todo_wine ok(count == 2, "%04x: returned %d (expected 2)\n", flags[i], count);
+            todo_wine ok(count2 == 2, "%04x: returned %d (expected 2)\n", flags[i], count2);
+            ok(wbuf[0] == 0x770b, "%04x: returned %04x (expected 770b)\n", flags[i], wbuf[0]);
+            todo_wine ok(wbuf[1] == 0x003f || broken(wbuf[1] == 0)/*windows xp*/,
+                    "%04x: wrong wide char: %04x\n", flags[i], wbuf[1]);
+        }
+    }
+}
+
 START_TEST(codepage)
 {
     BOOL bUsedDefaultChar;
@@ -1156,4 +1214,6 @@ START_TEST(codepage)
 
     test_undefined_byte_char();
     test_threadcp();
+
+    test_dbcs_to_widechar();
 }




More information about the wine-cvs mailing list