44 static char buf[2][1024];
56#define expect_eq(expr, value, type, format) { type ret = (expr); ok((value) == ret, #expr " expected " format " got " format "\n", value, ret); }
57#define expect_bin(buf, value, len) { ok(memcmp((buf), value, len) == 0, "Binary buffer mismatch - expected %s, got %s\n", buf_to_string((unsigned char *)value, len, 1), buf_to_string((buf), len, 0)); }
63static int (
__cdecl *p_strcmp)(
const char *,
const char *);
73static int (
__cdecl *p__mbscpy_s)(
unsigned char*,
size_t,
const unsigned char*);
118static int (
__cdecl *p__mbccpy_s)(
unsigned char*,
size_t,
int*,
const unsigned char*);
129#define SETNOFAIL(x,y) x = (void*)GetProcAddress(hMsvcrt,y)
130#define SET(x,y) SETNOFAIL(x,y); ok(x != NULL, "Export '%s' not found\n", y)
135 char original[] =
"BADCFEHGJILKNMPORQTSVUXWZY@#";
136 char expected1[] =
"ABCDEFGHIJKLMNOPQRSTUVWXYZ@#";
137 char expected2[] =
"ABCDEFGHIJKLMNOPQRSTUVWX$";
138 char expected3[] =
"$";
146 memset(to,
'$',
sizeof(to));
151 ok(
memcmp(to,expected1,testsize) == 0,
"Testing even size %d returned '%*.*s'\n", testsize, testsize, testsize, to);
154 memset(to,
'$',
sizeof(to));
159 ok(
memcmp(to,expected2,testsize) == 0,
"Testing odd size %d returned '%*.*s'\n", testsize, testsize, testsize, to);
162 memset(to,
'$',
sizeof(to));
165 memcpy(to, original, testsize);
166 _swab( to, to, testsize );
167 ok(
memcmp(to,expected1,testsize) == 0,
"Testing overlapped size %d returned '%*.*s'\n", testsize, testsize, testsize, to);
170 memset(to,
'$',
sizeof(to));
175 ok(
memcmp(to,expected3,testsize) == 0,
"Testing small size %d returned '%*.*s'\n", testsize, testsize, testsize, to);
180 static const struct {
189 {
"a\xf1",
"\xf1", 1 }
196 ok(
r ==
tests[
i].
ret,
"strcspn(\"%s\", \"%s\") = %d, expected %d\n",
212 printf(
"static int result_cp_%d_mbctype[] = { ",
cp);
213 for (
i = 1;
i < 257;
i++)
230static int result_cp_932_mbctype[] = { 0x0,65, 0x8,1, 0x18,26, 0x8,6, 0x28,26, 0x8,4,
231 0x0,1, 0x8,1, 0xc,31, 0x8,1, 0xa,5, 0x9,58, 0xc,29, 0,3 };
232static int result_cp_936_mbctype[] = { 0x0,65, 0x8,1, 0x18,26, 0x8,6, 0x28,26, 0x8,6,
234static int result_cp_949_mbctype[] = { 0x0,66, 0x18,26, 0x8,6, 0x28,26, 0x8,6, 0xc,126,
236static int result_cp_950_mbctype[] = { 0x0,65, 0x8,1, 0x18,26, 0x8,6, 0x28,26, 0x8,4,
237 0x0,2, 0x4,32, 0xc,94, 0,1 };
245 for (
i = 0;
i < 256;
i++)
258#define test_codepage(num) test_cp_table(num, result_cp_##num##_mbctype);
266 unsigned char *mbstring = (
unsigned char *)
"\xb0\xb1\xb2 \xb3\xb4 \xb5";
267 unsigned char *mbstring2 = (
unsigned char *)
"\xb0\xb1\xb2\xb3Q\xb4\xb5";
268 unsigned char *mbsonlylead = (
unsigned char *)
"\xb0\0\xb1\xb2 \xb3";
269 unsigned char buf[16];
302 ok(
_ismbblead(0x1234b0),
"0x1234b0 should not be a lead byte\n");
382 expect_eq(p__mbsnlen(mbstring, 8), 8,
int,
"%d");
383 expect_eq(p__mbsnlen(mbstring, 9), 4,
int,
"%d");
384 expect_eq(p__mbsnlen(mbstring, 10), 4,
int,
"%d");
385 expect_eq(p__mbsnlen(mbsonlylead, 0), 0,
int,
"%d");
386 expect_eq(p__mbsnlen(mbsonlylead, 1), 1,
int,
"%d");
387 expect_eq(p__mbsnlen(mbsonlylead, 2), 0,
int,
"%d");
388 expect_eq(p__mbsnlen(mbstring2, 7), 7,
int,
"%d");
389 expect_eq(p__mbsnlen(mbstring2, 8), 4,
int,
"%d");
390 expect_eq(p__mbsnlen(mbstring2, 9), 4,
int,
"%d");
398 expect_eq(p_mbrlen((
const char*)mbstring, 2,
NULL), 2,
int,
"%d");
399 expect_eq(p_mbrlen((
const char*)&mbstring[2], 2,
NULL), 2,
int,
"%d");
400 expect_eq(p_mbrlen((
const char*)&mbstring[3], 2,
NULL), 1,
int,
"%d");
401 expect_eq(p_mbrlen((
const char*)mbstring, 1,
NULL), -2,
int,
"%d");
402 expect_eq(p_mbrlen((
const char*)mbstring, 1, &
state), -2,
int,
"%d");
403 ok(
state == mbstring[0],
"incorrect state value (%x)\n",
state);
404 expect_eq(p_mbrlen((
const char*)&mbstring[1], 1, &
state), 2,
int,
"%d");
414 ok(
dst == 0x6c28,
"dst = %x, expected 0x6c28\n",
dst);
416 ok(
dst == 0x3f,
"dst = %x, expected 0x3f\n",
dst);
418 ok(
dst == 0x20,
"dst = %x, expected 0x20\n",
dst);
420 ok(
dst == 0,
"dst = %x, expected 0\n",
dst);
422 ok(
dst == 0,
"dst = %x, expected 0\n",
dst);
423 ok(
state == mbstring[0],
"incorrect state value (%x)\n",
state);
425 ok(
dst == 0x6c28,
"dst = %x, expected 0x6c28\n",
dst);
442 err = p__mbccpy_s(
buf, 0, &copied, mbstring);
444 ok(!copied,
"copied = %d\n", copied);
445 ok(
buf[0] == 0xff,
"buf[0] = %x\n",
buf[0]);
449 err = p__mbccpy_s(
buf, 1, &copied, mbstring);
451 ok(!copied,
"copied = %d\n", copied);
452 ok(!
buf[0],
"buf[0] = %x\n",
buf[0]);
456 err = p__mbccpy_s(
buf, 2, &copied, mbstring);
457 ok(!
err,
"_mbccpy_s returned %d\n",
err);
458 ok(copied == 2,
"copied = %d\n", copied);
463 err = p__mbccpy_s(
buf, 2, &copied, (
unsigned char *)
"\xb0");
465 ok(copied == 1,
"copied = %d\n", copied);
472 ok(
ret ==
NULL,
"_mbsncpy returned %p, expected NULL\n",
ret);
478 ok(
ret ==
NULL,
"_mbsncpy returned %p, expected NULL\n",
ret);
485 ok(
ret ==
NULL,
"_mbsncpy returned %p, expected NULL\n",
ret);
486 ok(
errno == 0xdeadbeef,
"_mbsncpy should not change errno\n");
492 ok(
errno == 0xdeadbeef,
"_mbsncpy should not change errno\n");
498 ok(
ret ==
NULL,
"_mbsncpy returned %p, expected NULL\n",
ret);
504 ok(
ret ==
NULL,
"_mbsncpy returned %p, expected NULL\n",
ret);
551 step =
_mbsinc(mbstring) - mbstring;
552 ok(step == 2,
"_mbsinc adds %d (exp. 2)\n", step);
553 step =
_mbsinc(&mbstring[2]) - &mbstring[2];
554 ok(step == 2,
"_mbsinc adds %d (exp. 2)\n", step);
556 step =
_mbsninc(mbsonlylead, 1) - mbsonlylead;
557 ok(step == 0,
"_mbsninc adds %d (exp. 0)\n", step);
558 step =
_mbsninc(mbsonlylead, 2) - mbsonlylead;
559 ok(step == 0,
"_mbsninc adds %d (exp. 0)\n", step);
560 step =
_mbsninc(mbstring2, 0) - mbstring2;
561 ok(step == 0,
"_mbsninc adds %d (exp. 2)\n", step);
562 step =
_mbsninc(mbstring2, 1) - mbstring2;
563 ok(step == 2,
"_mbsninc adds %d (exp. 2)\n", step);
564 step =
_mbsninc(mbstring2, 2) - mbstring2;
565 ok(step == 4,
"_mbsninc adds %d (exp. 4)\n", step);
566 step =
_mbsninc(mbstring2, 3) - mbstring2;
567 ok(step == 5,
"_mbsninc adds %d (exp. 5)\n", step);
568 step =
_mbsninc(mbstring2, 4) - mbstring2;
569 ok(step == 7,
"_mbsninc adds %d (exp. 7)\n", step);
570 step =
_mbsninc(mbstring2, 5) - mbstring2;
571 ok(step == 7,
"_mbsninc adds %d (exp. 7)\n", step);
572 step =
_mbsninc(mbstring2, 17) - mbstring2;
573 ok(step == 7,
"_mbsninc adds %d (exp. 7)\n", step);
586 skip(
"Current locale has double-byte charset - could lead to false positives\n");
614 unsigned char str1[]=
"cabernet";
615 unsigned char str2[]=
"shiraz";
616 unsigned char set[]=
"abc";
617 unsigned char empty[]=
"";
618 unsigned char mbstr[]=
" 2019\x94\x4e" "6\x8c\x8e" "29\x93\xfa";
619 unsigned char mbset1[]=
"0123456789 \x94\x4e";
620 unsigned char mbset2[]=
" \x94\x4e\x8c\x8e";
621 unsigned char mbset3[]=
"\x8e";
625 ok(
ret==3,
"_mbsspn returns %d should be 3\n",
ret);
627 ok(
ret==0,
"_mbsspn returns %d should be 0\n",
ret);
629 ok(
ret==0,
"_mbsspn returns %d should be 0\n",
ret);
632 ok(
ret==0,
"_mbscspn returns %d should be 0\n",
ret);
634 ok(
ret==4,
"_mbscspn returns %d should be 4\n",
ret);
636 ok(
ret==8,
"_mbscspn returns %d should be 8\n",
ret);
640 ok(
ret==8,
"_mbsspn returns %d should be 8\n",
ret);
642 ok(
ret==1,
"_mbsspn returns %d should be 1\n",
ret);
644 ok(
ret==0,
"_mbsspn returns %d should be 0\n",
ret);
646 ok(
ret==2,
"_mbsspn returns %d should be 2\n",
ret);
648 ok(
ret==14,
"_mbsspn returns %d should be 14\n",
ret);
651 ok(
ret==0,
"_mbscspn returns %d should be 0\n",
ret);
653 ok(
ret==0,
"_mbscspn returns %d should be 0\n",
ret);
655 ok(
ret==2,
"_mbscspn returns %d should be 2\n",
ret);
657 ok(
ret==0,
"_mbscspn returns %d should be 0\n",
ret);
659 ok(
ret==0,
"_mbscspn returns %d should be 0\n",
ret);
666 unsigned char str1[]=
"cabernet";
667 unsigned char str2[]=
"shiraz";
668 unsigned char set[]=
"abc";
669 unsigned char empty[]=
"";
670 unsigned char full[]=
"abcenrt";
671 unsigned char mbstr[]=
" 2019\x94\x4e" "6\x8c\x8e" "29\x93\xfa";
672 unsigned char mbset1[]=
"0123456789 \x94\x4e";
673 unsigned char mbset2[]=
" \x94\x4e\x8c\x8e";
678 ok(
ret[0]==
'e',
"_mbsspnp returns %c should be e\n",
ret[0]);
680 ok(
ret[0]==
's',
"_mbsspnp returns %c should be s\n",
ret[0]);
682 ok(
ret[0]==
'c',
"_mbsspnp returns %c should be c\n",
ret[0]);
684 ok(
ret==
NULL,
"_mbsspnp returns %p should be NULL\n",
ret);
688 ok(
ret==mbstr+8,
"_mbsspnp returns %p should be %p\n",
ret, mbstr+8);
690 ok(
ret==mbstr+1,
"_mbsspnp returns %p should be %p\n",
ret, mbstr+1);
692 ok(
ret==mbstr+8,
"_mbsspnp returns %p should be %p\n",
ret, mbstr+8);
694 ok(
ret==mbstr+10,
"_mbsspnp returns %p should be %p\n",
ret, mbstr+10);
705 ok(
errno == 0xdeadbeef,
"errno is %d, expected 0xdeadbeef\n",
errno);
714 ok(
errno == 0xdeadbeef,
"errno is %d, expected 0xdeadbeef\n",
errno);
719 int ret = p_strcmp(
"abc",
"abcd" );
720 ok(
ret == -1,
"wrong ret %d\n",
ret );
721 ret = p_strcmp(
"",
"abc" );
722 ok(
ret == -1,
"wrong ret %d\n",
ret );
723 ret = p_strcmp(
"abc",
"ab\xa0" );
724 ok(
ret == -1,
"wrong ret %d\n",
ret );
725 ret = p_strcmp(
"ab\xb0",
"ab\xa0" );
726 ok(
ret == 1,
"wrong ret %d\n",
ret );
727 ret = p_strcmp(
"ab\xc2",
"ab\xc2" );
728 ok(
ret == 0,
"wrong ret %d\n",
ret );
730 ret = p_strncmp(
"abc",
"abcd", 3 );
731 ok(
ret == 0,
"wrong ret %d\n",
ret );
734 ret = p_strncmp(
"",
"abc", 3 );
735 ok(
ret == -1,
"wrong ret %d\n",
ret );
736 ret = p_strncmp(
"abc",
"ab\xa0", 4 );
737 ok(
ret == -1,
"wrong ret %d\n",
ret );
738 ret = p_strncmp(
"ab\xb0",
"ab\xa0", 3 );
739 ok(
ret == 1,
"wrong ret %d\n",
ret );
741 ret = p_strncmp(
"",
"abc", 3 );
742 ok(
ret == 0 -
'a',
"wrong ret %d\n",
ret );
743 ret = p_strncmp(
"abc",
"ab\xa0", 4 );
744 ok(
ret ==
'c' - 0xa0,
"wrong ret %d\n",
ret );
745 ret = p_strncmp(
"ab\xb0",
"ab\xa0", 3 );
746 ok(
ret == 0xb0 - 0xa0,
"wrong ret %d\n",
ret );
749 ret = p_strncmp(
"ab\xb0",
"ab\xa0", 2 );
750 ok(
ret == 0,
"wrong ret %d\n",
ret );
751 ret = p_strncmp(
"ab\xc2",
"ab\xc2", 3 );
752 ok(
ret == 0,
"wrong ret %d\n",
ret );
753 ret = p_strncmp(
"abc",
"abd", 0 );
754 ok(
ret == 0,
"wrong ret %d\n",
ret );
755 ret = p_strncmp(
"abc",
"abc", 12 );
756 ok(
ret == 0,
"wrong ret %d\n",
ret );
762 const char small[] =
"small";
763 const char big[] =
"atoolongstringforthislittledestination";
774 ok(
ret == 0,
"Copying a string into a big enough destination returned %d, expected 0\n",
ret);
777 "Unexpected return data from strcpy_s: 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x\n",
782 ok(
ret ==
EINVAL,
"Copying into a destination of size 0 returned %d, expected EINVAL\n",
ret);
785 "Unexpected return data from strcpy_s: 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x\n",
788 ok(
ret ==
EINVAL,
"Copying into a destination of size 0 returned %d, expected EINVAL\n",
ret);
791 "Unexpected return data from strcpy_s: 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x\n",
796 ok(
ret ==
ERANGE,
"Copying a big string in a small location returned %d, expected ERANGE\n",
ret);
799 "Unexpected return data from strcpy_s: 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x\n",
804 ok(
ret ==
EINVAL,
"Copying from a NULL source string returned %d, expected EINVAL\n",
ret);
807 "Unexpected return data from strcpy_s: 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x\n",
811 ok(
ret ==
EINVAL,
"Copying a big string a NULL dest returned %d, expected EINVAL\n",
ret);
819 "Unexpected return data from strcpy: 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x\n",
834 ok(
dest[0] == 0,
"dest[0] not 0\n");
838 ok(
ret == 0,
"expected ERROR_SUCCESS got %d\n",
ret);
839 ok(
dest[0] == 0,
"dest[0] not 0\n");
847 ok(
ret == 0,
"expected 0 got %d\n",
ret);
853 ok(
dest[0] == 0,
"dest[0] not 0\n");
856 ret = p_strncpy_s(
dest, 5, big, -1);
858 ok(
dest[4] == 0,
"dest[4] not 0\n");
861 ret = p_strncpy_s(
NULL, 0, (
void*)0xdeadbeef, 0);
872#define okchars(dst, b0, b1, b2, b3, b4, b5, b6, b7) \
873 ok(dst[0] == b0 && dst[1] == b1 && dst[2] == b2 && dst[3] == b3 && \
874 dst[4] == b4 && dst[5] == b5 && dst[6] == b6 && dst[7] == b7, \
875 "Bad result: 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x\n",\
876 dst[0], dst[1], dst[2], dst[3], dst[4], dst[5], dst[6], dst[7])
881 static const char tiny[] = {
'T',0,
'I',
'N',
'Y',0};
882 static const char big[] = {
'a',
't',
'o',
'o',
'l',
'o',
'n',
'g',
's',
't',
'r',
'i',
'n',
'g',0};
892 ok(
ret == 0,
"Copying a buffer into a big enough destination returned %d, expected 0\n",
ret);
893 okchars(
dest, tiny[0], tiny[1], tiny[2], tiny[3], tiny[4], tiny[5],
'X',
'X');
899 ok(
ret ==
ERANGE,
"Copying a big buffer to a small destination returned %d, expected ERANGE\n",
ret);
907 ok(
ret ==
EINVAL,
"Copying a NULL source buffer returned %d, expected EINVAL\n",
ret);
915 ok(
ret ==
ERANGE,
"Copying into a destination of size 0 returned %d, expected ERANGE\n",
ret);
917 okchars(
dest,
'X',
'X',
'X',
'X',
'X',
'X',
'X',
'X');
922 ok(
ret ==
EINVAL,
"Copying a tiny buffer to a big NULL destination returned %d, expected EINVAL\n",
ret);
929 ok(
ret ==
EINVAL,
"Copying a NULL buffer into a destination of size 0 returned %d, expected EINVAL\n",
ret);
931 okchars(
dest,
'X',
'X',
'X',
'X',
'X',
'X',
'X',
'X');
934 ok(!
ret,
"memcpy_s returned %d\n",
ret);
935 ok(!
memcmp(
buf, big,
sizeof(big)),
"unexpected buf\n");
938 ok(!
ret,
"memcpy_s returned %d\n",
ret);
939 ok(!
memcmp(
buf + 1, big,
sizeof(big)),
"unexpected buf\n");
942 ok(!
ret,
"memcpy_s returned %d\n",
ret);
943 ok(!
memcmp(
buf, big,
sizeof(big)),
"unexpected buf\n");
949 static const char tiny[] = {
'T',0,
'I',
'N',
'Y',0};
950 static const char big[] = {
'a',
't',
'o',
'o',
'l',
'o',
'n',
'g',
's',
't',
'r',
'i',
'n',
'g',0};
960 ok(
ret == 0,
"Moving a buffer into a big enough destination returned %d, expected 0\n",
ret);
961 okchars(
dest, tiny[0], tiny[1], tiny[2], tiny[3], tiny[4], tiny[5],
'X',
'X');
966 ok(
ret == 0,
"Moving a buffer up one char returned %d, expected 0\n",
ret);
967 okchars(
dest, big[0], big[0], big[1], big[2], big[3], big[4], big[5], big[6]);
973 ok(
ret ==
ERANGE,
"Moving a big buffer to a small destination returned %d, expected ERANGE\n",
ret);
975 okchars(
dest,
'X',
'X',
'X',
'X',
'X',
'X',
'X',
'X');
981 ok(
ret ==
EINVAL,
"Moving a NULL source buffer returned %d, expected EINVAL\n",
ret);
983 okchars(
dest,
'X',
'X',
'X',
'X',
'X',
'X',
'X',
'X');
989 ok(
ret ==
ERANGE,
"Moving into a destination of size 0 returned %d, expected ERANGE\n",
ret);
991 okchars(
dest,
'X',
'X',
'X',
'X',
'X',
'X',
'X',
'X');
996 ok(
ret ==
EINVAL,
"Moving a tiny buffer to a big NULL destination returned %d, expected EINVAL\n",
ret);
1003 ok(
ret ==
EINVAL,
"Moving a NULL buffer into a destination of size 0 returned %d, expected EINVAL\n",
ret);
1005 okchars(
dest,
'X',
'X',
'X',
'X',
'X',
'X',
'X',
'X');
1011 const char *
small =
"sma";
1023 ok(
ret == 0,
"strcat_s: Copying a string into a big enough destination returned %d, expected 0\n",
ret);
1026 "Unexpected return data from strcpy_s: 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x\n",
1029 ok(
ret == 0,
"strcat_s: Attaching a string to a big enough destination returned %d, expected 0\n",
ret);
1032 "Unexpected return data from strcpy_s: 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x\n",
1036 ok(
ret ==
ERANGE,
"strcat_s: Attaching a string to a filled up destination returned %d, expected ERANGE\n",
ret);
1039 "Unexpected return data from strcpy_s: 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x\n",
1047 ok(
ret ==
EINVAL,
"strcat_s: Source len = 0 returned %d, expected EINVAL\n",
ret);
1050 "Unexpected return data from strcpy_s: 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x\n",
1054 ok(
ret ==
EINVAL,
"strcat_s: len = 0 and src = NULL returned %d, expected EINVAL\n",
ret);
1057 "Unexpected return data from strcpy_s: 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x\n",
1061 ok(
ret ==
EINVAL,
"strcat_s: Sourcing from NULL returned %d, expected EINVAL\n",
ret);
1064 "Unexpected return data from strcpy_s: 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x\n",
1068 ok(
ret ==
EINVAL,
"strcat_s: Writing to a NULL string returned %d, expected EINVAL\n",
ret);
1073 unsigned char dst[8],
src[4];
1101 ok(
err == 0,
"_mbscat_s returned %d\n",
err);
1106 ok(!
dst[0],
"dst[0] = %c\n",
dst[0]);
1107 ok(
dst[1] ==
'a',
"dst[1] = %c\n",
dst[1]);
1118 ok(
err == 0,
"_mbscat_s returned %d\n",
err);
1127 ok(
err == 0,
"_mbscat_s returned %d\n",
err);
1153 unsigned char dest[8];
1154 const unsigned char big[] =
"atoolongstringforthislittledestination";
1155 const unsigned char small[] =
"small";
1160 win_skip(
"_mbsnbcpy_s not found\n");
1166 ok(
ret == 0,
"_mbsnbcpy_s: Copying a string into a big enough destination returned %d, expected 0\n",
ret);
1169 "Unexpected return data from _mbsnbcpy_s: 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x\n",
1175 ok(
ret ==
ERANGE,
"_mbsnbcpy_s: Copying a too long string returned %d, expected ERANGE\n",
ret);
1178 "Unexpected return data from _mbsnbcpy_s: 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x\n",
1182 ret = p_mbsnbcpy_s(
dest,
sizeof(
dest) - 2, big, 4);
1183 ok(
ret == 0,
"_mbsnbcpy_s: Copying a too long string with a count cap returned %d, expected 0\n",
ret);
1186 "Unexpected return data from _mbsnbcpy_s: 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x\n",
1191 ok(
ret == 0,
"_mbsnbcpy_s: Copying more data than the source string len returned %d, expected 0\n",
ret);
1194 "Unexpected return data from _mbsnbcpy_s: 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x\n",
1200 const unsigned char src[] =
"source string";
1201 unsigned char dest[16];
1219 ok(!
dest[0],
"dest buffer was not modified on invalid argument\n");
1225 ok(
dest[
sizeof(
src)] ==
'X',
"unused part of buffer was modified\n");
1230 ok(!
dest[0],
"incorrect dest buffer (%d)\n",
dest[0]);
1231 ok(
dest[1] ==
src[1],
"incorrect dest buffer (%d)\n",
dest[1]);
1236 static const WCHAR szLongText[] =
L"ThisALongstring";
1237 static WCHAR szDest[18];
1238 static WCHAR szDestShort[8];
1249 ret = p_wcscpy_s(
NULL, 18, szLongText);
1256 ret = p_wcscpy_s(szDest, 18,
NULL);
1259 ok(szDest[0] == 0,
"szDest[0] not 0, got %c\n", szDest[0]);
1264 ret = p_wcscpy_s(szDest, 0, szLongText);
1270 ok(szDest[0] == 0 ||
ret ==
EINVAL,
"szDest[0] not 0\n");
1273 ret = p_wcscpy_s(szDest, 18, szLongText);
1274 ok(
ret == 0,
"expected 0 got %d\n",
ret);
1275 ok(
lstrcmpW(szDest, szLongText) == 0,
"szDest != szLongText\n");
1278 ret = p_wcscpy_s(szDest, 18, szDest);
1279 ok(
ret == 0,
"expected 0 got %d\n",
ret);
1280 ok(
lstrcmpW(szDest, szLongText) == 0,
"szDest != szLongText\n");
1285 ret = p_wcscpy_s(szDestShort, 8, szLongText);
1288 ok(szDestShort[0] == 0,
"szDestShort[0] not 0\n");
1300 ret = p_wcsncpy_s(szDest, 18,
NULL, 1);
1302 ok(szDest[0] == 0,
"szDest[0] not 0\n");
1305 ret = p_wcsncpy_s(szDest, 18,
NULL, 0);
1306 ok(
ret == 0,
"expected ERROR_SUCCESS got %d\n",
ret);
1307 ok(szDest[0] == 0,
"szDest[0] not 0\n");
1310 ret = p_wcsncpy_s(szDest, 0, szLongText,
ARRAY_SIZE(szLongText));
1312 ok(szDest[0] == 0 ||
ret ==
EINVAL,
"szDest[0] not 0\n");
1314 ret = p_wcsncpy_s(szDest, 18, szLongText,
ARRAY_SIZE(szLongText));
1315 ok(
ret == 0,
"expected 0 got %d\n",
ret);
1316 ok(
lstrcmpW(szDest, szLongText) == 0,
"szDest != szLongText\n");
1319 ret = p_wcsncpy_s(szDestShort, 8, szLongText,
ARRAY_SIZE(szLongText));
1321 ok(szDestShort[0] == 0,
"szDestShort[0] not 0\n");
1324 ret = p_wcsncpy_s(szDest, 5, szLongText, -1);
1326 ok(szDest[4] == 0,
"szDest[4] not 0\n");
1329 ret = p_wcsncpy_s(
NULL, 0, (
void*)0xdeadbeef, 0);
1332 szDestShort[0] =
'1';
1334 ret = p_wcsncpy_s(szDestShort+1, 4, szDestShort, -1);
1336 ok(szDestShort[0]==
'1' && szDestShort[1]==
'1' && szDestShort[2]==
'1' && szDestShort[3]==
'1',
1342 static const WCHAR mixedString[] =
L"MiXeDlowerUPPER";
1343 static const WCHAR expectedString[] =
L"MIXEDLOWERUPPER";
1356 ok(
ret ==
EINVAL,
"Expected _wcsupr_s to fail with EINVAL, got %d\n",
ret);
1362 ok(
ret ==
EINVAL,
"Expected _wcsupr_s to fail with EINVAL, got %d\n",
ret);
1367 testBuffer[0] =
'\0';
1368 ret = p_wcsupr_s(testBuffer, 0);
1369 ok(
ret ==
EINVAL,
"Expected _wcsupr_s to fail with EINVAL, got %d\n",
ret);
1371 ok(testBuffer[0] ==
'\0',
"Expected the buffer to be unchanged\n");
1374 testBuffer[0] =
'\0';
1375 ret = p_wcsupr_s(testBuffer, 1);
1376 ok(
ret == 0,
"Expected _wcsupr_s to succeed, got %d\n",
ret);
1377 ok(testBuffer[0] ==
'\0',
"Expected the buffer to be unchanged\n");
1381 testBuffer[0] =
'x';
1382 ret = p_wcsupr_s(testBuffer, 0);
1383 ok(
ret ==
EINVAL,
"Expected _wcsupr_s to fail with EINVAL, got %d\n",
ret);
1385 ok(testBuffer[0] ==
'\0',
"Expected the first buffer character to be null\n");
1389 testBuffer[0] =
'x';
1390 ret = p_wcsupr_s(testBuffer, 1);
1391 ok(
ret ==
EINVAL,
"Expected _wcsupr_s to fail with EINVAL, got %d\n",
ret);
1393 ok(testBuffer[0] ==
'\0',
"Expected the first buffer character to be null\n");
1396 wcscpy(testBuffer, mixedString);
1398 ret = p_wcsupr_s(testBuffer, 0);
1399 ok(
ret ==
EINVAL,
"Expected _wcsupr_s to fail with EINVAL, got %d\n",
ret);
1401 ok(testBuffer[0] ==
'\0',
"Expected the first buffer character to be null\n");
1404 wcscpy(testBuffer, mixedString);
1406 ok(
ret == 0,
"Expected _wcsupr_s to succeed, got %d\n",
ret);
1407 ok(!
wcscmp(testBuffer, expectedString),
"Expected the string to be fully upper-case\n");
1410 wcscpy(testBuffer, mixedString);
1413 ok(
ret ==
EINVAL,
"Expected _wcsupr_s to fail with EINVAL, got %d\n",
ret);
1415 ok(testBuffer[0] ==
'\0',
"Expected the first buffer character to be null\n");
1418 wcscpy(testBuffer, mixedString);
1420 ok(
ret == 0,
"Expected _wcsupr_s to succeed, got %d\n",
ret);
1421 ok(!
wcscmp(testBuffer, expectedString),
"Expected the string to be fully upper-case\n");
1426 static const WCHAR mixedString[] =
L"MiXeDlowerUPPER";
1427 static const WCHAR expectedString[] =
L"mixedlowerupper";
1455 ok(
buffer[0] == 0,
"expected empty string\n");
1461 ok(
buffer[0] == 0,
"expected buffer to be unchanged\n");
1469 ok(
buffer[0] ==
'\0',
"expected empty string\n");
1477 ok(
buffer[0] ==
'\0',
"expected empty string\n");
1485 ok(
buffer[0] ==
'\0',
"expected empty string\n");
1490 ok(
ret == 0,
"expected 0, got %d\n",
ret);
1499 ok(
buffer[0] ==
'\0',
"expected empty string\n");
1504 ok(
ret == 0,
"expected 0, got %d\n",
ret);
1511 unsigned int jisjms[][2] = { {0x2020, 0}, {0x2021, 0}, {0x2120, 0}, {0x2121, 0x8140},
1512 {0x7f7f, 0}, {0x7f7e, 0}, {0x7e7f, 0}, {0x7e7e, 0xeffc},
1513 {0x255f, 0x837e}, {0x2560, 0x8380}, {0x2561, 0x8381},
1514 {0x2121FFFF, 0}, {0x2223, 0x81a1}, {0x237e, 0x829e}, {0, 0}};
1522 for (
j = 0; jisjms[
j][0] != 0;
j++)
1526 exp = (
cp[
i] == 932) ? jisjms[
j][1] : jisjms[
j][0];
1527 ok(
ret ==
exp,
"Expected 0x%x, got 0x%x (0x%x, codepage=%d)\n",
1537 unsigned int jmsjis[][2] = { {0x80fc, 0}, {0x813f, 0}, {0x8140, 0x2121},
1538 {0x817e, 0x215f}, {0x817f, 0}, {0x8180, 0x2160},
1539 {0x819e, 0x217e}, {0x819f, 0x2221}, {0x81fc, 0x227e},
1540 {0x81fd, 0}, {0x9ffc, 0x5e7e}, {0x9ffd, 0},
1541 {0xa040, 0}, {0xdffc, 0}, {0xe040, 0x5f21},
1542 {0xeffc, 0x7e7e}, {0xf040, 0}, {0x21, 0}, {0, 0}};
1550 for (
j = 0; jmsjis[
j][0] != 0;
j++)
1554 exp = (
cp[
i] == 932) ? jmsjis[
j][1] : jmsjis[
j][0];
1555 ok(
ret ==
exp,
"Expected 0x%x, got 0x%x (0x%x, codepage=%d)\n",
1564 static const unsigned int mbchira_932[][2] = {
1565 {0x8152, 0x8152}, {0x8153, 0x8153}, {0x8154, 0x8154}, {0x8155, 0x8155},
1566 {0x82a0, 0x82a0}, {0x833f, 0x833f}, {0x8340, 0x829f}, {0x837e, 0x82dd},
1567 {0x837f, 0x837f}, {0x8380, 0x82de}, {0x8393, 0x82f1}, {0x8394, 0x8394},
1568 {0x8396, 0x8396}, {0x8397, 0x8397},
1569 {0xa5, 0xa5}, {0xb0, 0xb0}, {0xdd, 0xdd} };
1576 int ret,
exp = mbchira_932[
i][0];
1586 exp = mbchira_932[
i][1];
1594 static const unsigned int mbckata_932[][2] = {
1595 {0x8152, 0x8152}, {0x8153, 0x8153}, {0x8154, 0x8154}, {0x8155, 0x8155},
1596 {0x833f, 0x833f}, {0x829f, 0x8340}, {0x82dd, 0x837e}, {0x837f, 0x837f},
1597 {0x82de, 0x8380}, {0x8394, 0x8394}, {0x8397, 0x8397},
1598 {0xa5, 0xa5}, {0xb0, 0xb0}, {0xdd, 0xdd} };
1605 int ret,
exp = mbckata_932[
i][0];
1615 exp = mbckata_932[
i][1];
1623 static const unsigned int mbbmbc[][2] = {
1624 {0x1f, 0x1f}, {0x20, 0x8140}, {0x39, 0x8258}, {0x40, 0x8197},
1625 {0x41, 0x8260}, {0x5e, 0x814f}, {0x7e, 0x8150}, {0x7f, 0x7f},
1626 {0x80, 0x80}, {0x81, 0x81}, {0xa0, 0xa0}, {0xa7, 0x8340},
1627 {0xb0, 0x815b}, {0xd1, 0x8380}, {0xff, 0xff}, {0,0}};
1635 for (
j = 0; mbbmbc[
j][0] != 0;
j++)
1639 exp = (
cp[
i] == 932) ? mbbmbc[
j][1] : mbbmbc[
j][0];
1640 ok(
ret ==
exp,
"Expected 0x%x, got 0x%x (0x%x, codepage %d)\n",
1649 static const unsigned int mbcmbb_932[][2] = {
1650 {0x829e, 0x829e}, {0x829f, 0xa7}, {0x82f1, 0xdd}, {0x82f2, 0x82f2},
1651 {0x833f, 0x833f}, {0x8340, 0xa7}, {0x837e, 0xd0}, {0x837f, 0x837f},
1652 {0x8380, 0xd1}, {0x8396, 0xb9}, {0x8397, 0x8397}, {0x813f, 0x813f},
1653 {0x8140, 0x20}, {0x814c, 0x814c}, {0x814f, 0x5e}, {0x8197, 0x40},
1654 {0x8198, 0x8198}, {0x8258, 0x39}, {0x8259, 0x8259}, {0x825f, 0x825f},
1655 {0x8260, 0x41}, {0x82f1, 0xdd}, {0x82f2, 0x82f2}, {0,0}};
1660 for (
i = 0; mbcmbb_932[
i][0] != 0;
i++)
1663 exp = mbcmbb_932[
i][1];
1670 struct katakana_pair {
1674 static const struct katakana_pair
tests[] = {
1707 for(
i = 0;
i < 0x10000;
i++) {
1718 ok(!
err,
"_ismbclegal (932) : Expected 0x%x, got 0x%x (0x%x)\n",
exp,
ret,
i);
1721 for(
i = 0;
i < 0x10000;
i++) {
1730 ok(!
err,
"_ismbclegal (936) : Expected 0x%x, got 0x%x (0x%x)\n",
exp,
ret,
i);
1733 for(
i = 0;
i < 0x10000;
i++) {
1742 ok(!
err,
"_ismbclegal (949) : Expected 0x%x, got 0x%x (0x%x)\n",
exp,
ret,
i);
1745 for(
i = 0;
i < 0x10000;
i++) {
1755 ok(!
err,
"_ismbclegal (950) : Expected 0x%x, got 0x%x (0x%x)\n",
exp,
ret,
i);
1758 for(
i = 0;
i < 0x10000;
i++) {
1775static const struct {
1785 {
"red cabernet",
" ", 0, 4, -1 },
1786 {
"sparkling white riesling",
" ", 0, 10, 16 },
1787 {
" pale cream sherry",
"e ", 1, 6, 9 },
1802 "string (%p) \'%s\' return %p\n",
1804 if( !strret)
continue;
1808 "second call string (%p) \'%s\' return %p\n",
1810 if( !strret)
continue;
1814 "third call string (%p) \'%s\' return %p\n",
1818 strcpy( teststr,
"test a=b" );
1819 strret =
strtok( teststr,
" " );
1820 ok( strret == teststr,
"strret = %p, expected %p\n", strret, teststr );
1822 ok( !strret,
"strret = %p, expected NULL\n", strret );
1824 ok( !strret,
"strret = %p, expected NULL\n", strret );
1829 static char neg[] =
"-0x";
1839 ok(
l==-1234,
"wrong value %ld\n",
l);
1843 ok(ul==1234,
"wrong value %lu\n", ul);
1848 ok(
l==2147483647,
"wrong value %ld\n",
l);
1852 ok(
l==-2147483647L - 1,
"wrong value %ld\n",
l);
1855 ul =
strtoul(
"4294967295UL", &
e, 0);
1856 ok(ul==4294967295ul,
"wrong value %lu\n", ul);
1860 l =
strtol(
"9223372036854775807L", &
e, 0);
1861 ok(
l==2147483647,
"wrong value %ld\n",
l);
1864 ul =
strtoul(
"9223372036854775807L", &
e, 0);
1865 ok(ul==4294967295ul,
"wrong value %lu\n", ul);
1870 ok(ul == -2,
"wrong value %lu\n", ul);
1875 ok(ul == 2,
"wrong value %lu\n", ul);
1880 ok(ul==1,
"wrong value %lu\n", ul);
1885 ok(ul == 1,
"wrong value %lu\n", ul);
1890 ok(
l == 0,
"wrong value %ld\n",
l);
1892 ok(
e == neg,
"e = %p, neg = %p\n",
e, neg);
1897 static const char str[] =
"string";
1905 res = p_strnlen(
str, 20);
1906 ok(
res == 6,
"Returned length = %d\n", (
int)
res);
1909 ok(
res == 3,
"Returned length = %d\n", (
int)
res);
1912 ok(
res == 0,
"Returned length = %d\n", (
int)
res);
1917 static const char no1[] =
"31923";
1918 static const char no2[] =
"-213312";
1919 static const char no3[] =
"12aa";
1920 static const char no4[] =
"abc12";
1921 static const char overflow[] =
"99999999999999999999";
1922 static const char neg_overflow[] =
"-99999999999999999999";
1923 static const char hex[] =
"0x123";
1924 static const char oct[] =
"000123";
1925 static const char blanks[] =
" 12 212.31";
1931 if(!p_strtoi64 || !p_strtoui64) {
1932 win_skip(
"_strtoi64 or _strtoui64 not found\n");
1937 res = p_strtoi64(no1,
NULL, 10);
1938 ok(
res == 31923,
"res != 31923\n");
1939 res = p_strtoi64(no2,
NULL, 10);
1940 ok(
res == -213312,
"res != -213312\n");
1941 res = p_strtoi64(no3,
NULL, 10);
1942 ok(
res == 12,
"res != 12\n");
1943 res = p_strtoi64(no4, &endpos, 10);
1944 ok(
res == 0,
"res != 0\n");
1945 ok(endpos == no4,
"Scanning was not stopped on first character\n");
1946 res = p_strtoi64(
hex, &endpos, 10);
1947 ok(
res == 0,
"res != 0\n");
1948 ok(endpos ==
hex+1,
"Incorrect endpos (%p-%p)\n",
hex, endpos);
1949 res = p_strtoi64(
oct, &endpos, 10);
1950 ok(
res == 123,
"res != 123\n");
1952 res = p_strtoi64(blanks, &endpos, 10);
1953 ok(
res == 12,
"res != 12\n");
1954 ok(endpos == blanks+10,
"Incorrect endpos (%p-%p)\n", blanks, endpos);
1958 res = p_strtoi64(overflow, &endpos, 10);
1960 ok(endpos == overflow+
strlen(overflow),
"Incorrect endpos (%p-%p)\n", overflow, endpos);
1964 res = p_strtoi64(neg_overflow, &endpos, 10);
1966 ok(endpos == neg_overflow+
strlen(neg_overflow),
"Incorrect endpos (%p-%p)\n", neg_overflow, endpos);
1970 res = p_strtoi64(no1, &endpos, 16);
1971 ok(
res == 203043,
"res != 203043\n");
1972 ok(endpos == no1+
strlen(no1),
"Incorrect endpos (%p-%p)\n", no1, endpos);
1973 res = p_strtoi64(no2, &endpos, 16);
1974 ok(
res == -2175762,
"res != -2175762\n");
1975 ok(endpos == no2+
strlen(no2),
"Incorrect endpos (%p-%p)\n", no2, endpos);
1976 res = p_strtoi64(no3, &endpos, 16);
1977 ok(
res == 4778,
"res != 4778\n");
1978 ok(endpos == no3+
strlen(no3),
"Incorrect endpos (%p-%p)\n", no3, endpos);
1979 res = p_strtoi64(no4, &endpos, 16);
1980 ok(
res == 703506,
"res != 703506\n");
1981 ok(endpos == no4+
strlen(no4),
"Incorrect endpos (%p-%p)\n", no4, endpos);
1982 res = p_strtoi64(
hex, &endpos, 16);
1983 ok(
res == 291,
"res != 291\n");
1985 res = p_strtoi64(
oct, &endpos, 16);
1986 ok(
res == 291,
"res != 291\n");
1988 res = p_strtoi64(blanks, &endpos, 16);
1989 ok(
res == 18,
"res != 18\n");
1990 ok(endpos == blanks+10,
"Incorrect endpos (%p-%p)\n", blanks, endpos);
1994 res = p_strtoi64(
hex, &endpos, 36);
1995 ok(
res == 1541019,
"res != 1541019\n");
2000 res = p_strtoi64(no1, &endpos, 0);
2001 ok(
res == 31923,
"res != 31923\n");
2002 ok(endpos == no1+
strlen(no1),
"Incorrect endpos (%p-%p)\n", no1, endpos);
2003 res = p_strtoi64(no2, &endpos, 0);
2004 ok(
res == -213312,
"res != -213312\n");
2005 ok(endpos == no2+
strlen(no2),
"Incorrect endpos (%p-%p)\n", no2, endpos);
2006 res = p_strtoi64(no3, &endpos, 10);
2007 ok(
res == 12,
"res != 12\n");
2008 ok(endpos == no3+2,
"Incorrect endpos (%p-%p)\n", no3, endpos);
2009 res = p_strtoi64(no4, &endpos, 10);
2010 ok(
res == 0,
"res != 0\n");
2011 ok(endpos == no4,
"Incorrect endpos (%p-%p)\n", no4, endpos);
2012 res = p_strtoi64(
hex, &endpos, 10);
2013 ok(
res == 0,
"res != 0\n");
2014 ok(endpos ==
hex+1,
"Incorrect endpos (%p-%p)\n",
hex, endpos);
2015 res = p_strtoi64(
oct, &endpos, 10);
2016 ok(
res == 123,
"res != 123\n");
2018 res = p_strtoi64(blanks, &endpos, 10);
2019 ok(
res == 12,
"res != 12\n");
2020 ok(endpos == blanks+10,
"Incorrect endpos (%p-%p)\n", blanks, endpos);
2024 ures = p_strtoui64(no1, &endpos, 0);
2025 ok(ures == 31923,
"ures != 31923\n");
2026 ok(endpos == no1+
strlen(no1),
"Incorrect endpos (%p-%p)\n", no1, endpos);
2027 ures = p_strtoui64(no2, &endpos, 0);
2028 ok(ures == -213312,
"ures != -213312\n");
2029 ok(endpos == no2+
strlen(no2),
"Incorrect endpos (%p-%p)\n", no2, endpos);
2030 ures = p_strtoui64(no3, &endpos, 10);
2031 ok(ures == 12,
"ures != 12\n");
2032 ok(endpos == no3+2,
"Incorrect endpos (%p-%p)\n", no3, endpos);
2033 ures = p_strtoui64(no4, &endpos, 10);
2034 ok(ures == 0,
"ures != 0\n");
2035 ok(endpos == no4,
"Incorrect endpos (%p-%p)\n", no4, endpos);
2036 ures = p_strtoui64(
hex, &endpos, 10);
2037 ok(ures == 0,
"ures != 0\n");
2038 ok(endpos ==
hex+1,
"Incorrect endpos (%p-%p)\n",
hex, endpos);
2039 ures = p_strtoui64(
oct, &endpos, 10);
2040 ok(ures == 123,
"ures != 123\n");
2042 ures = p_strtoui64(blanks, &endpos, 10);
2043 ok(ures == 12,
"ures != 12\n");
2044 ok(endpos == blanks+10,
"Incorrect endpos (%p-%p)\n", blanks, endpos);
2048 ures = p_strtoui64(overflow, &endpos, 10);
2050 ok(endpos == overflow+
strlen(overflow),
"Incorrect endpos (%p-%p)\n", overflow, endpos);
2054 ures = p_strtoui64(neg_overflow, &endpos, 10);
2055 ok(ures == 1,
"ures != 1\n");
2056 ok(endpos == neg_overflow+
strlen(neg_overflow),
"Incorrect endpos (%p-%p)\n", neg_overflow, endpos);
2079 static const struct {
2085 {
"12.1", 4, 12.1 },
2086 {
"-13.721", 7, -13.721 },
2088 {
".21e12", 6, 210000000000.0 },
2089 {
"214353e-3", 9, 214.353 },
2091 {
"12.1d2", 6, 12.1e2 },
2094 {
"-0.1", 4, -0.1 },
2095 {
"0.1281832188491894198128921", 27, 0.1281832188491894198128921 },
2096 {
"0.82181281288121", 16, 0.82181281288121 },
2097 {
"21921922352523587651128218821", 29, 21921922352523587651128218821.0 },
2098 {
"0.1d238", 7, 0.1e238 },
2099 {
"0.1D-4736", 9, 0,
ERANGE },
2100 {
"3.4028234663852887e38", 21,
FLT_MAX },
2101 {
"1.1754943508222875e-38", 22,
FLT_MIN },
2102 {
"1.7976931348623158e+308", 23,
DBL_MAX },
2104 {
"2.2250738585072014e-308", 23,
DBL_MIN },
2105 {
"-1.7976931348623158e+308", 24, -
DBL_MAX },
2113 const char overflow[] =
"1d9999999999999999999";
2122 if ((
i == 19) && IsReactOS())
2124 skip(
"Skipping i == 19, because it crashes on ReactOS\n");
2134 "%d) errno = %d\n",
i,
errno);
2143 ok(
d == 0.0,
"d = %.16e\n",
d);
2147 end = (
char *)0xdeadbeef;
2149 ok(
d == 0.0,
"d = %.16e\n",
d);
2151 ok(!
end,
"incorrect end ptr %p\n",
end);
2155 ok(
d == 0.0,
"d = %.16e\n",
d);
2161 win_skip(
"system with limited locales\n");
2166 ok(
d == 12.0,
"d = %.16e\n",
d);
2169 ok(
d == 12.1,
"d = %.16e\n",
d);
2176 ok(
end == overflow+21,
"incorrect end (%d)\n", (
int)(
end-overflow));
2185 static const wchar_t wSimple[] =
L"text";
2186 static const wchar_t wHiragana[] =
L"\x3042\x3043";
2187 static const char mSimple[] =
"text";
2188 static const char mHiragana[] = { 0x82,0xa0,0x82,0xa1,0 };
2190 const wchar_t *pwstr;
2198 wOut[4] =
'!'; wOut[5] =
'\0';
2199 mOut[4] =
'!'; mOut[5] =
'\0';
2205 ok(
ret == -1,
"mbstowcs did not return -1\n");
2210 ok(
ret == 4,
"mbstowcs did not return 4\n");
2213 ok(
ret == 4,
"mbstowcs did not return 4\n");
2215 ok(wOut[4] ==
'!',
"wOut[4] != \'!\'\n");
2218 ok(
ret == 0,
"mbstowcs did not return 0, got %d\n", (
int)
ret);
2221 ok(
ret == 0,
"mbstowcs did not return 0, got %d\n", (
int)
ret);
2225 ok(
ret == 4,
"wcstombs did not return 4\n");
2228 ok(
ret == 4,
"wcstombs did not return 4\n");
2229 ok(!
memcmp(mOut, mSimple, 5*
sizeof(
char)),
"mOut = %s\n", mOut);
2232 ok(
ret == 2,
"wcstombs did not return 2\n");
2233 ok(!
memcmp(mOut, mSimple, 5*
sizeof(
char)),
"mOut = %s\n", mOut);
2236 ok(
ret == 0,
"wcstombs did not return 0, got %d\n", (
int)
ret);
2239 ok(
ret == 0,
"wcstombs did not return 0, got %d\n", (
int)
ret);
2240 ok(!mOut[0],
"mOut = %s\n", mOut);
2245 ret = pwcsrtombs(mOut, &pwstr, 4, &
err);
2246 ok(
ret == 4,
"wcsrtombs did not return 4\n");
2248 ok(pwstr == wSimple+4,
"pwstr = %p (wszSimple = %p)\n", pwstr, wSimple);
2249 ok(!
memcmp(mOut, mSimple,
ret),
"mOut = %s\n", mOut);
2252 ret = pwcsrtombs(mOut, &pwstr, 5,
NULL);
2253 ok(
ret == 4,
"wcsrtombs did not return 4\n");
2254 ok(pwstr ==
NULL,
"pwstr != NULL\n");
2255 ok(!
memcmp(mOut, mSimple,
sizeof(mSimple)),
"mOut = %s\n", mOut);
2259 win_skip(
"Japanese_Japan.932 locale not available\n");
2264 ok(
ret == 2,
"mbstowcs did not return 2\n");
2268 ok(
ret == 0,
"mbstowcs did not return 0, got %d\n", (
int)
ret);
2273 ok(
ret == -1,
"mbstowcs did not return -1\n");
2277 ok(
ret == 4,
"wcstombs did not return 4\n");
2278 ok(!
memcmp(mOut, mHiragana,
sizeof(mHiragana)),
"mOut = %s\n", mOut);
2281 ok(
ret == 0,
"wcstombs did not return 0, got %d\n", (
int)
ret);
2282 ok(!mOut[0],
"mOut = %s\n", mOut);
2284 if(!pmbstowcs_s || !pwcstombs_s) {
2286 win_skip(
"mbstowcs_s or wcstombs_s not available\n");
2292 ok(
ret == 1,
"mbstowcs_s did not return 0\n");
2293 ok(!wOut[0],
"wOut[0] = %d\n", wOut[0]);
2297 ok(
ret == 5,
"mbstowcs_s did not return 5\n");
2302 ok(
ret == 3,
"mbstowcs_s did not return 3\n");
2307 ok(
ret == 1,
"mbstowcs_s did not return 1, got %d\n", (
int)
ret);
2310 err = pmbstowcs_s(&
ret,
NULL, 0, mHiragana, 1);
2312 ok(
ret == 3,
"mbstowcs_s did not return 3\n");
2316 ok(
ret == 5,
"wcstombs_s did not return 5\n");
2317 ok(!
memcmp(mOut, mSimple,
sizeof(mSimple)),
"mOut = %s\n", mOut);
2321 ok(
ret == 5,
"wcstombs_s did not return 5\n");
2322 ok(!
memcmp(mOut, mHiragana,
sizeof(mHiragana)),
"mOut = %s\n", mOut);
2326 ok(
ret == 1,
"wcstombs_s did not return 1, got %d\n", (
int)
ret);
2327 ok(!mOut[0],
"mOut = %s\n", mOut);
2329 err = pwcstombs_s(&
ret,
NULL, 0, wHiragana, 1);
2331 ok(
ret == 5,
"wcstombs_s did not return 5\n");
2335 win_skip(
"wcsrtombs not available\n");
2341 ret = pwcsrtombs(mOut, &pwstr, 4, &
err);
2342 ok(
ret == 4,
"wcsrtombs did not return 4\n");
2344 ok(pwstr == wSimple+4,
"pwstr = %p (wszSimple = %p)\n", pwstr, wSimple);
2345 ok(!
memcmp(mOut, mSimple,
ret),
"mOut = %s\n", mOut);
2348 ret = pwcsrtombs(mOut, &pwstr, 5,
NULL);
2349 ok(
ret == 4,
"wcsrtombs did not return 4\n");
2350 ok(pwstr ==
NULL,
"pwstr != NULL\n");
2351 ok(!
memcmp(mOut, mSimple,
sizeof(mSimple)),
"mOut = %s\n", mOut);
2355 win_skip(
"mbsrtowcs not available\n");
2361 ok(
ret == 2,
"mbsrtowcs did not return 2\n");
2362 ok(pmbstr == mHiragana,
"pmbstr = %p, expected %p\n", pmbstr, mHiragana);
2365 ret = p_mbsrtowcs(wOut, &pmbstr, 6,
NULL);
2366 ok(
ret == 2,
"mbsrtowcs did not return 2\n");
2368 ok(!pmbstr,
"pmbstr != NULL\n");
2370 state = mHiragana[0];
2371 pmbstr = mHiragana+1;
2372 ret = p_mbsrtowcs(wOut, &pmbstr, 6, &
state);
2373 ok(
ret == 2,
"mbsrtowcs did not return 2\n");
2374 ok(wOut[0] == 0x3042,
"wOut[0] = %x\n", wOut[0]);
2375 ok(wOut[1] == 0xff61,
"wOut[1] = %x\n", wOut[1]);
2376 ok(wOut[2] == 0,
"wOut[2] = %x\n", wOut[2]);
2377 ok(!pmbstr,
"pmbstr != NULL\n");
2381 ok(
ret == -1,
"mbsrtowcs did not return -1\n");
2384 if(!p_mbsrtowcs_s) {
2386 win_skip(
"mbsrtowcs_s not available\n");
2392 ok(
ret == -1,
"mbsrtowcs_s did not return -1\n");
2395 ok(
ret == -1,
"mbsrtowcs_s did not return -1\n");
2397 err = p_mbsrtowcs_s(&
ret, wOut, 0, &pmbstr, 6,
NULL);
2398 ok(
ret == -1,
"mbsrtowcs_s did not return -1\n");
2404 ok(
ret == 3,
"mbsrtowcs_s did not return 3\n");
2406 ok(pmbstr == mHiragana,
"pmbstr = %p, expected %p\n", pmbstr, mHiragana);
2410 err = p_mbsrtowcs_s(&
ret, wOut, 1, &pmbstr, 6,
NULL);
2411 ok(
ret == 2,
"mbsrtowcs_s did not return 2\n");
2413 ok(!wOut[0],
"wOut[0] = '%c'\n", wOut[0]);
2414 ok(pmbstr == mHiragana+2,
"pmbstr = %p, expected %p\n", pmbstr, mHiragana+2);
2418 err = p_mbsrtowcs_s(&
ret, wOut, 2, &pmbstr, 6,
NULL);
2419 ok(
ret == 3,
"mbsrtowcs_s did not return 3\n");
2421 ok(!wOut[0],
"wOut[0] = '%c'\n", wOut[0]);
2422 ok(pmbstr == mHiragana+4,
"pmbstr = %p, expected %p\n", pmbstr, mHiragana+4);
2426 err = p_mbsrtowcs_s(&
ret, wOut, 3, &pmbstr, 6,
NULL);
2427 ok(
ret == 3,
"mbsrtowcs_s did not return 3\n");
2429 ok(!pmbstr,
"pmbstr != NULL\n");
2438 const wchar_t *wstr;
2455 {
L"", 0,
NULL, 0, 1, 0,
"English_United States.1252" },
2456 {
L"\xfffd", 1,
NULL, 0, 0,
EILSEQ,
"English_United States.1252" },
2457 {
L"\xfffd", 1,
"", 1, 0,
EILSEQ,
"English_United States.1252" },
2458 {
L"\xfffd", 1,
"", 6, 0,
EILSEQ,
"English_United States.1252" },
2459 {
L"text",
_TRUNCATE,
"text", 5, 5, 0,
"English_United States.1252" },
2461 {
L"text", 5,
"", 3, 0,
ERANGE,
"English_United States.1252" },
2469 if(!p__create_locale) {
2470 win_skip(
"_create_locale not available\n");
2494 "%d: expected out %s, got %s for '%s' in locale %s\n",
i,
tests[
i].
str,
out,
2507 win_skip(
"Skipping _gcvt tests\n");
2526 err = p_gcvt_s(
buf, 5, 1.2, 10);
2528 ok(
buf[0] ==
'\0',
"buf[0] = %c\n",
buf[0]);
2531 err = p_gcvt_s(
buf, 4, 123456, 2);
2533 ok(
buf[0] ==
'\0',
"buf[0] = %c\n",
buf[0]);
2543 win_skip(
"Skipping _itoa_s tests\n");
2548 ret = p_itoa_s(0,
NULL, 0, 0);
2549 ok(
ret ==
EINVAL,
"Expected _itoa_s to return EINVAL, got %d\n",
ret);
2555 ok(
ret ==
EINVAL,
"Expected _itoa_s to return EINVAL, got %d\n",
ret);
2557 ok(
buffer[0] ==
'X',
"Expected the output buffer to be untouched\n");
2562 ok(
ret ==
EINVAL,
"Expected _itoa_s to return EINVAL, got %d\n",
ret);
2564 ok(
buffer[0] ==
'\0',
"Expected the output buffer to be null terminated\n");
2569 ok(
ret ==
EINVAL,
"Expected _itoa_s to return EINVAL, got %d\n",
ret);
2571 ok(
buffer[0] ==
'\0',
"Expected the output buffer to be null terminated\n");
2575 ret = p_itoa_s(12345678,
buffer, 4, 10);
2576 ok(
ret ==
ERANGE,
"Expected _itoa_s to return ERANGE, got %d\n",
ret);
2579 "Expected the output buffer to be null terminated with truncated output\n");
2583 ret = p_itoa_s(12345678,
buffer, 8, 10);
2584 ok(
ret ==
ERANGE,
"Expected _itoa_s to return ERANGE, got %d\n",
ret);
2587 "Expected the output buffer to be null terminated with truncated output\n");
2591 ret = p_itoa_s(-12345678,
buffer, 9, 10);
2592 ok(
ret ==
ERANGE,
"Expected _itoa_s to return ERANGE, got %d\n",
ret);
2595 "Expected the output buffer to be null terminated with truncated output\n");
2597 ret = p_itoa_s(12345678,
buffer, 9, 10);
2598 ok(
ret == 0,
"Expected _itoa_s to return 0, got %d\n",
ret);
2600 "Expected output buffer string to be \"12345678\", got \"%s\"\n",
2604 ok(
ret == 0,
"Expected _itoa_s to return 0, got %d\n",
ret);
2606 "Expected output buffer string to be \"1010101010101010\", got \"%s\"\n",
2610 ok(
ret == 0,
"Expected _itoa_s to return 0, got %d\n",
ret);
2612 "Expected output buffer string to be \"nell\", got \"%s\"\n",
2616 ok(
ret == 0,
"Expected _itoa_s to return 0, got %d\n",
ret);
2618 "Expected output buffer string to be \"hag\", got \"%s\"\n",
2622 ok(
ret == 0,
"Expected _itoa_s to return 0, got %d\n",
ret);
2624 "Expected output buffer string to be \"-12345678\", got \"%s\"\n",
2629 "Expected output buffer string to be \"10\", got \"%s\"\n",
buffer);
2639 win_skip(
"Skipping _strlwr_s tests\n");
2645 ok(
ret ==
EINVAL,
"Expected _strlwr_s to return EINVAL, got %d\n",
ret);
2650 ok(
ret ==
EINVAL,
"Expected _strlwr_s to return EINVAL, got %d\n",
ret);
2655 ok(
ret ==
EINVAL,
"Expected _strlwr_s to return EINVAL, got %d\n",
ret);
2661 ok(
ret ==
EINVAL,
"Expected _strlwr_s to return EINVAL, got %d\n",
ret);
2664 "Expected the output buffer to be \"\\0oRrIsTeR\"\n");
2668 ret = p_strlwr_s(
buffer,
sizeof(
"GoRrIsTeR") - 1);
2669 ok(
ret ==
EINVAL,
"Expected _strlwr_s to return EINVAL, got %d\n",
ret);
2672 "Expected the output buffer to be \"\\0oRrIsTeR\"\n");
2675 ret = p_strlwr_s(
buffer,
sizeof(
"GoRrIsTeR"));
2676 ok(
ret == 0,
"Expected _strlwr_s to return 0, got %d\n",
ret);
2678 "Expected the output buffer to be \"gorrister\", got \"%s\"\n",
2681 memcpy(
buffer,
"GoRrIsTeR\0ELLEN",
sizeof(
"GoRrIsTeR\0ELLEN"));
2683 ok(
ret == 0,
"Expected _strlwr_s to return 0, got %d\n",
ret);
2684 ok(!
memcmp(
buffer,
"gorrister\0ELLEN",
sizeof(
"gorrister\0ELLEN")),
2685 "Expected the output buffer to be \"gorrister\\0ELLEN\", got \"%s\"\n",
2688 ret = p_strlwr_s((
char *)
"already_lowercase",
sizeof(
"already_lowercase"));
2689 ok(
ret == 0,
"Expected _strlwr_s to return 0, got %d\n",
ret);
2700 win_skip(
"skipping wcsncat_s tests\n");
2710 ok(
dst[0] ==
'a',
"dst %x\n",
dst[0]);
2721 ok(
dst[0] ==
'a',
"dst %x\n",
dst[0]);
2747 win_skip(
"skipping wcsncat_s tests\n");
2757 ok(
dst[0] ==
'a',
"dst %x\n",
dst[0]);
2760 ok(
dst[0] ==
'a',
"dst %x\n",
dst[0]);
2769 ok(
dst[0] ==
'a',
"dst %x\n",
dst[0]);
2789 unsigned char dest[16];
2790 const unsigned char first[] =
"dinosaur";
2791 const unsigned char second[] =
"duck";
2796 win_skip(
"Skipping _mbsnbcat_s tests\n");
2802 ok(
ret == 0,
"Expected _mbsnbcat_s to return 0, got %d\n",
ret);
2806 ok(
ret ==
EINVAL,
"Expected _mbsnbcat_s to return EINVAL, got %d\n",
ret);
2811 ok(
ret ==
EINVAL,
"Expected _mbsnbcat_s to return EINVAL, got %d\n",
ret);
2817 ok(
ret ==
EINVAL,
"Expected _mbsnbcat_s to return EINVAL, got %d\n",
ret);
2819 ok(
dest[0] ==
'X',
"Expected the output buffer to be untouched\n");
2823 ret = p_mbsnbcat_s(
dest, 0, second, 0);
2824 ok(
ret ==
EINVAL,
"Expected _mbsnbcat_s to return EINVAL, got %d\n",
ret);
2826 ok(
dest[0] ==
'X',
"Expected the output buffer to be untouched\n");
2831 ok(
ret ==
EINVAL,
"Expected _mbsnbcat_s to return EINVAL, got %d\n",
ret);
2833 ok(
dest[0] ==
'\0',
"Expected the output buffer to be null terminated\n");
2838 ok(
ret ==
EINVAL,
"Expected _mbsnbcat_s to return EINVAL, got %d\n",
ret);
2840 ok(
dest[0] ==
'\0',
"Expected the output buffer to be null terminated\n");
2844 ret = p_mbsnbcat_s(
dest,
sizeof(
dest), second,
sizeof(second));
2845 ok(
ret == 0,
"Expected _mbsnbcat_s to return 0, got %d\n",
ret);
2847 "Expected the output buffer string to be \"duck\"\n");
2852 ret = p_mbsnbcat_s(
dest,
sizeof(
dest), second, 0);
2853 ok(
ret == 0,
"Expected _mbsnbcat_s to return 0, got %d\n",
ret);
2855 "Expected the output buffer string to be \"dinosaur\"\n");
2859 ret = p_mbsnbcat_s(
dest,
sizeof(
dest), second,
sizeof(second));
2860 ok(
ret == 0,
"Expected _mbsnbcat_s to return 0, got %d\n",
ret);
2861 ok(!
memcmp(
dest,
"dinosaurduck",
sizeof(
"dinosaurduck")),
2862 "Expected the output buffer string to be \"dinosaurduck\"\n");
2866 ret = p_mbsnbcat_s(
dest,
sizeof(
dest), second,
sizeof(second) + 1);
2867 ok(
ret == 0,
"Expected _mbsnbcat_s to return 0, got %d\n",
ret);
2868 ok(!
memcmp(
dest,
"dinosaurduck",
sizeof(
"dinosaurduck")),
2869 "Expected the output buffer string to be \"dinosaurduck\"\n");
2873 ret = p_mbsnbcat_s(
dest,
sizeof(
dest), second,
sizeof(second) - 1);
2874 ok(
ret == 0,
"Expected _mbsnbcat_s to return 0, got %d\n",
ret);
2875 ok(!
memcmp(
dest,
"dinosaurduck",
sizeof(
"dinosaurduck")),
2876 "Expected the output buffer string to be \"dinosaurduck\"\n");