[MSVCRT_WINETEST] Sync with Wine Staging 2.9. CORE-13362
[reactos.git] / rostests / winetests / msvcrt / string.c
index 187d2b9..a59ed91 100644 (file)
@@ -58,6 +58,7 @@ static int (__cdecl *p_memmove_s)(void *, size_t, const void *, size_t);
 static int* (__cdecl *pmemcmp)(void *, const void *, size_t n);
 static int (__cdecl *pstrcpy_s)(char *dst, size_t len, const char *src);
 static int (__cdecl *pstrcat_s)(char *dst, size_t len, const char *src);
+static int (__cdecl *p_mbscat_s)(unsigned char *dst, size_t size, const unsigned char *src);
 static int (__cdecl *p_mbsnbcat_s)(unsigned char *dst, size_t size, const unsigned char *src, size_t count);
 static int (__cdecl *p_mbsnbcpy_s)(unsigned char * dst, size_t size, const unsigned char * src, size_t count);
 static int (__cdecl *p__mbscpy_s)(unsigned char*, size_t, const unsigned char*);
@@ -73,6 +74,7 @@ static unsigned __int64 (__cdecl *p_wcstoui64)(const wchar_t *, wchar_t **, int)
 static int (__cdecl *pwcstombs_s)(size_t*,char*,size_t,const wchar_t*,size_t);
 static int (__cdecl *pmbstowcs_s)(size_t*,wchar_t*,size_t,const char*,size_t);
 static size_t (__cdecl *p_mbsrtowcs)(wchar_t*, const char**, size_t, mbstate_t*);
+static int (__cdecl *p_mbsrtowcs_s)(size_t*,wchar_t*,size_t,const char**,size_t,mbstate_t*);
 static size_t (__cdecl *pwcsrtombs)(char*, const wchar_t**, size_t, int*);
 static errno_t (__cdecl *p_gcvt_s)(char*,size_t,double,int);
 static errno_t (__cdecl *p_itoa_s)(int,char*,size_t,int);
@@ -732,6 +734,86 @@ static void test_strcat_s(void)
     ok(ret == EINVAL, "strcat_s: Writing to a NULL string returned %d, expected EINVAL\n", ret);
 }
 
