Alex Henrie : msvcr90: Add tests for mbstowcs and wcstombs with a negative count.

Alexandre Julliard julliard at winehq.org
Tue Jun 14 12:04:34 CDT 2016


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

Author: Alex Henrie <alexhenrie24 at gmail.com>
Date:   Tue Jun 14 11:57:59 2016 +0200

msvcr90: Add tests for mbstowcs and wcstombs with a negative count.

Signed-off-by: Piotr Caban <piotr at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/msvcr90/tests/msvcr90.c | 69 ++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 69 insertions(+)

diff --git a/dlls/msvcr90/tests/msvcr90.c b/dlls/msvcr90/tests/msvcr90.c
index 5e16e8f..ecf25ec 100644
--- a/dlls/msvcr90/tests/msvcr90.c
+++ b/dlls/msvcr90/tests/msvcr90.c
@@ -123,6 +123,9 @@ static unsigned long (__cdecl *p_byteswap_ulong)(unsigned long);
 static void** (__cdecl *p__pxcptinfoptrs)(void);
 static void* (__cdecl *p__AdjustPointer)(void*, const void*);
 static int (__cdecl *p_fflush_nolock)(FILE*);
+static size_t (__cdecl *p_mbstowcs)(wchar_t*, const char*, size_t);
+static size_t (__cdecl *p_wcstombs)(char*, const wchar_t*, size_t);
+static char* (__cdecl *p_setlocale)(int, const char*);
 
 /* make sure we use the correct errno */
 #undef errno
@@ -383,6 +386,9 @@ static BOOL init(void)
     SET(p__pxcptinfoptrs, "__pxcptinfoptrs");
     SET(p__AdjustPointer, "__AdjustPointer");
     SET(p_fflush_nolock, "_fflush_nolock");
+    SET(p_mbstowcs, "mbstowcs");
+    SET(p_wcstombs, "wcstombs");
+    SET(p_setlocale, "setlocale");
     if (sizeof(void *) == 8)
     {
         SET(p_type_info_name_internal_method, "?_name_internal_method at type_info@@QEBAPEBDPEAU__type_info_node@@@Z");
@@ -1479,6 +1485,68 @@ static void test__AdjustPointer(void)
     }
 }
 
+static void test_mbstowcs(void)
+{
+    wchar_t bufw[16];
+    char buf[16];
+    size_t ret;
+
+    buf[0] = 'a';
+    buf[1] = 0;
+    memset(bufw, 'x', sizeof(bufw));
+    ret = p_mbstowcs(bufw, buf, -1);
+    ok(ret == 1, "ret = %d\n", (int)ret);
+    ok(bufw[0] == 'a', "bufw[0] = '%c'\n", bufw[0]);
+    ok(bufw[1] == 0, "bufw[1] = '%c'\n", bufw[1]);
+
+    memset(bufw, 'x', sizeof(bufw));
+    ret = p_mbstowcs(bufw, buf, -1000);
+    ok(ret == 1, "ret = %d\n", (int)ret);
+    ok(bufw[0] == 'a', "bufw[0] = '%c'\n", bufw[0]);
+    ok(bufw[1] == 0, "bufw[1] = '%c'\n", bufw[1]);
+
+    memset(buf, 'x', sizeof(buf));
+    ret = p_wcstombs(buf, bufw, -1);
+    ok(ret == 1, "ret = %d\n", (int)ret);
+    ok(buf[0] == 'a', "buf[0] = '%c'\n", buf[0]);
+    ok(buf[1] == 0, "buf[1] = '%c'\n", buf[1]);
+
+    memset(buf, 'x', sizeof(buf));
+    ret = p_wcstombs(buf, bufw, -1000);
+    ok(ret == 1, "ret = %d\n", (int)ret);
+    ok(buf[0] == 'a', "buf[0] = '%c'\n", buf[0]);
+    ok(buf[1] == 0, "buf[1] = '%c'\n", buf[1]);
+
+    if(!p_setlocale(LC_ALL, "English")) {
+        win_skip("English locale not available\n");
+        return;
+    }
+
+    buf[0] = 'a';
+    buf[1] = 0;
+    memset(bufw, 'x', sizeof(bufw));
+    ret = p_mbstowcs(bufw, buf, -1);
+    ok(ret == -1, "ret = %d\n", (int)ret);
+    ok(bufw[0] == 0, "bufw[0] = '%c'\n", bufw[0]);
+
+    memset(bufw, 'x', sizeof(bufw));
+    ret = p_mbstowcs(bufw, buf, -1000);
+    ok(ret == -1, "ret = %d\n", (int)ret);
+    ok(bufw[0] == 0, "bufw[0] = '%c'\n", bufw[0]);
+
+    memset(buf, 'x', sizeof(buf));
+    ret = p_wcstombs(buf, bufw, -1);
+    ok(ret == 0, "ret = %d\n", (int)ret);
+    ok(buf[0] == 0, "buf[0] = '%c'\n", buf[0]);
+
+    memset(buf, 'x', sizeof(buf));
+    ret = p_wcstombs(buf, bufw, -1000);
+    ok(ret == 0, "ret = %d\n", (int)ret);
+    ok(buf[0] == 0, "buf[0] = '%c'\n", buf[0]);
+
+    p_setlocale(LC_ALL, "C");
+}
+
 START_TEST(msvcr90)
 {
     if(!init())
@@ -1507,4 +1575,5 @@ START_TEST(msvcr90)
     test_access_s();
     test_is_exception_typeof();
     test__AdjustPointer();
+    test_mbstowcs();
 }




More information about the wine-cvs mailing list