40 static char buf[2][1024];
52#define expect_eq(expr, value, type, format) { type ret = (expr); ok((value) == ret, #expr " expected " format " got " format "\n", value, ret); }
53#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)); }
65static int (
__cdecl *p__mbscpy_s)(
unsigned char*,
size_t,
const unsigned char*);
108static int (
__cdecl *p__mbccpy_s)(
unsigned char*,
size_t,
int*,
const unsigned char*);
113#define SETNOFAIL(x,y) x = (void*)GetProcAddress(hMsvcrt,y)
114#define SET(x,y) SETNOFAIL(x,y); ok(x != NULL, "Export '%s' not found\n", y)
119 char original[] =
"BADCFEHGJILKNMPORQTSVUXWZY@#";
120 char expected1[] =
"ABCDEFGHIJKLMNOPQRSTUVWXYZ@#";
121 char expected2[] =
"ABCDEFGHIJKLMNOPQRSTUVWX$";
130 memset(to,
'$',
sizeof(to));
135 ok(
memcmp(to,
expected1,testsize) == 0,
"Testing even size %d returned '%*.*s'\n", testsize, testsize, testsize, to);
138 memset(to,
'$',
sizeof(to));
143 ok(
memcmp(to,
expected2,testsize) == 0,
"Testing odd size %d returned '%*.*s'\n", testsize, testsize, testsize, to);
146 memset(to,
'$',
sizeof(to));
149 memcpy(to, original, testsize);
150 _swab( to, to, testsize );
151 ok(
memcmp(to,
expected1,testsize) == 0,
"Testing overlapped size %d returned '%*.*s'\n", testsize, testsize, testsize, to);
154 memset(to,
'$',
sizeof(to));
159 ok(
memcmp(to,
expected3,testsize) == 0,
"Testing small size %d returned '%*.*s'\n", testsize, testsize, testsize, to);
173 printf(
"static int result_cp_%d_mbctype[] = { ",
cp);
174 for (
i = 1;
i < 257;
i++)
191static int result_cp_932_mbctype[] = { 0x0,65, 0x8,1, 0x18,26, 0x8,6, 0x28,26, 0x8,4,
192 0x0,1, 0x8,1, 0xc,31, 0x8,1, 0xa,5, 0x9,58, 0xc,29, 0,3 };
193static int result_cp_936_mbctype[] = { 0x0,65, 0x8,1, 0x18,26, 0x8,6, 0x28,26, 0x8,6,
195static int result_cp_949_mbctype[] = { 0x0,66, 0x18,26, 0x8,6, 0x28,26, 0x8,6, 0xc,126,
197static int result_cp_950_mbctype[] = { 0x0,65, 0x8,1, 0x18,26, 0x8,6, 0x28,26, 0x8,4,
198 0x0,2, 0x4,32, 0xc,94, 0,1 };
206 for (
i = 0;
i < 256;
i++)
219#define test_codepage(num) test_cp_table(num, result_cp_##num##_mbctype);
227 unsigned char *mbstring = (
unsigned char *)
"\xb0\xb1\xb2 \xb3\xb4 \xb5";
228 unsigned char *mbstring2 = (
unsigned char *)
"\xb0\xb1\xb2\xb3Q\xb4\xb5";
229 unsigned char *mbsonlylead = (
unsigned char *)
"\xb0\0\xb1\xb2 \xb3";
230 unsigned char buf[16];
262 ok(
_ismbblead(0x1234b0),
"0x1234b0 should not be a lead byte\n");
335 expect_eq(p__mbsnlen(mbstring, 8), 8,
int,
"%d");
336 expect_eq(p__mbsnlen(mbstring, 9), 4,
int,
"%d");
337 expect_eq(p__mbsnlen(mbstring, 10), 4,
int,
"%d");
338 expect_eq(p__mbsnlen(mbsonlylead, 0), 0,
int,
"%d");
339 expect_eq(p__mbsnlen(mbsonlylead, 1), 1,
int,
"%d");
340 expect_eq(p__mbsnlen(mbsonlylead, 2), 0,
int,
"%d");
341 expect_eq(p__mbsnlen(mbstring2, 7), 7,
int,
"%d");
342 expect_eq(p__mbsnlen(mbstring2, 8), 4,
int,
"%d");
343 expect_eq(p__mbsnlen(mbstring2, 9), 4,
int,
"%d");
351 expect_eq(p_mbrlen((
const char*)mbstring, 2,
NULL), 2,
int,
"%d");
352 expect_eq(p_mbrlen((
const char*)&mbstring[2], 2,
NULL), 2,
int,
"%d");
353 expect_eq(p_mbrlen((
const char*)&mbstring[3], 2,
NULL), 1,
int,
"%d");
354 expect_eq(p_mbrlen((
const char*)mbstring, 1,
NULL), -2,
int,
"%d");
355 expect_eq(p_mbrlen((
const char*)mbstring, 1, &
state), -2,
int,
"%d");
356 ok(
state == mbstring[0],
"incorrect state value (%x)\n",
state);
357 expect_eq(p_mbrlen((
const char*)&mbstring[1], 1, &
state), 2,
int,
"%d");
367 ok(
dst == 0x6c28,
"dst = %x, expected 0x6c28\n",
dst);
369 ok(
dst == 0x3f,
"dst = %x, expected 0x3f\n",
dst);
371 ok(
dst == 0x20,
"dst = %x, expected 0x20\n",
dst);
373 ok(
dst == 0,
"dst = %x, expected 0\n",
dst);
375 ok(
dst == 0,
"dst = %x, expected 0\n",
dst);
376 ok(
state == mbstring[0],
"incorrect state value (%x)\n",
state);
378 ok(
dst == 0x6c28,
"dst = %x, expected 0x6c28\n",
dst);
395 err = p__mbccpy_s(
buf, 0, &copied, mbstring);
397 ok(!copied,
"copied = %d\n", copied);
398 ok(
buf[0] == 0xff,
"buf[0] = %x\n",
buf[0]);
402 err = p__mbccpy_s(
buf, 1, &copied, mbstring);
404 ok(!copied,
"copied = %d\n", copied);
405 ok(!
buf[0],
"buf[0] = %x\n",
buf[0]);
409 err = p__mbccpy_s(
buf, 2, &copied, mbstring);
410 ok(!
err,
"_mbccpy_s returned %d\n",
err);
411 ok(copied == 2,
"copied = %d\n", copied);
416 err = p__mbccpy_s(
buf, 2, &copied, (
unsigned char *)
"\xb0");
418 ok(copied == 1,
"copied = %d\n", copied);
453 step =
_mbsinc(mbstring) - mbstring;
454 ok(step == 2,
"_mbsinc adds %d (exp. 2)\n", step);
455 step =
_mbsinc(&mbstring[2]) - &mbstring[2];
456 ok(step == 2,
"_mbsinc adds %d (exp. 2)\n", step);
458 step =
_mbsninc(mbsonlylead, 1) - mbsonlylead;
459 ok(step == 0,
"_mbsninc adds %d (exp. 0)\n", step);
460 step =
_mbsninc(mbsonlylead, 2) - mbsonlylead;
461 ok(step == 0,
"_mbsninc adds %d (exp. 0)\n", step);
462 step =
_mbsninc(mbstring2, 0) - mbstring2;
463 ok(step == 0,
"_mbsninc adds %d (exp. 2)\n", step);
464 step =
_mbsninc(mbstring2, 1) - mbstring2;
465 ok(step == 2,
"_mbsninc adds %d (exp. 2)\n", step);
466 step =
_mbsninc(mbstring2, 2) - mbstring2;
467 ok(step == 4,
"_mbsninc adds %d (exp. 4)\n", step);
468 step =
_mbsninc(mbstring2, 3) - mbstring2;
469 ok(step == 5,
"_mbsninc adds %d (exp. 5)\n", step);
470 step =
_mbsninc(mbstring2, 4) - mbstring2;
471 ok(step == 7,
"_mbsninc adds %d (exp. 7)\n", step);
472 step =
_mbsninc(mbstring2, 5) - mbstring2;
473 ok(step == 7,
"_mbsninc adds %d (exp. 7)\n", step);
474 step =
_mbsninc(mbstring2, 17) - mbstring2;
475 ok(step == 7,
"_mbsninc adds %d (exp. 7)\n", step);
488 skip(
"Current locale has double-byte charset - could lead to false positives\n");
516 unsigned char str1[]=
"cabernet";
517 unsigned char str2[]=
"shiraz";
518 unsigned char set[]=
"abc";
519 unsigned char empty[]=
"";
520 unsigned char mbstr[]=
" 2019\x94\x4e" "6\x8c\x8e" "29\x93\xfa";
521 unsigned char mbset1[]=
"0123456789 \x94\x4e";
522 unsigned char mbset2[]=
" \x94\x4e\x8c\x8e";
523 unsigned char mbset3[]=
"\x8e";
527 ok(
ret==3,
"_mbsspn returns %d should be 3\n",
ret);
529 ok(
ret==0,
"_mbsspn returns %d should be 0\n",
ret);
531 ok(
ret==0,
"_mbsspn returns %d should be 0\n",
ret);
535 ok(
ret==8,
"_mbsspn returns %d should be 8\n",
ret);
537 ok(
ret==1,
"_mbsspn returns %d should be 1\n",
ret);
539 ok(
ret==0,
"_mbsspn returns %d should be 0\n",
ret);
541 ok(
ret==2,
"_mbsspn returns %d should be 2\n",
ret);
543 ok(
ret==14,
"_mbsspn returns %d should be 14\n",
ret);
550 unsigned char str1[]=
"cabernet";
551 unsigned char str2[]=
"shiraz";
552 unsigned char set[]=
"abc";
553 unsigned char empty[]=
"";
554 unsigned char full[]=
"abcenrt";
555 unsigned char mbstr[]=
" 2019\x94\x4e" "6\x8c\x8e" "29\x93\xfa";
556 unsigned char mbset1[]=
"0123456789 \x94\x4e";
557 unsigned char mbset2[]=
" \x94\x4e\x8c\x8e";
562 ok(
ret[0]==
'e',
"_mbsspnp returns %c should be e\n",
ret[0]);
564 ok(
ret[0]==
's',
"_mbsspnp returns %c should be s\n",
ret[0]);
566 ok(
ret[0]==
'c',
"_mbsspnp returns %c should be c\n",
ret[0]);
568 ok(
ret==
NULL,
"_mbsspnp returns %p should be NULL\n",
ret);
572 ok(
ret==mbstr+8,
"_mbsspnp returns %p should be %p\n",
ret, mbstr+8);
574 ok(
ret==mbstr+1,
"_mbsspnp returns %p should be %p\n",
ret, mbstr+1);
576 ok(
ret==mbstr+8,
"_mbsspnp returns %p should be %p\n",
ret, mbstr+8);
578 ok(
ret==mbstr+10,
"_mbsspnp returns %p should be %p\n",
ret, mbstr+10);
587 ok(
str == 0,
"strdup returns %s should be 0\n",
str);
594 const char small[] =
"small";
595 const char big[] =
"atoolongstringforthislittledestination";
606 ok(
ret == 0,
"Copying a string into a big enough destination returned %d, expected 0\n",
ret);
609 "Unexpected return data from strcpy_s: 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x\n",
614 ok(
ret ==
EINVAL,
"Copying into a destination of size 0 returned %d, expected EINVAL\n",
ret);
617 "Unexpected return data from strcpy_s: 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x\n",
620 ok(
ret ==
EINVAL,
"Copying into a destination of size 0 returned %d, expected EINVAL\n",
ret);
623 "Unexpected return data from strcpy_s: 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x\n",
628 ok(
ret ==
ERANGE,
"Copying a big string in a small location returned %d, expected ERANGE\n",
ret);
631 "Unexpected return data from strcpy_s: 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x\n",
636 ok(
ret ==
EINVAL,
"Copying from a NULL source string returned %d, expected EINVAL\n",
ret);
639 "Unexpected return data from strcpy_s: 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x\n",
643 ok(
ret ==
EINVAL,
"Copying a big string a NULL dest returned %d, expected EINVAL\n",
ret);
651 "Unexpected return data from strcpy: 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x\n",
655#define okchars(dst, b0, b1, b2, b3, b4, b5, b6, b7) \
656 ok(dst[0] == b0 && dst[1] == b1 && dst[2] == b2 && dst[3] == b3 && \
657 dst[4] == b4 && dst[5] == b5 && dst[6] == b6 && dst[7] == b7, \
658 "Bad result: 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x\n",\
659 dst[0], dst[1], dst[2], dst[3], dst[4], dst[5], dst[6], dst[7])
664 static const char tiny[] = {
'T',0,
'I',
'N',
'Y',0};
665 static const char big[] = {
'a',
't',
'o',
'o',
'l',
'o',
'n',
'g',
's',
't',
'r',
'i',
'n',
'g',0};
675 ok(
ret == 0,
"Copying a buffer into a big enough destination returned %d, expected 0\n",
ret);
676 okchars(
dest, tiny[0], tiny[1], tiny[2], tiny[3], tiny[4], tiny[5],
'X',
'X');
682 ok(
ret ==
ERANGE,
"Copying a big buffer to a small destination returned %d, expected ERANGE\n",
ret);
690 ok(
ret ==
EINVAL,
"Copying a NULL source buffer returned %d, expected EINVAL\n",
ret);
698 ok(
ret ==
ERANGE,
"Copying into a destination of size 0 returned %d, expected ERANGE\n",
ret);
700 okchars(
dest,
'X',
'X',
'X',
'X',
'X',
'X',
'X',
'X');
705 ok(
ret ==
EINVAL,
"Copying a tiny buffer to a big NULL destination returned %d, expected EINVAL\n",
ret);
712 ok(
ret ==
EINVAL,
"Copying a NULL buffer into a destination of size 0 returned %d, expected EINVAL\n",
ret);
714 okchars(
dest,
'X',
'X',
'X',
'X',
'X',
'X',
'X',
'X');
717 ok(!
ret,
"memcpy_s returned %d\n",
ret);
718 ok(!
memcmp(
buf, big,
sizeof(big)),
"unexpected buf\n");
721 ok(!
ret,
"memcpy_s returned %d\n",
ret);
722 ok(!
memcmp(
buf + 1, big,
sizeof(big)),
"unexpected buf\n");
725 ok(!
ret,
"memcpy_s returned %d\n",
ret);
726 ok(!
memcmp(
buf, big,
sizeof(big)),
"unexpected buf\n");
732 static const char tiny[] = {
'T',0,
'I',
'N',
'Y',0};
733 static const char big[] = {
'a',
't',
'o',
'o',
'l',
'o',
'n',
'g',
's',
't',
'r',
'i',
'n',
'g',0};
743 ok(
ret == 0,
"Moving a buffer into a big enough destination returned %d, expected 0\n",
ret);
744 okchars(
dest, tiny[0], tiny[1], tiny[2], tiny[3], tiny[4], tiny[5],
'X',
'X');
749 ok(
ret == 0,
"Moving a buffer up one char returned %d, expected 0\n",
ret);
750 okchars(
dest, big[0], big[0], big[1], big[2], big[3], big[4], big[5], big[6]);
756 ok(
ret ==
ERANGE,
"Moving a big buffer to a small destination returned %d, expected ERANGE\n",
ret);
758 okchars(
dest,
'X',
'X',
'X',
'X',
'X',
'X',
'X',
'X');
764 ok(
ret ==
EINVAL,
"Moving a NULL source buffer returned %d, expected EINVAL\n",
ret);
766 okchars(
dest,
'X',
'X',
'X',
'X',
'X',
'X',
'X',
'X');
772 ok(
ret ==
ERANGE,
"Moving into a destination of size 0 returned %d, expected ERANGE\n",
ret);
774 okchars(
dest,
'X',
'X',
'X',
'X',
'X',
'X',
'X',
'X');
779 ok(
ret ==
EINVAL,
"Moving a tiny buffer to a big NULL destination returned %d, expected EINVAL\n",
ret);
786 ok(
ret ==
EINVAL,
"Moving a NULL buffer into a destination of size 0 returned %d, expected EINVAL\n",
ret);
788 okchars(
dest,
'X',
'X',
'X',
'X',
'X',
'X',
'X',
'X');
794 const char *
small =
"sma";
806 ok(
ret == 0,
"strcat_s: Copying a string into a big enough destination returned %d, expected 0\n",
ret);
809 "Unexpected return data from strcpy_s: 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x\n",
812 ok(
ret == 0,
"strcat_s: Attaching a string to a big enough destination returned %d, expected 0\n",
ret);
815 "Unexpected return data from strcpy_s: 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x\n",
819 ok(
ret ==
ERANGE,
"strcat_s: Attaching a string to a filled up destination returned %d, expected ERANGE\n",
ret);
822 "Unexpected return data from strcpy_s: 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x\n",
830 ok(
ret ==
EINVAL,
"strcat_s: Source len = 0 returned %d, expected EINVAL\n",
ret);
833 "Unexpected return data from strcpy_s: 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x\n",
837 ok(
ret ==
EINVAL,
"strcat_s: len = 0 and src = NULL returned %d, expected EINVAL\n",
ret);
840 "Unexpected return data from strcpy_s: 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x\n",
844 ok(
ret ==
EINVAL,
"strcat_s: Sourcing from NULL returned %d, expected EINVAL\n",
ret);
847 "Unexpected return data from strcpy_s: 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x\n",
851 ok(
ret ==
EINVAL,
"strcat_s: Writing to a NULL string returned %d, expected EINVAL\n",
ret);
856 unsigned char dst[8],
src[4];
884 ok(
err == 0,
"_mbscat_s returned %d\n",
err);
889 ok(!
dst[0],
"dst[0] = %c\n",
dst[0]);
890 ok(
dst[1] ==
'a',
"dst[1] = %c\n",
dst[1]);
901 ok(
err == 0,
"_mbscat_s returned %d\n",
err);
910 ok(
err == 0,
"_mbscat_s returned %d\n",
err);
936 unsigned char dest[8];
937 const unsigned char big[] =
"atoolongstringforthislittledestination";
938 const unsigned char small[] =
"small";
943 win_skip(
"_mbsnbcpy_s not found\n");
949 ok(
ret == 0,
"_mbsnbcpy_s: Copying a string into a big enough destination returned %d, expected 0\n",
ret);
952 "Unexpected return data from _mbsnbcpy_s: 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x\n",
958 ok(
ret ==
ERANGE,
"_mbsnbcpy_s: Copying a too long string returned %d, expected ERANGE\n",
ret);
961 "Unexpected return data from _mbsnbcpy_s: 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x\n",
965 ret = p_mbsnbcpy_s(
dest,
sizeof(
dest) - 2, big, 4);
966 ok(
ret == 0,
"_mbsnbcpy_s: Copying a too long string with a count cap returned %d, expected 0\n",
ret);
969 "Unexpected return data from _mbsnbcpy_s: 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x\n",
974 ok(
ret == 0,
"_mbsnbcpy_s: Copying more data than the source string len returned %d, expected 0\n",
ret);
977 "Unexpected return data from _mbsnbcpy_s: 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x\n",
983 const unsigned char src[] =
"source string";
984 unsigned char dest[16];
1002 ok(!
dest[0],
"dest buffer was not modified on invalid argument\n");
1008 ok(
dest[
sizeof(
src)] ==
'X',
"unused part of buffer was modified\n");
1013 ok(!
dest[0],
"incorrect dest buffer (%d)\n",
dest[0]);
1014 ok(
dest[1] ==
src[1],
"incorrect dest buffer (%d)\n",
dest[1]);
1019 static const WCHAR szLongText[] = {
'T',
'h',
'i',
's',
'A',
'L',
'o',
'n',
'g',
's',
't',
'r',
'i',
'n',
'g',0 };
1020 static WCHAR szDest[18];
1021 static WCHAR szDestShort[8];
1032 ret = p_wcscpy_s(
NULL, 18, szLongText);
1039 ret = p_wcscpy_s(szDest, 18,
NULL);
1042 ok(szDest[0] == 0,
"szDest[0] not 0, got %c\n", szDest[0]);
1047 ret = p_wcscpy_s(szDest, 0, szLongText);
1053 ok(szDest[0] == 0 ||
ret ==
EINVAL,
"szDest[0] not 0\n");
1056 ret = p_wcscpy_s(szDest, 18, szLongText);
1057 ok(
ret == 0,
"expected 0 got %d\n",
ret);
1058 ok(
lstrcmpW(szDest, szLongText) == 0,
"szDest != szLongText\n");
1061 ret = p_wcscpy_s(szDest, 18, szDest);
1062 ok(
ret == 0,
"expected 0 got %d\n",
ret);
1063 ok(
lstrcmpW(szDest, szLongText) == 0,
"szDest != szLongText\n");
1068 ret = p_wcscpy_s(szDestShort, 8, szLongText);
1071 ok(szDestShort[0] == 0,
"szDestShort[0] not 0\n");
1083 ret = p_wcsncpy_s(szDest, 18,
NULL, 1);
1085 ok(szDest[0] == 0,
"szDest[0] not 0\n");
1088 ret = p_wcsncpy_s(szDest, 18,
NULL, 0);
1089 ok(
ret == 0,
"expected ERROR_SUCCESS got %d\n",
ret);
1090 ok(szDest[0] == 0,
"szDest[0] not 0\n");
1093 ret = p_wcsncpy_s(szDest, 0, szLongText,
ARRAY_SIZE(szLongText));
1095 ok(szDest[0] == 0 ||
ret ==
EINVAL,
"szDest[0] not 0\n");
1097 ret = p_wcsncpy_s(szDest, 18, szLongText,
ARRAY_SIZE(szLongText));
1098 ok(
ret == 0,
"expected 0 got %d\n",
ret);
1099 ok(
lstrcmpW(szDest, szLongText) == 0,
"szDest != szLongText\n");
1102 ret = p_wcsncpy_s(szDestShort, 8, szLongText,
ARRAY_SIZE(szLongText));
1104 ok(szDestShort[0] == 0,
"szDestShort[0] not 0\n");
1107 ret = p_wcsncpy_s(szDest, 5, szLongText, -1);
1109 ok(szDest[4] == 0,
"szDest[4] not 0\n");
1112 ret = p_wcsncpy_s(
NULL, 0, (
void*)0xdeadbeef, 0);
1115 szDestShort[0] =
'1';
1117 ret = p_wcsncpy_s(szDestShort+1, 4, szDestShort, -1);
1119 ok(szDestShort[0]==
'1' && szDestShort[1]==
'1' && szDestShort[2]==
'1' && szDestShort[3]==
'1',
1125 static const WCHAR mixedString[] = {
'M',
'i',
'X',
'e',
'D',
'l',
'o',
'w',
1126 'e',
'r',
'U',
'P',
'P',
'E',
'R', 0};
1127 static const WCHAR expectedString[] = {
'M',
'I',
'X',
'E',
'D',
'L',
'O',
1128 'W',
'E',
'R',
'U',
'P',
'P',
'E',
1142 ok(
ret ==
EINVAL,
"Expected _wcsupr_s to fail with EINVAL, got %d\n",
ret);
1148 ok(
ret ==
EINVAL,
"Expected _wcsupr_s to fail with EINVAL, got %d\n",
ret);
1153 testBuffer[0] =
'\0';
1154 ret = p_wcsupr_s(testBuffer, 0);
1155 ok(
ret ==
EINVAL,
"Expected _wcsupr_s to fail with EINVAL, got %d\n",
ret);
1157 ok(testBuffer[0] ==
'\0',
"Expected the buffer to be unchanged\n");
1160 testBuffer[0] =
'\0';
1161 ret = p_wcsupr_s(testBuffer, 1);
1162 ok(
ret == 0,
"Expected _wcsupr_s to succeed, got %d\n",
ret);
1163 ok(testBuffer[0] ==
'\0',
"Expected the buffer to be unchanged\n");
1167 testBuffer[0] =
'x';
1168 ret = p_wcsupr_s(testBuffer, 0);
1169 ok(
ret ==
EINVAL,
"Expected _wcsupr_s to fail with EINVAL, got %d\n",
ret);
1171 ok(testBuffer[0] ==
'\0',
"Expected the first buffer character to be null\n");
1175 testBuffer[0] =
'x';
1176 ret = p_wcsupr_s(testBuffer, 1);
1177 ok(
ret ==
EINVAL,
"Expected _wcsupr_s to fail with EINVAL, got %d\n",
ret);
1179 ok(testBuffer[0] ==
'\0',
"Expected the first buffer character to be null\n");
1182 wcscpy(testBuffer, mixedString);
1184 ret = p_wcsupr_s(testBuffer, 0);
1185 ok(
ret ==
EINVAL,
"Expected _wcsupr_s to fail with EINVAL, got %d\n",
ret);
1187 ok(testBuffer[0] ==
'\0',
"Expected the first buffer character to be null\n");
1190 wcscpy(testBuffer, mixedString);
1192 ok(
ret == 0,
"Expected _wcsupr_s to succeed, got %d\n",
ret);
1193 ok(!
wcscmp(testBuffer, expectedString),
"Expected the string to be fully upper-case\n");
1196 wcscpy(testBuffer, mixedString);
1199 ok(
ret ==
EINVAL,
"Expected _wcsupr_s to fail with EINVAL, got %d\n",
ret);
1201 ok(testBuffer[0] ==
'\0',
"Expected the first buffer character to be null\n");
1204 wcscpy(testBuffer, mixedString);
1206 ok(
ret == 0,
"Expected _wcsupr_s to succeed, got %d\n",
ret);
1207 ok(!
wcscmp(testBuffer, expectedString),
"Expected the string to be fully upper-case\n");
1212 static const WCHAR mixedString[] = {
'M',
'i',
'X',
'e',
'D',
'l',
'o',
'w',
1213 'e',
'r',
'U',
'P',
'P',
'E',
'R', 0};
1214 static const WCHAR expectedString[] = {
'm',
'i',
'x',
'e',
'd',
'l',
'o',
1215 'w',
'e',
'r',
'u',
'p',
'p',
'e',
1244 ok(
buffer[0] == 0,
"expected empty string\n");
1250 ok(
buffer[0] == 0,
"expected buffer to be unchanged\n");
1258 ok(
buffer[0] ==
'\0',
"expected empty string\n");
1266 ok(
buffer[0] ==
'\0',
"expected empty string\n");
1274 ok(
buffer[0] ==
'\0',
"expected empty string\n");
1279 ok(
ret == 0,
"expected 0, got %d\n",
ret);
1288 ok(
buffer[0] ==
'\0',
"expected empty string\n");
1293 ok(
ret == 0,
"expected 0, got %d\n",
ret);
1300 unsigned int jisjms[][2] = { {0x2020, 0}, {0x2021, 0}, {0x2120, 0}, {0x2121, 0x8140},
1301 {0x7f7f, 0}, {0x7f7e, 0}, {0x7e7f, 0}, {0x7e7e, 0xeffc},
1302 {0x255f, 0x837e}, {0x2560, 0x8380}, {0x2561, 0x8381},
1303 {0x2121FFFF, 0}, {0x2223, 0x81a1}, {0x237e, 0x829e}, {0, 0}};
1311 for (
j = 0; jisjms[
j][0] != 0;
j++)
1315 exp = (
cp[
i] == 932) ? jisjms[
j][1] : jisjms[
j][0];
1316 ok(
ret ==
exp,
"Expected 0x%x, got 0x%x (0x%x, codepage=%d)\n",
1326 unsigned int jmsjis[][2] = { {0x80fc, 0}, {0x813f, 0}, {0x8140, 0x2121},
1327 {0x817e, 0x215f}, {0x817f, 0}, {0x8180, 0x2160},
1328 {0x819e, 0x217e}, {0x819f, 0x2221}, {0x81fc, 0x227e},
1329 {0x81fd, 0}, {0x9ffc, 0x5e7e}, {0x9ffd, 0},
1330 {0xa040, 0}, {0xdffc, 0}, {0xe040, 0x5f21},
1331 {0xeffc, 0x7e7e}, {0xf040, 0}, {0x21, 0}, {0, 0}};
1339 for (
j = 0; jmsjis[
j][0] != 0;
j++)
1343 exp = (
cp[
i] == 932) ? jmsjis[
j][1] : jmsjis[
j][0];
1344 ok(
ret ==
exp,
"Expected 0x%x, got 0x%x (0x%x, codepage=%d)\n",
1353 static const unsigned int mbchira_932[][2] = {
1354 {0x8152, 0x8152}, {0x8153, 0x8153}, {0x8154, 0x8154}, {0x8155, 0x8155},
1355 {0x82a0, 0x82a0}, {0x833f, 0x833f}, {0x8340, 0x829f}, {0x837e, 0x82dd},
1356 {0x837f, 0x837f}, {0x8380, 0x82de}, {0x8393, 0x82f1}, {0x8394, 0x8394},
1357 {0x8396, 0x8396}, {0x8397, 0x8397},
1358 {0xa5, 0xa5}, {0xb0, 0xb0}, {0xdd, 0xdd} };
1365 int ret,
exp = mbchira_932[
i][0];
1375 exp = mbchira_932[
i][1];
1383 static const unsigned int mbckata_932[][2] = {
1384 {0x8152, 0x8152}, {0x8153, 0x8153}, {0x8154, 0x8154}, {0x8155, 0x8155},
1385 {0x833f, 0x833f}, {0x829f, 0x8340}, {0x82dd, 0x837e}, {0x837f, 0x837f},
1386 {0x82de, 0x8380}, {0x8394, 0x8394}, {0x8397, 0x8397},
1387 {0xa5, 0xa5}, {0xb0, 0xb0}, {0xdd, 0xdd} };
1394 int ret,
exp = mbckata_932[
i][0];
1404 exp = mbckata_932[
i][1];
1412 static const unsigned int mbbmbc[][2] = {
1413 {0x1f, 0x1f}, {0x20, 0x8140}, {0x39, 0x8258}, {0x40, 0x8197},
1414 {0x41, 0x8260}, {0x5e, 0x814f}, {0x7e, 0x8150}, {0x7f, 0x7f},
1415 {0x80, 0x80}, {0x81, 0x81}, {0xa0, 0xa0}, {0xa7, 0x8340},
1416 {0xb0, 0x815b}, {0xd1, 0x8380}, {0xff, 0xff}, {0,0}};
1424 for (
j = 0; mbbmbc[
j][0] != 0;
j++)
1428 exp = (
cp[
i] == 932) ? mbbmbc[
j][1] : mbbmbc[
j][0];
1429 ok(
ret ==
exp,
"Expected 0x%x, got 0x%x (0x%x, codepage %d)\n",
1438 static const unsigned int mbcmbb_932[][2] = {
1439 {0x829e, 0x829e}, {0x829f, 0xa7}, {0x82f1, 0xdd}, {0x82f2, 0x82f2},
1440 {0x833f, 0x833f}, {0x8340, 0xa7}, {0x837e, 0xd0}, {0x837f, 0x837f},
1441 {0x8380, 0xd1}, {0x8396, 0xb9}, {0x8397, 0x8397}, {0x813f, 0x813f},
1442 {0x8140, 0x20}, {0x814c, 0x814c}, {0x814f, 0x5e}, {0x8197, 0x40},
1443 {0x8198, 0x8198}, {0x8258, 0x39}, {0x8259, 0x8259}, {0x825f, 0x825f},
1444 {0x8260, 0x41}, {0x82f1, 0xdd}, {0x82f2, 0x82f2}, {0,0}};
1449 for (
i = 0; mbcmbb_932[
i][0] != 0;
i++)
1452 exp = mbcmbb_932[
i][1];
1459 struct katakana_pair {
1463 static const struct katakana_pair
tests[] = {
1496 for(
i = 0;
i < 0x10000;
i++) {
1507 ok(!
err,
"_ismbclegal (932) : Expected 0x%x, got 0x%x (0x%x)\n",
exp,
ret,
i);
1510 for(
i = 0;
i < 0x10000;
i++) {
1519 ok(!
err,
"_ismbclegal (936) : Expected 0x%x, got 0x%x (0x%x)\n",
exp,
ret,
i);
1522 for(
i = 0;
i < 0x10000;
i++) {
1531 ok(!
err,
"_ismbclegal (949) : Expected 0x%x, got 0x%x (0x%x)\n",
exp,
ret,
i);
1534 for(
i = 0;
i < 0x10000;
i++) {
1544 ok(!
err,
"_ismbclegal (950) : Expected 0x%x, got 0x%x (0x%x)\n",
exp,
ret,
i);
1547 for(
i = 0;
i < 0x10000;
i++) {
1564static const struct {
1574 {
"red cabernet",
" ", 0, 4, -1 },
1575 {
"sparkling white riesling",
" ", 0, 10, 16 },
1576 {
" pale cream sherry",
"e ", 1, 6, 9 },
1591 "string (%p) \'%s\' return %p\n",
1593 if( !strret)
continue;
1597 "second call string (%p) \'%s\' return %p\n",
1599 if( !strret)
continue;
1603 "third call string (%p) \'%s\' return %p\n",
1610 static char neg[] =
"-0x";
1620 ok(
l==-1234,
"wrong value %d\n",
l);
1624 ok(ul==1234,
"wrong value %u\n", ul);
1629 ok(
l==2147483647,
"wrong value %d\n",
l);
1633 ok(
l==-2147483647L - 1,
"wrong value %d\n",
l);
1636 ul =
strtoul(
"4294967295UL", &
e, 0);
1637 ok(ul==4294967295ul,
"wrong value %u\n", ul);
1641 l =
strtol(
"9223372036854775807L", &
e, 0);
1642 ok(
l==2147483647,
"wrong value %d\n",
l);
1645 ul =
strtoul(
"9223372036854775807L", &
e, 0);
1646 ok(ul==4294967295ul,
"wrong value %u\n", ul);
1651 ok(ul == -2,
"wrong value %u\n", ul);
1656 ok(ul == 2,
"wrong value %u\n", ul);
1661 ok(ul==1,
"wrong value %u\n", ul);
1666 ok(ul == 1,
"wrong value %u\n", ul);
1671 ok(
l == 0,
"wrong value %d\n",
l);
1673 ok(
e == neg,
"e = %p, neg = %p\n",
e, neg);
1678 static const char str[] =
"string";
1686 res = p_strnlen(
str, 20);
1687 ok(
res == 6,
"Returned length = %d\n", (
int)
res);
1690 ok(
res == 3,
"Returned length = %d\n", (
int)
res);
1693 ok(
res == 0,
"Returned length = %d\n", (
int)
res);
1698 static const char no1[] =
"31923";
1699 static const char no2[] =
"-213312";
1700 static const char no3[] =
"12aa";
1701 static const char no4[] =
"abc12";
1702 static const char overflow[] =
"99999999999999999999";
1703 static const char neg_overflow[] =
"-99999999999999999999";
1704 static const char hex[] =
"0x123";
1705 static const char oct[] =
"000123";
1706 static const char blanks[] =
" 12 212.31";
1712 if(!p_strtoi64 || !p_strtoui64) {
1713 win_skip(
"_strtoi64 or _strtoui64 not found\n");
1718 res = p_strtoi64(no1,
NULL, 10);
1719 ok(
res == 31923,
"res != 31923\n");
1720 res = p_strtoi64(no2,
NULL, 10);
1721 ok(
res == -213312,
"res != -213312\n");
1722 res = p_strtoi64(no3,
NULL, 10);
1723 ok(
res == 12,
"res != 12\n");
1724 res = p_strtoi64(no4, &endpos, 10);
1725 ok(
res == 0,
"res != 0\n");
1726 ok(endpos == no4,
"Scanning was not stopped on first character\n");
1727 res = p_strtoi64(
hex, &endpos, 10);
1728 ok(
res == 0,
"res != 0\n");
1729 ok(endpos ==
hex+1,
"Incorrect endpos (%p-%p)\n",
hex, endpos);
1730 res = p_strtoi64(
oct, &endpos, 10);
1731 ok(
res == 123,
"res != 123\n");
1733 res = p_strtoi64(blanks, &endpos, 10);
1734 ok(
res == 12,
"res != 12\n");
1735 ok(endpos == blanks+10,
"Incorrect endpos (%p-%p)\n", blanks, endpos);
1739 res = p_strtoi64(overflow, &endpos, 10);
1741 ok(endpos == overflow+
strlen(overflow),
"Incorrect endpos (%p-%p)\n", overflow, endpos);
1745 res = p_strtoi64(neg_overflow, &endpos, 10);
1747 ok(endpos == neg_overflow+
strlen(neg_overflow),
"Incorrect endpos (%p-%p)\n", neg_overflow, endpos);
1751 res = p_strtoi64(no1, &endpos, 16);
1752 ok(
res == 203043,
"res != 203043\n");
1753 ok(endpos == no1+
strlen(no1),
"Incorrect endpos (%p-%p)\n", no1, endpos);
1754 res = p_strtoi64(no2, &endpos, 16);
1755 ok(
res == -2175762,
"res != -2175762\n");
1756 ok(endpos == no2+
strlen(no2),
"Incorrect endpos (%p-%p)\n", no2, endpos);
1757 res = p_strtoi64(no3, &endpos, 16);
1758 ok(
res == 4778,
"res != 4778\n");
1759 ok(endpos == no3+
strlen(no3),
"Incorrect endpos (%p-%p)\n", no3, endpos);
1760 res = p_strtoi64(no4, &endpos, 16);
1761 ok(
res == 703506,
"res != 703506\n");
1762 ok(endpos == no4+
strlen(no4),
"Incorrect endpos (%p-%p)\n", no4, endpos);
1763 res = p_strtoi64(
hex, &endpos, 16);
1764 ok(
res == 291,
"res != 291\n");
1766 res = p_strtoi64(
oct, &endpos, 16);
1767 ok(
res == 291,
"res != 291\n");
1769 res = p_strtoi64(blanks, &endpos, 16);
1770 ok(
res == 18,
"res != 18\n");
1771 ok(endpos == blanks+10,
"Incorrect endpos (%p-%p)\n", blanks, endpos);
1775 res = p_strtoi64(
hex, &endpos, 36);
1776 ok(
res == 1541019,
"res != 1541019\n");
1781 res = p_strtoi64(no1, &endpos, 0);
1782 ok(
res == 31923,
"res != 31923\n");
1783 ok(endpos == no1+
strlen(no1),
"Incorrect endpos (%p-%p)\n", no1, endpos);
1784 res = p_strtoi64(no2, &endpos, 0);
1785 ok(
res == -213312,
"res != -213312\n");
1786 ok(endpos == no2+
strlen(no2),
"Incorrect endpos (%p-%p)\n", no2, endpos);
1787 res = p_strtoi64(no3, &endpos, 10);
1788 ok(
res == 12,
"res != 12\n");
1789 ok(endpos == no3+2,
"Incorrect endpos (%p-%p)\n", no3, endpos);
1790 res = p_strtoi64(no4, &endpos, 10);
1791 ok(
res == 0,
"res != 0\n");
1792 ok(endpos == no4,
"Incorrect endpos (%p-%p)\n", no4, endpos);
1793 res = p_strtoi64(
hex, &endpos, 10);
1794 ok(
res == 0,
"res != 0\n");
1795 ok(endpos ==
hex+1,
"Incorrect endpos (%p-%p)\n",
hex, endpos);
1796 res = p_strtoi64(
oct, &endpos, 10);
1797 ok(
res == 123,
"res != 123\n");
1799 res = p_strtoi64(blanks, &endpos, 10);
1800 ok(
res == 12,
"res != 12\n");
1801 ok(endpos == blanks+10,
"Incorrect endpos (%p-%p)\n", blanks, endpos);
1805 ures = p_strtoui64(no1, &endpos, 0);
1806 ok(ures == 31923,
"ures != 31923\n");
1807 ok(endpos == no1+
strlen(no1),
"Incorrect endpos (%p-%p)\n", no1, endpos);
1808 ures = p_strtoui64(no2, &endpos, 0);
1809 ok(ures == -213312,
"ures != -213312\n");
1810 ok(endpos == no2+
strlen(no2),
"Incorrect endpos (%p-%p)\n", no2, endpos);
1811 ures = p_strtoui64(no3, &endpos, 10);
1812 ok(ures == 12,
"ures != 12\n");
1813 ok(endpos == no3+2,
"Incorrect endpos (%p-%p)\n", no3, endpos);
1814 ures = p_strtoui64(no4, &endpos, 10);
1815 ok(ures == 0,
"ures != 0\n");
1816 ok(endpos == no4,
"Incorrect endpos (%p-%p)\n", no4, endpos);
1817 ures = p_strtoui64(
hex, &endpos, 10);
1818 ok(ures == 0,
"ures != 0\n");
1819 ok(endpos ==
hex+1,
"Incorrect endpos (%p-%p)\n",
hex, endpos);
1820 ures = p_strtoui64(
oct, &endpos, 10);
1821 ok(ures == 123,
"ures != 123\n");
1823 ures = p_strtoui64(blanks, &endpos, 10);
1824 ok(ures == 12,
"ures != 12\n");
1825 ok(endpos == blanks+10,
"Incorrect endpos (%p-%p)\n", blanks, endpos);
1829 ures = p_strtoui64(overflow, &endpos, 10);
1831 ok(endpos == overflow+
strlen(overflow),
"Incorrect endpos (%p-%p)\n", overflow, endpos);
1835 ures = p_strtoui64(neg_overflow, &endpos, 10);
1836 ok(ures == 1,
"ures != 1\n");
1837 ok(endpos == neg_overflow+
strlen(neg_overflow),
"Incorrect endpos (%p-%p)\n", neg_overflow, endpos);
1842 if(d1-d2>-1
e-30 && d1-d2<1
e-30)
1849 const char double1[] =
"12.1";
1850 const char double2[] =
"-13.721";
1851 const char double3[] =
"INF";
1852 const char double4[] =
".21e12";
1853 const char double5[] =
"214353e-3";
1854 const char double6[] =
"NAN";
1855 const char overflow[] =
"1d9999999999999999999";
1856 const char white_chars[] =
" d10";
1863 ok(
end == double1+4,
"incorrect end (%d)\n", (
int)(
end-double1));
1867 ok(
end == double2+7,
"incorrect end (%d)\n", (
int)(
end-double2));
1871 ok(
end == double3,
"incorrect end (%d)\n", (
int)(
end-double3));
1875 ok(
end == double4+6,
"incorrect end (%d)\n", (
int)(
end-double4));
1879 ok(
end == double5+9,
"incorrect end (%d)\n", (
int)(
end-double5));
1883 ok(
end == double6,
"incorrect end (%d)\n", (
int)(
end-double6));
1890 ok(
end == white_chars,
"incorrect end (%d)\n", (
int)(
end-white_chars));
1902 end = (
char *)0xdeadbeef;
1906 ok(!
end,
"incorrect end ptr %p\n",
end);
1916 win_skip(
"system with limited locales\n");
1937 d =
strtod(
"21921922352523587651128218821",
NULL);
1947 ok(
end == overflow+21,
"incorrect end (%d)\n", (
int)(
end-overflow));
1956 static const wchar_t wSimple[] = {
't',
'e',
'x',
't',0 };
1957 static const wchar_t wHiragana[] = { 0x3042,0x3043,0 };
1958 static const wchar_t wEmpty[] = { 0 };
1959 static const char mSimple[] =
"text";
1960 static const char mHiragana[] = { 0x82,0xa0,0x82,0xa1,0 };
1961 static const char mEmpty[] = { 0 };
1963 const wchar_t *pwstr;
1971 wOut[4] =
'!'; wOut[5] =
'\0';
1972 mOut[4] =
'!'; mOut[5] =
'\0';
1978 ok(
ret == -1,
"mbstowcs did not return -1\n");
1983 ok(
ret == 4,
"mbstowcs did not return 4\n");
1986 ok(
ret == 4,
"mbstowcs did not return 4\n");
1988 ok(wOut[4] ==
'!',
"wOut[4] != \'!\'\n");
1991 ok(
ret == 0,
"mbstowcs did not return 0, got %d\n", (
int)
ret);
1994 ok(
ret == 0,
"mbstowcs did not return 0, got %d\n", (
int)
ret);
1998 ok(
ret == 4,
"wcstombs did not return 4\n");
2001 ok(
ret == 4,
"wcstombs did not return 4\n");
2002 ok(!
memcmp(mOut, mSimple, 5*
sizeof(
char)),
"mOut = %s\n", mOut);
2005 ok(
ret == 2,
"wcstombs did not return 2\n");
2006 ok(!
memcmp(mOut, mSimple, 5*
sizeof(
char)),
"mOut = %s\n", mOut);
2009 ok(
ret == 0,
"wcstombs did not return 0, got %d\n", (
int)
ret);
2012 ok(
ret == 0,
"wcstombs did not return 0, got %d\n", (
int)
ret);
2013 ok(!
memcmp(mOut, mEmpty,
sizeof(mEmpty)),
"mOut = %s\n", mOut);
2016 win_skip(
"Japanese_Japan.932 locale not available\n");
2021 ok(
ret == 2,
"mbstowcs did not return 2\n");
2025 ok(
ret == 0,
"mbstowcs did not return 0, got %d\n", (
int)
ret);
2029 ok(
ret == 4,
"wcstombs did not return 4\n");
2030 ok(!
memcmp(mOut, mHiragana,
sizeof(mHiragana)),
"mOut = %s\n", mOut);
2033 ok(
ret == 0,
"wcstombs did not return 0, got %d\n", (
int)
ret);
2034 ok(!
memcmp(mOut, mEmpty,
sizeof(mEmpty)),
"mOut = %s\n", mOut);
2036 if(!pmbstowcs_s || !pwcstombs_s) {
2038 win_skip(
"mbstowcs_s or wcstombs_s not available\n");
2044 ok(
ret == 5,
"mbstowcs_s did not return 5\n");
2049 ok(
ret == 3,
"mbstowcs_s did not return 3\n");
2054 ok(
ret == 1,
"mbstowcs_s did not return 1, got %d\n", (
int)
ret);
2057 err = pmbstowcs_s(&
ret,
NULL, 0, mHiragana, 1);
2059 ok(
ret == 3,
"mbstowcs_s did not return 3\n");
2063 ok(
ret == 5,
"wcstombs_s did not return 5\n");
2064 ok(!
memcmp(mOut, mSimple,
sizeof(mSimple)),
"mOut = %s\n", mOut);
2068 ok(
ret == 5,
"wcstombs_s did not return 5\n");
2069 ok(!
memcmp(mOut, mHiragana,
sizeof(mHiragana)),
"mOut = %s\n", mOut);
2073 ok(
ret == 1,
"wcstombs_s did not return 1, got %d\n", (
int)
ret);
2074 ok(!
memcmp(mOut, mEmpty,
sizeof(mEmpty)),
"mOut = %s\n", mOut);
2076 err = pwcstombs_s(&
ret,
NULL, 0, wHiragana, 1);
2078 ok(
ret == 5,
"wcstombs_s did not return 5\n");
2082 win_skip(
"wcsrtombs not available\n");
2088 ret = pwcsrtombs(mOut, &pwstr, 4, &
err);
2089 ok(
ret == 4,
"wcsrtombs did not return 4\n");
2091 ok(pwstr == wSimple+4,
"pwstr = %p (wszSimple = %p)\n", pwstr, wSimple);
2092 ok(!
memcmp(mOut, mSimple,
ret),
"mOut = %s\n", mOut);
2095 ret = pwcsrtombs(mOut, &pwstr, 5,
NULL);
2096 ok(
ret == 4,
"wcsrtombs did not return 4\n");
2097 ok(pwstr ==
NULL,
"pwstr != NULL\n");
2098 ok(!
memcmp(mOut, mSimple,
sizeof(mSimple)),
"mOut = %s\n", mOut);
2102 win_skip(
"mbsrtowcs not available\n");
2108 ok(
ret == 2,
"mbsrtowcs did not return 2\n");
2109 ok(pmbstr == mHiragana,
"pmbstr = %p, expected %p\n", pmbstr, mHiragana);
2112 ret = p_mbsrtowcs(wOut, &pmbstr, 6,
NULL);
2113 ok(
ret == 2,
"mbsrtowcs did not return 2\n");
2115 ok(!pmbstr,
"pmbstr != NULL\n");
2117 state = mHiragana[0];
2118 pmbstr = mHiragana+1;
2119 ret = p_mbsrtowcs(wOut, &pmbstr, 6, &
state);
2120 ok(
ret == 2,
"mbsrtowcs did not return 2\n");
2121 ok(wOut[0] == 0x3042,
"wOut[0] = %x\n", wOut[0]);
2122 ok(wOut[1] == 0xff61,
"wOut[1] = %x\n", wOut[1]);
2123 ok(wOut[2] == 0,
"wOut[2] = %x\n", wOut[2]);
2124 ok(!pmbstr,
"pmbstr != NULL\n");
2128 ok(
ret == -1,
"mbsrtowcs did not return -1\n");
2131 if(!p_mbsrtowcs_s) {
2133 win_skip(
"mbsrtowcs_s not available\n");
2139 ok(
ret == -1,
"mbsrtowcs_s did not return -1\n");
2142 ok(
ret == -1,
"mbsrtowcs_s did not return -1\n");
2144 err = p_mbsrtowcs_s(&
ret, wOut, 0, &pmbstr, 6,
NULL);
2145 ok(
ret == -1,
"mbsrtowcs_s did not return -1\n");
2151 ok(
ret == 3,
"mbsrtowcs_s did not return 3\n");
2153 ok(pmbstr == mHiragana,
"pmbstr = %p, expected %p\n", pmbstr, mHiragana);
2157 err = p_mbsrtowcs_s(&
ret, wOut, 1, &pmbstr, 6,
NULL);
2158 ok(
ret == 2,
"mbsrtowcs_s did not return 2\n");
2160 ok(!wOut[0],
"wOut[0] = '%c'\n", wOut[0]);
2161 ok(pmbstr == mHiragana+2,
"pmbstr = %p, expected %p\n", pmbstr, mHiragana+2);
2165 err = p_mbsrtowcs_s(&
ret, wOut, 2, &pmbstr, 6,
NULL);
2166 ok(
ret == 3,
"mbsrtowcs_s did not return 3\n");
2168 ok(!wOut[0],
"wOut[0] = '%c'\n", wOut[0]);
2169 ok(pmbstr == mHiragana+4,
"pmbstr = %p, expected %p\n", pmbstr, mHiragana+4);
2173 err = p_mbsrtowcs_s(&
ret, wOut, 3, &pmbstr, 6,
NULL);
2174 ok(
ret == 3,
"mbsrtowcs_s did not return 3\n");
2176 ok(!pmbstr,
"pmbstr != NULL\n");
2188 win_skip(
"Skipping _gcvt tests\n");
2207 err = p_gcvt_s(
buf, 5, 1.2, 10);
2209 ok(
buf[0] ==
'\0',
"buf[0] = %c\n",
buf[0]);
2212 err = p_gcvt_s(
buf, 4, 123456, 2);
2214 ok(
buf[0] ==
'\0',
"buf[0] = %c\n",
buf[0]);
2224 win_skip(
"Skipping _itoa_s tests\n");
2229 ret = p_itoa_s(0,
NULL, 0, 0);
2230 ok(
ret ==
EINVAL,
"Expected _itoa_s to return EINVAL, got %d\n",
ret);
2236 ok(
ret ==
EINVAL,
"Expected _itoa_s to return EINVAL, got %d\n",
ret);
2238 ok(
buffer[0] ==
'X',
"Expected the output buffer to be untouched\n");
2243 ok(
ret ==
EINVAL,
"Expected _itoa_s to return EINVAL, got %d\n",
ret);
2245 ok(
buffer[0] ==
'\0',
"Expected the output buffer to be null terminated\n");
2250 ok(
ret ==
EINVAL,
"Expected _itoa_s to return EINVAL, got %d\n",
ret);
2252 ok(
buffer[0] ==
'\0',
"Expected the output buffer to be null terminated\n");
2256 ret = p_itoa_s(12345678,
buffer, 4, 10);
2257 ok(
ret ==
ERANGE,
"Expected _itoa_s to return ERANGE, got %d\n",
ret);
2260 "Expected the output buffer to be null terminated with truncated output\n");
2264 ret = p_itoa_s(12345678,
buffer, 8, 10);
2265 ok(
ret ==
ERANGE,
"Expected _itoa_s to return ERANGE, got %d\n",
ret);
2268 "Expected the output buffer to be null terminated with truncated output\n");
2272 ret = p_itoa_s(-12345678,
buffer, 9, 10);
2273 ok(
ret ==
ERANGE,
"Expected _itoa_s to return ERANGE, got %d\n",
ret);
2276 "Expected the output buffer to be null terminated with truncated output\n");
2278 ret = p_itoa_s(12345678,
buffer, 9, 10);
2279 ok(
ret == 0,
"Expected _itoa_s to return 0, got %d\n",
ret);
2281 "Expected output buffer string to be \"12345678\", got \"%s\"\n",
2285 ok(
ret == 0,
"Expected _itoa_s to return 0, got %d\n",
ret);
2287 "Expected output buffer string to be \"1010101010101010\", got \"%s\"\n",
2291 ok(
ret == 0,
"Expected _itoa_s to return 0, got %d\n",
ret);
2293 "Expected output buffer string to be \"nell\", got \"%s\"\n",
2297 ok(
ret == 0,
"Expected _itoa_s to return 0, got %d\n",
ret);
2299 "Expected output buffer string to be \"hag\", got \"%s\"\n",
2303 ok(
ret == 0,
"Expected _itoa_s to return 0, got %d\n",
ret);
2305 "Expected output buffer string to be \"-12345678\", got \"%s\"\n",
2310 "Expected output buffer string to be \"10\", got \"%s\"\n",
buffer);
2320 win_skip(
"Skipping _strlwr_s tests\n");
2326 ok(
ret ==
EINVAL,
"Expected _strlwr_s to return EINVAL, got %d\n",
ret);
2331 ok(
ret ==
EINVAL,
"Expected _strlwr_s to return EINVAL, got %d\n",
ret);
2336 ok(
ret ==
EINVAL,
"Expected _strlwr_s to return EINVAL, got %d\n",
ret);
2342 ok(
ret ==
EINVAL,
"Expected _strlwr_s to return EINVAL, got %d\n",
ret);
2345 "Expected the output buffer to be \"\\0oRrIsTeR\"\n");
2349 ret = p_strlwr_s(
buffer,
sizeof(
"GoRrIsTeR") - 1);
2350 ok(
ret ==
EINVAL,
"Expected _strlwr_s to return EINVAL, got %d\n",
ret);
2353 "Expected the output buffer to be \"\\0oRrIsTeR\"\n");
2356 ret = p_strlwr_s(
buffer,
sizeof(
"GoRrIsTeR"));
2357 ok(
ret == 0,
"Expected _strlwr_s to return 0, got %d\n",
ret);
2359 "Expected the output buffer to be \"gorrister\", got \"%s\"\n",
2362 memcpy(
buffer,
"GoRrIsTeR\0ELLEN",
sizeof(
"GoRrIsTeR\0ELLEN"));
2364 ok(
ret == 0,
"Expected _strlwr_s to return 0, got %d\n",
ret);
2365 ok(!
memcmp(
buffer,
"gorrister\0ELLEN",
sizeof(
"gorrister\0ELLEN")),
2366 "Expected the output buffer to be \"gorrister\\0ELLEN\", got \"%s\"\n",
2372 static wchar_t abcW[] = {
'a',
'b',
'c',0};
2379 win_skip(
"skipping wcsncat_s tests\n");
2411 unsigned char dest[16];
2412 const unsigned char first[] =
"dinosaur";
2413 const unsigned char second[] =
"duck";
2418 win_skip(
"Skipping _mbsnbcat_s tests\n");
2424 ok(
ret == 0,
"Expected _mbsnbcat_s to return 0, got %d\n",
ret);
2428 ok(
ret ==
EINVAL,
"Expected _mbsnbcat_s to return EINVAL, got %d\n",
ret);
2433 ok(
ret ==
EINVAL,
"Expected _mbsnbcat_s to return EINVAL, got %d\n",
ret);
2439 ok(
ret ==
EINVAL,
"Expected _mbsnbcat_s to return EINVAL, got %d\n",
ret);
2441 ok(
dest[0] ==
'X',
"Expected the output buffer to be untouched\n");
2445 ret = p_mbsnbcat_s(
dest, 0, second, 0);
2446 ok(
ret ==
EINVAL,
"Expected _mbsnbcat_s to return EINVAL, got %d\n",
ret);
2448 ok(
dest[0] ==
'X',
"Expected the output buffer to be untouched\n");
2453 ok(
ret ==
EINVAL,
"Expected _mbsnbcat_s to return EINVAL, got %d\n",
ret);
2455 ok(
dest[0] ==
'\0',
"Expected the output buffer to be null terminated\n");
2460 ok(
ret ==
EINVAL,
"Expected _mbsnbcat_s to return EINVAL, got %d\n",
ret);
2462 ok(
dest[0] ==
'\0',
"Expected the output buffer to be null terminated\n");
2466 ret = p_mbsnbcat_s(
dest,
sizeof(
dest), second,
sizeof(second));
2467 ok(
ret == 0,
"Expected _mbsnbcat_s to return 0, got %d\n",
ret);
2469 "Expected the output buffer string to be \"duck\"\n");
2474 ret = p_mbsnbcat_s(
dest,
sizeof(
dest), second, 0);
2475 ok(
ret == 0,
"Expected _mbsnbcat_s to return 0, got %d\n",
ret);
2477 "Expected the output buffer string to be \"dinosaur\"\n");
2481 ret = p_mbsnbcat_s(
dest,
sizeof(
dest), second,
sizeof(second));
2482 ok(
ret == 0,
"Expected _mbsnbcat_s to return 0, got %d\n",
ret);
2483 ok(!
memcmp(
dest,
"dinosaurduck",
sizeof(
"dinosaurduck")),
2484 "Expected the output buffer string to be \"dinosaurduck\"\n");
2488 ret = p_mbsnbcat_s(
dest,
sizeof(
dest), second,
sizeof(second) + 1);
2489 ok(
ret == 0,
"Expected _mbsnbcat_s to return 0, got %d\n",
ret);
2490 ok(!
memcmp(
dest,
"dinosaurduck",
sizeof(
"dinosaurduck")),
2491 "Expected the output buffer string to be \"dinosaurduck\"\n");
2495 ret = p_mbsnbcat_s(
dest,
sizeof(
dest), second,
sizeof(second) - 1);
2496 ok(
ret == 0,
"Expected _mbsnbcat_s to return 0, got %d\n",
ret);
2497 ok(!
memcmp(
dest,
"dinosaurduck",
sizeof(
"dinosaurduck")),
2498 "Expected the output buffer string to be \"dinosaurduck\"\n");
2502 ret = p_mbsnbcat_s(
dest,
sizeof(
dest), second,
sizeof(second) - 2);
2503 ok(
ret == 0,
"Expected _mbsnbcat_s to return 0, got %d\n",
ret);
2504 ok(!
memcmp(
dest,
"dinosaurduc",
sizeof(
"dinosaurduc")),
2505 "Expected the output buffer string to be \"dinosaurduc\"\n");
2511 ret = p_mbsnbcat_s(
dest,
sizeof(
first) - 1, second,
sizeof(second));
2512 ok(
ret ==
EINVAL,
"Expected _mbsnbcat_s to return EINVAL, got %d\n",
ret);
2514 ok(!
memcmp(
dest,
"\0inosaur",
sizeof(
"\0inosaur") - 1),
2515 "Expected the output buffer string to be \"\\0inosaur\" without ending null terminator\n");
2520 ret = p_mbsnbcat_s(
dest,
sizeof(
first), second,
sizeof(second));
2521 ok(
ret ==
ERANGE,
"Expected _mbsnbcat_s to return ERANGE, got %d\n",
ret);
2523 ok(!
memcmp(
dest,
"\0inosaurd",
sizeof(
"\0inosaurd") - 1),
2524 "Expected the output buffer string to be \"\\0inosaurd\" without ending null terminator\n");
2529 ret = p_mbsnbcat_s(
dest,
sizeof(
first) + 1, second,
sizeof(second));
2530 ok(
ret ==
ERANGE,
"Expected _mbsnbcat_s to return ERANGE, got %d\n",
ret);
2532 ok(!
memcmp(
dest,
"\0inosaurdu",
sizeof(
"\0inosaurdu") - 1),
2533 "Expected the output buffer string to be \"\\0inosaurdu\" without ending null terminator\n");
2539 unsigned char buffer[20];
2543 win_skip(
"Skipping _mbsupr_s tests\n");
2549 ok(
ret == 0,
"Expected _mbsupr_s to return 0, got %d\n",
ret);
2553 ok(
ret ==
EINVAL,
"Expected _mbsupr_s to return EINVAL, got %d\n",
ret);
2558 ok(
ret ==
EINVAL,
"Expected _mbsupr_s to return EINVAL, got %d\n",
ret);
2563 ret = p_mbsupr_s(
buffer,
sizeof(
"abcdefgh"));
2564 ok(
ret == 0,
"Expected _mbsupr_s to return 0, got %d\n",
ret);
2566 "Expected the output buffer to be \"ABCDEFGH\", got \"%s\"\n",
2572 ok(
ret == 0,
"Expected _mbsupr_s to return 0, got %d\n",
ret);
2574 "Expected the output buffer to be \"ABCDEFGH\", got \"%s\"\n",
2580 ok(
ret ==
EINVAL,
"Expected _mbsupr_s to return EINVAL, got %d\n",
ret);
2583 memcpy(
buffer,
"abcdefgh\0ijklmnop",
sizeof(
"abcdefgh\0ijklmnop"));
2586 ok(
ret == 0,
"Expected _mbsupr_s to return 0, got %d\n",
ret);
2587 ok(!
memcmp(
buffer,
"ABCDEFGH\0ijklmnop",
sizeof(
"ABCDEFGH\0ijklmnop")),
2588 "Expected the output buffer to be \"ABCDEFGH\\0ijklmnop\", got \"%s\"\n",
2596 unsigned char buffer[20];
2600 win_skip(
"Skipping _mbslwr_s tests\n");
2606 ok(
ret == 0,
"Expected _mbslwr_s to return 0, got %d\n",
ret);
2610 ok(
ret ==
EINVAL,
"Expected _mbslwr_s to return EINVAL, got %d\n",
ret);
2615 ok(
ret ==
EINVAL,
"Expected _mbslwr_s to return EINVAL, got %d\n",
ret);
2620 ret = p_mbslwr_s(
buffer,
sizeof(
"ABCDEFGH"));
2621 ok(
ret == 0,
"Expected _mbslwr_s to return 0, got %d\n",
ret);
2623 "Expected the output buffer to be \"abcdefgh\", got \"%s\"\n",
2629 ok(
ret == 0,
"Expected _mbslwr_s to return 0, got %d\n",
ret);
2631 "Expected the output buffer to be \"abcdefgh\", got \"%s\"\n",
2637 ok(
ret ==
EINVAL,
"Expected _mbslwr_s to return EINVAL, got %d\n",
ret);
2640 memcpy(
buffer,
"ABCDEFGH\0IJKLMNOP",
sizeof(
"ABCDEFGH\0IJKLMNOP"));
2643 ok(
ret == 0,
"Expected _mbslwr_s to return 0, got %d\n",
ret);
2644 ok(!
memcmp(
buffer,
"abcdefgh\0IJKLMNOP",
sizeof(
"abcdefgh\0IJKLMNOP")),
2645 "Expected the output buffer to be \"abcdefgh\\0IJKLMNOP\", got \"%s\"\n",
2651 const unsigned char delim[] =
"t";
2653 char str[] =
"!.!test";
2661 "_mbstok(NULL, \"t\") = %p, expected NULL (%p)\n",
ret,
str);
2664 ok(!
ret,
"_mbstok(NULL, \"t\") = %p, expected NULL\n",
ret);
2674 win_skip(
"Skipping _ultoa_s tests\n");
2679 ret = p_ultoa_s(0,
NULL, 0, 0);
2680 ok(
ret ==
EINVAL,
"Expected _ultoa_s to return EINVAL, got %d\n",
ret);
2686 ok(
ret ==
EINVAL,
"Expected _ultoa_s to return EINVAL, got %d\n",
ret);
2688 ok(
buffer[0] ==
'X',
"Expected the output buffer to be untouched\n");
2693 ok(
ret ==
EINVAL,
"Expected _ultoa_s to return EINVAL, got %d\n",
ret);
2695 ok(
buffer[0] ==
'\0',
"Expected the output buffer to be null terminated\n");
2700 ok(
ret ==
EINVAL,
"Expected _ultoa_s to return EINVAL, got %d\n",
ret);
2702 ok(
buffer[0] ==
'\0',
"Expected the output buffer to be null terminated\n");
2706 ret = p_ultoa_s(12345678,
buffer, 4, 10);
2707 ok(
ret ==
ERANGE,
"Expected _ultoa_s to return ERANGE, got %d\n",
ret);
2710 "Expected the output buffer to be null terminated with truncated output\n");
2714 ret = p_ultoa_s(12345678,
buffer, 8, 10);
2715 ok(
ret ==
ERANGE,
"Expected _ultoa_s to return ERANGE, got %d\n",
ret);
2718 "Expected the output buffer to be null terminated with truncated output\n");
2720 ret = p_ultoa_s(12345678,
buffer, 9, 10);
2721 ok(
ret == 0,
"Expected _ultoa_s to return 0, got %d\n",
ret);
2723 "Expected output buffer string to be \"12345678\", got \"%s\"\n",
2727 ok(
ret == 0,
"Expected _ultoa_s to return 0, got %d\n",
ret);
2729 "Expected output buffer string to be \"1010101010101010\", got \"%s\"\n",
2733 ok(
ret == 0,
"Expected _ultoa_s to return 0, got %d\n",
ret);
2735 "Expected output buffer string to be \"nell\", got \"%s\"\n",
2739 ok(
ret == 0,
"Expected _ultoa_s to return 0, got %d\n",
ret);
2741 "Expected output buffer string to be \"hag\", got \"%s\"\n",
2750 win_skip(
"Skipping wctob tests\n");
2754 ret = p_wctob(0x8141);
2757 ret = p_wctob(0x81);
2760 ret = p_wctob(0xe0);
2761 ok(
ret == 0x61,
"ret = %x\n",
ret);
2764 ret = p_wctob(0x81);
2768 ret = p_wctob(0x8141);
2771 ret = p_wctob(0x81);
2772 ok(
ret == (
int)(
char)0x81,
"ret = %x\n",
ret);
2774 ret = p_wctob(0x9f);
2775 ok(
ret == (
int)(
char)0x9f,
"ret = %x\n",
ret);
2777 ret = p_wctob(0xe0);
2778 ok(
ret == (
int)(
char)0xe0,
"ret = %x\n",
ret);
2786 unsigned char dst[10];
2796 ok(
ret == 2,
"wcrtomb did not return 2\n");
2801 ok(
ret == 2,
"wcrtomb did not return 2\n");
2802 ok(
state == 0,
"state != 0\n");
2803 ok(
dst[0] == 0x82,
"dst[0] = %x, expected 0x82\n",
dst[0]);
2804 ok(
dst[1] == 0xa0,
"dst[1] = %x, expected 0xa0\n",
dst[1]);
2805 ok(
dst[2] ==
'a',
"dst[2] != 'a'\n");
2808 ok(
ret == 2,
"wcrtomb did not return 2\n");
2809 ok(
dst[0] == 0x82,
"dst[0] = %x, expected 0x82\n",
dst[0]);
2810 ok(
dst[1] == 0xa1,
"dst[1] = %x, expected 0xa1\n",
dst[1]);
2813 ok(
ret == 1,
"wcrtomb did not return 1\n");
2814 ok(
dst[0] == 0x20,
"dst[0] = %x, expected 0x20\n",
dst[0]);
2817 ok(
ret == -1,
"wcrtomb did not return -1\n");
2818 ok(
dst[0] == 0x3f,
"dst[0] = %x, expected 0x3f\n",
dst[0]);
2830 ok(
ret == 2,
"ret != 2\n");
2832 ok(
dst[0] == 0x82,
"dst[0] = %x, expected 0x82\n",
dst[0]);
2833 ok(
dst[1] == 0xa0,
"dst[1] = %x, expected 0xa0\n",
dst[1]);
2834 ok(
dst[2] ==
'a',
"dst[2] != 'a'\n");
2838 ok(
ret == 2,
"ret != 2\n");
2840 ok(
dst[0] == 0x82,
"dst[0] = %x, expected 0x82\n",
dst[0]);
2841 ok(
dst[1] == 0xa0,
"dst[1] = %x, expected 0xa0\n",
dst[1]);
2845 ok(
ret == 1,
"ret != 1\n");
2846 ok(
dst[0] == 0x20,
"dst[0] = %x, expected 0x20\n",
dst[0]);
2850 ok(
ret == 1,
"ret != 1\n");
2854 ok(
ret == -1,
"wcrtomb did not return -1\n");
2855 ok(
dst[0] == 0x3f,
"dst[0] = %x, expected 0x3f\n",
dst[0]);
2867 ret = p_tolower(0x41);
2868 ok(
ret == 0x61,
"ret = %x\n",
ret);
2870 ret = p_tolower(0xF4);
2871 ok(
ret == 0xF4,
"ret = %x\n",
ret);
2874 ret = p_tolower((
char)0xF4);
2875 ok(
ret == (
char)0xF4,
"ret = %x\n",
ret);
2879 ret = p_tolower((
char)0xD0);
2880 ok(
ret == (
char)0xD0,
"ret = %x\n",
ret);
2885 ret = p_tolower((
char)0xF4);
2886 ok(
ret == (
char)0xF4,
"ret = %x\n",
ret);
2891 win_skip(
"skipping tolower tests that depends on locale\n");
2898 ret = p_tolower(ch);