+static void test__mbscat_s(void)
+{
+    unsigned char dst[8], src[4];
+    int err;
+    int prev_cp = _getmbcp();
+
+    if(!p_mbscat_s)
+    {
+        win_skip("_mbscat_s not found\n");
+        return;
+    }
+
+
+    src[0] = dst[0] = 0;
+    err = p_mbscat_s(NULL, sizeof(dst), src);
+    ok(err == EINVAL, "_mbscat_s returned %d\n", err);
+
+    err = p_mbscat_s(dst, sizeof(dst), NULL);
+    ok(err == EINVAL, "_mbscat_s returned %d\n", err);
+
+    dst[0] = 'a';
+    err = p_mbscat_s(dst, 1, src);
+    ok(err == EINVAL, "_mbscat_s returned %d\n", err);
+
+    memset(dst, 'a', sizeof(dst));
+    dst[6] = 0;
+    src[0] = 'b';
+    src[1] = 0;
+
+    err = p_mbscat_s(dst, sizeof(dst), src);
+    ok(err == 0, "_mbscat_s returned %d\n", err);
+    ok(!memcmp(dst, "aaaaaab", 8), "dst = %s\n", dst);
+
+    err = p_mbscat_s(dst, sizeof(dst), src);
+    ok(err == ERANGE, "_mbscat_s returned %d\n", err);
+    ok(!dst[0], "dst[0] = %c\n", dst[0]);
+    ok(dst[1] == 'a', "dst[1] = %c\n", dst[1]);
+
+    _setmbcp(932);
+    /* test invalid str in dst */
+    dst[0] = 0x81;
+    dst[1] = 0x81;
+    dst[2] = 0x52;
+    dst[3] = 0;
+    src[0] = 'a';
+    src[1] = 0;
+    err = p_mbscat_s(dst, sizeof(dst), src);
+    ok(err == 0, "_mbscat_s returned %d\n", err);
+
+    /* test invalid str in src */
+    dst[0] = 0;
+    src[0] = 0x81;
+    src[1] = 0x81;
+    src[2] = 0x52;
+    src[3] = 0;
+    err = p_mbscat_s(dst, sizeof(dst), src);
+    ok(err == 0, "_mbscat_s returned %d\n", err);
+
+    /* test dst with leading byte on the end of buffer */
+    dst[0] = 'a';
+    dst[1] = 0x81;
+    dst[2] = 0;
+    src[0] = 'R';
+    src[1] = 0;
+    err = p_mbscat_s(dst, sizeof(dst), src);
+    ok(err == EILSEQ, "_mbscat_s returned %d\n", err);
+    ok(!memcmp(dst, "aR", 3), "dst = %s\n", dst);
+
+    /* test src with leading byte on the end of buffer */
+    dst[0] = 'a';
+    dst[1] = 0;
+    src[0] = 'b';
+    src[1] = 0x81;
+    src[2] = 0;
+    err = p_mbscat_s(dst, sizeof(dst), src);
+    ok(err == EILSEQ, "_mbscat_s returned %d\n", err);
+    ok(!memcmp(dst, "ab", 3), "dst = %s\n", dst);
+    _setmbcp(prev_cp);
+}
+
 static void test__mbsnbcpy_s(void)
 {
     unsigned char dest[8];
@@ -1027,7 +1109,7 @@ static void test__wcslwr_s(void)
 
     /* Test NULL input string and valid size. */
     errno = EBADF;
-    ret = p_wcslwr_s(NULL, sizeof(buffer)/sizeof(wchar_t));
+    ret = p_wcslwr_s(NULL, sizeof(buffer)/sizeof(buffer[0]));
     ok(ret == EINVAL, "expected EINVAL, got %d\n", ret);
     ok(errno == EINVAL, "expected errno EINVAL, got %d\n", errno);
 
@@ -1144,6 +1226,65 @@ static void test_mbcjmsjis(void)
     _setmbcp(prev_cp);
 }
 
