diff --git a/dlls/msvcrt/tests/string.c b/dlls/msvcrt/tests/string.c index 221ee3c6011..955a0924948 100644 --- a/dlls/msvcrt/tests/string.c +++ b/dlls/msvcrt/tests/string.c @@ -97,6 +97,7 @@ static double (__cdecl *p__strtod_l)(const char *,char**,_locale_t); static int (__cdecl *p__strnset_s)(char*,size_t,int,size_t); static int (__cdecl *p__wcsset_s)(wchar_t*,size_t,wchar_t); static size_t (__cdecl *p__mbsnlen)(const unsigned char*, size_t); +static int (__cdecl *p__mbccpy_s)(unsigned char*, size_t, int*, const unsigned char*); #define SETNOFAIL(x,y) x = (void*)GetProcAddress(hMsvcrt,y) #define SET(x,y) SETNOFAIL(x,y); ok(x != NULL, "Export '%s' not found\n", y) @@ -373,6 +374,40 @@ static void test_mbcp(void) _mbccpy(buf, mbstring); expect_bin(buf, "\xb0\xb1\xff", 3); + if(!p__mbccpy_s) { + win_skip("_mbccpy_s tests\n"); + }else { + int err, copied; + + memset(buf, 0xff, sizeof(buf)); + copied = -1; + err = p__mbccpy_s(buf, 0, &copied, mbstring); + ok(err == EINVAL, "_mbccpy_s returned %d\n", err); + ok(!copied, "copied = %d\n", copied); + ok(buf[0] == 0xff, "buf[0] = %x\n", buf[0]); + + memset(buf, 0xff, sizeof(buf)); + copied = -1; + err = p__mbccpy_s(buf, 1, &copied, mbstring); + ok(err == ERANGE, "_mbccpy_s returned %d\n", err); + ok(!copied, "copied = %d\n", copied); + ok(!buf[0], "buf[0] = %x\n", buf[0]); + + memset(buf, 0xff, sizeof(buf)); + copied = -1; + err = p__mbccpy_s(buf, 2, &copied, mbstring); + ok(!err, "_mbccpy_s returned %d\n", err); + ok(copied == 2, "copied = %d\n", copied); + expect_bin(buf, "\xb0\xb1\xff", 3); + + memset(buf, 0xff, sizeof(buf)); + copied = -1; + err = p__mbccpy_s(buf, 2, &copied, (unsigned char *)"\xb0"); + ok(err == EILSEQ, "_mbccpy_s returned %d\n", err); + ok(copied == 1, "copied = %d\n", copied); + expect_bin(buf, "\x00\xff", 2); + } + memset(buf, 0xff, sizeof(buf)); _mbsncpy(buf, mbstring, 1); expect_bin(buf, "\xb0\xb1\xff", 3); @@ -3286,6 +3321,7 @@ START_TEST(string) p__strnset_s = (void*)GetProcAddress(hMsvcrt, "_strnset_s"); p__wcsset_s = (void*)GetProcAddress(hMsvcrt, "_wcsset_s"); p__mbsnlen = (void*)GetProcAddress(hMsvcrt, "_mbsnlen"); + p__mbccpy_s = (void*)GetProcAddress(hMsvcrt, "_mbccpy_s"); /* MSVCRT memcpy behaves like memmove for overlapping moves, MFC42 CString::Insert seems to rely on that behaviour */