msvcrt/tests: Add _mbccpy_s tests.
Signed-off-by: Piotr Caban <piotr@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
eb7d55761e
commit
6d0d955ac0
|
@ -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 */
|
||||
|
|
Loading…
Reference in New Issue