+static void test_mbctohira(void)
+{
+    static const unsigned int mbchira_932[][2] = {
+        {0x8152, 0x8152}, {0x8153, 0x8153}, {0x8154, 0x8154}, {0x8155, 0x8155},
+        {0x82a0, 0x82a0}, {0x833f, 0x833f}, {0x8340, 0x829f}, {0x837e, 0x82dd},
+        {0x837f, 0x837f}, {0x8380, 0x82de}, {0x8393, 0x82f1}, {0x8394, 0x8394},
+        {0x8396, 0x8396}, {0x8397, 0x8397},
+        {0xa5, 0xa5}, {0xb0, 0xb0}, {0xdd, 0xdd} };
+    unsigned int i;
+    unsigned int prev_cp = _getmbcp();
+
+    _setmbcp(_MB_CP_SBCS);
+    for (i = 0; i < sizeof(mbchira_932)/sizeof(mbchira_932[0]); i++)
+    {
+        int ret, exp = mbchira_932[i][0];
+        ret = _mbctohira(mbchira_932[i][0]);
+        ok(ret == exp, "Expected 0x%x, got 0x%x\n", exp, ret);
+    }
+
+    _setmbcp(932);
+    for (i = 0; i < sizeof(mbchira_932)/sizeof(mbchira_932[0]); i++)
+    {
+        unsigned int ret, exp;
+        ret = _mbctohira(mbchira_932[i][0]);
+        exp = mbchira_932[i][1];
+        ok(ret == exp, "Expected 0x%x, got 0x%x\n", exp, ret);
+    }
+    _setmbcp(prev_cp);
+}
+
+static void test_mbctokata(void)
+{
+    static const unsigned int mbckata_932[][2] = {
+        {0x8152, 0x8152}, {0x8153, 0x8153}, {0x8154, 0x8154}, {0x8155, 0x8155},
+        {0x833f, 0x833f}, {0x829f, 0x8340}, {0x82dd, 0x837e}, {0x837f, 0x837f},
+        {0x82de, 0x8380}, {0x8394, 0x8394}, {0x8397, 0x8397},
+        {0xa5, 0xa5}, {0xb0, 0xb0}, {0xdd, 0xdd} };
+    unsigned int i;
+    unsigned int prev_cp = _getmbcp();
+
+    _setmbcp(_MB_CP_SBCS);
+    for (i = 0; i < sizeof(mbckata_932)/sizeof(mbckata_932[0]); i++)
+    {
+        int ret, exp = mbckata_932[i][0];
+        ret = _mbctokata(mbckata_932[i][0]);
+        ok(ret == exp, "Expected 0x%x, got 0x%x\n", exp, ret);
+    }
+
+    _setmbcp(932);
+    for (i = 0; i < sizeof(mbckata_932)/sizeof(mbckata_932[0]); i++)
+    {
+        unsigned int ret, exp;
+        ret = _mbctokata(mbckata_932[i][0]);
+        exp = mbckata_932[i][1];
+        ok(ret == exp, "Expected 0x%x, got 0x%x\n", exp, ret);
+    }
+    _setmbcp(prev_cp);
+}
+
 static void test_mbbtombc(void)
 {
     static const unsigned int mbbmbc[][2] = {
@@ -1192,6 +1333,37 @@ static void test_mbctombb(void)
     _setmbcp(prev_cp);
 }
 
+static void test_ismbckata(void) {
+    struct katakana_pair {
+        UINT c;
+        BOOL exp;
+    };
+    static const struct katakana_pair tests[] = {
+        {0x8152, FALSE}, {0x8153, FALSE}, {0x8154, FALSE}, {0x8155, FALSE},
+        {0x82a0, FALSE}, {0x833f, FALSE}, {0x8340, TRUE }, {0x837e, TRUE },
+        {0x837f, FALSE}, {0x8380, TRUE }, {0x8396, TRUE }, {0x8397, FALSE},
+        {0xa5, FALSE}, {0xb0, FALSE}, {0xdd, FALSE}
+    };
+    unsigned int prev_cp = _getmbcp();
+    int ret;
+    unsigned int i;
+
+    _setmbcp(_MB_CP_SBCS);
+    for (i = 0; i < sizeof(tests)/sizeof(tests[0]); i++) {
+        ret = _ismbckata(tests[i].c);
+        ok(!ret, "expected 0, got %d for %04x\n", ret, tests[i].c);
+    }
+
+    _setmbcp(932);
+    for (i = 0; i < sizeof(tests)/sizeof(tests[0]); i++) {
+        ret = _ismbckata(tests[i].c);
+        ok(!!ret == tests[i].exp, "expected %d, got %d for %04x\n",
+           tests[i].exp, !!ret, tests[i].c);
+    }
+
+    _setmbcp(prev_cp);
+}
+
 static void test_ismbclegal(void) {
     unsigned int prev_cp = _getmbcp();
     int ret, exp, err;
@@ -1313,6 +1485,8 @@ static void test_strtok(void)
 
 static void test_strtol(void)
 {
+    static char neg[] = "-0x";
+
     char* e;
     LONG l;
     ULONG ul;
@@ -1369,6 +1543,12 @@ static void test_strtol(void)
     ul = strtoul("-4294967296", NULL, 0);
     ok(ul == 1, "wrong value %u\n", ul);
     ok(errno == ERANGE, "wrong errno %d\n", errno);
+
+    errno = 0;
+    l = strtol(neg, &e, 0);
+    ok(l == 0, "wrong value %d\n", l);
+    ok(errno == 0, "wrong errno %d\n", errno);
+    ok(e == neg, "e = %p, neg = %p\n", e, neg);
 }
 
 static void test_strnlen(void)
@@ -1549,6 +1729,7 @@ static void test__strtod(void)
     const char double3[] = "INF";
     const char double4[] = ".21e12";
     const char double5[] = "214353e-3";
+    const char double6[] = "NAN";
     const char overflow[] = "1d9999999999999999999";
     const char white_chars[] = "  d10";
 
@@ -1575,6 +1756,10 @@ static void test__strtod(void)
     ok(almost_equal(d, 214.353), "d = %lf\n", d);
     ok(end == double5+9, "incorrect end (%d)\n", (int)(end-double5));
 
+    d = strtod(double6, &end);
+    ok(almost_equal(d, 0), "d = %lf\n", d);
+    ok(end == double6, "incorrect end (%d)\n", (int)(end-double6));
+
     d = strtod("12.1d2", NULL);
     ok(almost_equal(d, 12.1e2), "d = %lf\n", d);
 
@@ -1588,7 +1773,7 @@ static void test__strtod(void)
     {
         errno = EBADF;
         d = strtod(NULL, NULL);
-        ok(almost_equal(d, 0.0), "d =  %lf\n", d);
+        ok(almost_equal(d, 0.0), "d = %lf\n", d);
         ok(errno == EINVAL, "errno = %x\n", errno);
 
         errno = EBADF;
@@ -1762,6 +1947,11 @@ static void test_mbstowcs(void)
         return;
     }
 
+    pmbstr = mHiragana;
+    ret = p_mbsrtowcs(NULL, &pmbstr, 6, NULL);
+    ok(ret == 2, "mbsrtowcs did not return 2\n");
+    ok(pmbstr == mHiragana, "pmbstr = %p, expected %p\n", pmbstr, mHiragana);
+
     pmbstr = mHiragana;
     ret = p_mbsrtowcs(wOut, &pmbstr, 6, NULL);
     ok(ret == 2, "mbsrtowcs did not return 2\n");
@@ -1782,6 +1972,54 @@ static void test_mbstowcs(void)
     ok(ret == -1, "mbsrtowcs did not return -1\n");
     ok(errno == EINVAL, "Expected errno to be EINVAL, got %d\n", errno);
 
+    if(!p_mbsrtowcs_s) {
+        setlocale(LC_ALL, "C");
+        win_skip("mbsrtowcs_s not available\n");
+        return;
+    }
+
+    pmbstr = mHiragana;
+    err = p_mbsrtowcs_s(&ret, NULL, 0, NULL, 6, NULL);
+    ok(ret == -1, "mbsrtowcs_s did not return -1\n");
+    ok(err == EINVAL, "err = %d\n", err);
+    err = p_mbsrtowcs_s(&ret, NULL, 1, &pmbstr, 6, NULL);
+    ok(ret == -1, "mbsrtowcs_s did not return -1\n");
+    ok(err == EINVAL, "err = %d\n", err);
+    err = p_mbsrtowcs_s(&ret, wOut, 0, &pmbstr, 6, NULL);
+    ok(ret == -1, "mbsrtowcs_s did not return -1\n");
+    ok(err == EINVAL, "err = %d\n", err);
+
+    pmbstr = mHiragana;
+    errno = 0;
+    err = p_mbsrtowcs_s(&ret, NULL, 0, &pmbstr, 6, NULL);
+    ok(ret == 3, "mbsrtowcs_s did not return 3\n");
+    ok(err == 0, "err = %d\n", err);
+    ok(pmbstr == mHiragana, "pmbstr = %p, expected %p\n", pmbstr, mHiragana);
+    ok(errno == 0, "errno = %d\n", errno);
+
+    pmbstr = mHiragana;
+    err = p_mbsrtowcs_s(&ret, wOut, 1, &pmbstr, 6, NULL);
+    ok(ret == 2, "mbsrtowcs_s did not return 2\n");
+    ok(err == 0, "err = %d\n", err);
+    ok(!wOut[0], "wOut[0] = '%c'\n", wOut[0]);
+    ok(pmbstr == mHiragana+2, "pmbstr = %p, expected %p\n", pmbstr, mHiragana+2);
+    ok(errno == 0, "errno = %d\n", errno);
+
+    pmbstr = mHiragana;
+    err = p_mbsrtowcs_s(&ret, wOut, 2, &pmbstr, 6, NULL);
+    ok(ret == 3, "mbsrtowcs_s did not return 3\n");
+    ok(err == 0, "err = %d\n", err);
+    ok(!wOut[0], "wOut[0] = '%c'\n", wOut[0]);
+    ok(pmbstr == mHiragana+4, "pmbstr = %p, expected %p\n", pmbstr, mHiragana+4);
+    ok(errno == 0, "errno = %d\n", errno);
+
+    pmbstr = mHiragana;
+    err = p_mbsrtowcs_s(&ret, wOut, 3, &pmbstr, 6, NULL);
+    ok(ret == 3, "mbsrtowcs_s did not return 3\n");
+    ok(err == 0, "err = %d\n", err);
+    ok(!pmbstr, "pmbstr != NULL\n");
+    ok(errno == 0, "errno = %d\n", errno);
+
     setlocale(LC_ALL, "C");
 }
 
@@ -2424,6 +2662,7 @@ static void test_wctomb(void)
 
 static void test_tolower(void)
 {
+    WCHAR chw, lower;
     char ch, lch;
     int ret, len;
 
@@ -2454,7 +2693,10 @@ static void test_tolower(void)
     ch = 0xF4;
     errno = 0xdeadbeef;
     ret = p_tolower(ch);
-    len = LCMapStringA(0, LCMAP_LOWERCASE, &ch, 1, &lch, 1);
+    if(!MultiByteToWideChar(CP_ACP, MB_ERR_INVALID_CHARS, &ch, 1, &chw, 1) ||
+            LCMapStringW(CP_ACP, LCMAP_LOWERCASE, &chw, 1, &lower, 1) != 1 ||
+            (len = WideCharToMultiByte(CP_ACP, 0, &lower, 1, &lch, 1, NULL, NULL)) != 1)
+        len = 0;
     if(len)
         ok(ret==(unsigned char)lch || broken(ret==ch)/*WinXP-*/, "ret = %x\n", ret);
     else
@@ -2465,7 +2707,10 @@ static void test_tolower(void)
     ch = 0xD0;
     errno = 0xdeadbeef;
     ret = p_tolower(ch);
-    len = LCMapStringA(0, LCMAP_LOWERCASE, &ch, 1, &lch, 1);
+    if(!MultiByteToWideChar(CP_ACP, MB_ERR_INVALID_CHARS, &ch, 1, &chw, 1) ||
+            LCMapStringW(CP_ACP, LCMAP_LOWERCASE, &chw, 1, &lower, 1) != 1 ||
+            (len = WideCharToMultiByte(CP_ACP, 0, &lower, 1, &lch, 1, NULL, NULL)) != 1)
+        len = 0;
     if(len)
         ok(ret==(unsigned char)lch || broken(ret==ch)/*WinXP-*/, "ret = %x\n", ret);
     else
@@ -2582,11 +2827,21 @@ static void test__stricmp(void)
 static void test__wcstoi64(void)
 {
     static const WCHAR digit[] = { '9', 0 };
+    static const WCHAR space[] = { ' ', 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;
@@ -2599,21 +2854,33 @@ static void test__wcstoi64(void)
 
     res = p_wcstoi64(digit, NULL, 10);
     ok(res == 9, "res != 9\n");
+    res = p_wcstoi64(space, &endpos, 0);
+    ok(endpos == space, "endpos != space\n");
     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);
     res = p_wcstoi64(thai, NULL, 10);
-    todo_wine ok(res == 9, "res != 9\n");
+    ok(res == 9, "res != 9\n");
     res = p_wcstoi64(fullwidth, NULL, 10);
-    todo_wine ok(res == 9, "res != 9\n");
+    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");
+    ok(res == 0x9f9, "res != 0x9f9\n");
+    res = p_wcstoi64(minus_0x91, NULL, 0);
+    ok(res == -0x91, "res != -0x91\n");
+    res = p_wcstoi64(plus_071, NULL, 0);
+    ok(res == 071, "res != 071\n");
 
     ures = p_wcstoui64(digit, NULL, 10);
     ok(ures == 9, "ures != 9\n");
+    ures = p_wcstoui64(space, &endpos, 0);
+    ok(endpos == space, "endpos != space\n");
     ures = p_wcstoui64(stock, &endpos, 10);
     ok(ures == 0, "ures != 0\n");
     ok(endpos == stock, "Incorrect endpos (%p-%p)\n", stock, endpos);
@@ -2621,11 +2888,25 @@ static void test__wcstoi64(void)
     ok(ures == 0, "ures != 0\n");
     ok(endpos == tamil, "Incorrect endpos (%p-%p)\n", tamil, endpos);
     ures = p_wcstoui64(thai, NULL, 10);
-    todo_wine ok(ures == 9, "ures != 9\n");
+    ok(ures == 9, "ures != 9\n");
     ures = p_wcstoui64(fullwidth, NULL, 10);
-    todo_wine ok(ures == 9, "ures != 9\n");
+    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");
+    ok(ures == 0x9f9, "ures != 0x9f9\n");
+    ures = p_wcstoui64(plus_071, NULL, 0);
+    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);
+        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);
+        ok(res == 4, "with zero = U+%04X: got %d, expected 4\n", zeros[i], (int)res);
+    }
 
     return;
 }
@@ -2838,6 +3119,36 @@ static void test__wcsset_s(void)
     ok(str[2] == 'b', "str[2] = %d\n", str[2]);
 }
 
+static void test__mbscmp(void)
+{
+    static const unsigned char a[] = {'a',0}, b[] = {'b',0};
+    int ret;
+
+    if (!p_mbrlen)
+    {
+        win_skip("_mbscmp tests\n");
+        return;
+    }
+
+    ret = _mbscmp(NULL, NULL);
+    ok(ret == INT_MAX, "got %d\n", ret);
+
+    ret = _mbscmp(a, NULL);
+    ok(ret == INT_MAX, "got %d\n", ret);
+
+    ret = _mbscmp(NULL, a);
+    ok(ret == INT_MAX, "got %d\n", ret);
+
+    ret = _mbscmp(a, a);
+    ok(!ret, "got %d\n", ret);
+
+    ret = _mbscmp(a, b);
+    ok(ret == -1, "got %d\n", ret);
+
+    ret = _mbscmp(b, a);
+    ok(ret == 1, "got %d\n", ret);
+}
+
 START_TEST(string)
 {
     char mem[100];
@@ -2856,6 +3167,7 @@ START_TEST(string)
     SET(p__mb_cur_max,"__mb_cur_max");
     pstrcpy_s = (void *)GetProcAddress( hMsvcrt,"strcpy_s" );
     pstrcat_s = (void *)GetProcAddress( hMsvcrt,"strcat_s" );
+    p_mbscat_s = (void*)GetProcAddress( hMsvcrt, "_mbscat_s" );
     p_mbsnbcat_s = (void *)GetProcAddress( hMsvcrt,"_mbsnbcat_s" );
     p_mbsnbcpy_s = (void *)GetProcAddress( hMsvcrt,"_mbsnbcpy_s" );
     p__mbscpy_s = (void *)GetProcAddress( hMsvcrt,"_mbscpy_s" );
@@ -2884,6 +3196,7 @@ START_TEST(string)
     p_mbrlen = (void*)GetProcAddress(hMsvcrt, "mbrlen");
     p_mbrtowc = (void*)GetProcAddress(hMsvcrt, "mbrtowc");
     p_mbsrtowcs = (void*)GetProcAddress(hMsvcrt, "mbsrtowcs");
+    p_mbsrtowcs_s = (void*)GetProcAddress(hMsvcrt, "mbsrtowcs_s");
     p__atodbl_l = (void*)GetProcAddress(hMsvcrt, "_atodbl_l");
     p__atof_l = (void*)GetProcAddress(hMsvcrt, "_atof_l");
     p__strtod_l = (void*)GetProcAddress(hMsvcrt, "_strtod_l");
@@ -2909,12 +3222,16 @@ START_TEST(string)
     test_memcpy_s();
     test_memmove_s();
     test_strcat_s();
+    test__mbscat_s();
     test__mbsnbcpy_s();
     test__mbscpy_s();
     test_mbcjisjms();
     test_mbcjmsjis();
+    test_mbctohira();
+    test_mbctokata();
     test_mbbtombc();
     test_mbctombb();
+    test_ismbckata();
     test_ismbclegal();
     test_strtok();
     test__mbstok();
@@ -2945,4 +3262,5 @@ START_TEST(string)
     test_strxfrm();
     test__strnset_s();
     test__wcsset_s();
+    test__mbscmp();
 }