2 * Unit test suite for string functions.
4 * Copyright 2004 Uwe Bonnes
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #include "wine/test.h"
33 static char *buf_to_string(const unsigned char *bin, int len, int nr)
35 static char buf[2][1024];
39 for (i = 0; i < len; i++)
41 sprintf(w, "%02x ", (unsigned char)bin[i]);
47 static void __cdecl test_invalid_parameter_handler(const wchar_t *expression,
48 const wchar_t *function, const wchar_t *file,
49 unsigned line, uintptr_t arg)
51 /* we just ignore handler calls */
54 #define expect_eq(expr, value, type, format) { type ret = (expr); ok((value) == ret, #expr " expected " format " got " format "\n", value, ret); }
55 #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)); }
57 static void* (__cdecl *pmemcpy)(void *, const void *, size_t n);
58 static int* (__cdecl *pmemcmp)(void *, const void *, size_t n);
59 static int (__cdecl *pstrcpy_s)(char *dst, size_t len, const char *src);
60 static int (__cdecl *pstrcat_s)(char *dst, size_t len, const char *src);
61 static int (__cdecl *p_mbsnbcat_s)(unsigned char *dst, size_t size, const unsigned char *src, size_t count);
62 static int (__cdecl *p_mbsnbcpy_s)(unsigned char * dst, size_t size, const unsigned char * src, size_t count);
63 static int (__cdecl *p_wcscpy_s)(wchar_t *wcDest, size_t size, const wchar_t *wcSrc);
64 static int (__cdecl *p_wcsncat_s)(wchar_t *dst, size_t elem, const wchar_t *src, size_t count);
65 static int (__cdecl *p_wcsupr_s)(wchar_t *str, size_t size);
66 static size_t (__cdecl *p_strnlen)(const char *, size_t);
67 static __int64 (__cdecl *p_strtoi64)(const char *, char **, int);
68 static unsigned __int64 (__cdecl *p_strtoui64)(const char *, char **, int);
69 static int (__cdecl *pwcstombs_s)(size_t*,char*,size_t,const wchar_t*,size_t);
70 static int (__cdecl *pmbstowcs_s)(size_t*,wchar_t*,size_t,const char*,size_t);
71 static errno_t (__cdecl *p_gcvt_s)(char*,size_t,double,int);
72 static errno_t (__cdecl *p_itoa_s)(int,char*,size_t,int);
73 static errno_t (__cdecl *p_strlwr_s)(char*,size_t);
74 static errno_t (__cdecl *p_ultoa_s)(__msvcrt_ulong,char*,size_t,int);
75 static int *p__mb_cur_max;
76 static unsigned char *p_mbctype;
77 static _invalid_parameter_handler (__cdecl *p_set_invalid_parameter_handler)(_invalid_parameter_handler);
78 static int (__cdecl *p_wcslwr_s)(wchar_t*,size_t);
79 static errno_t (__cdecl *p_mbsupr_s)(unsigned char *str, size_t numberOfElements);
80 static errno_t (__cdecl *p_mbslwr_s)(unsigned char *str, size_t numberOfElements);
81 static int (__cdecl *p_wctob)(wint_t);
83 #define SETNOFAIL(x,y) x = (void*)GetProcAddress(hMsvcrt,y)
84 #define SET(x,y) SETNOFAIL(x,y); ok(x != NULL, "Export '%s' not found\n", y)
86 static HMODULE hMsvcrt;
88 static void test_swab( void ) {
89 char original[] = "BADCFEHGJILKNMPORQTSVUXWZY@#";
90 char expected1[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ@#";
91 char expected2[] = "ABCDEFGHIJKLMNOPQRSTUVWX$";
92 char expected3[] = "$";
99 /* Test 1 - normal even case */
100 memset(to,'$', sizeof(to));
101 memset(from,'@', sizeof(from));
103 memcpy(from, original, testsize);
104 _swab( from, to, testsize );
105 ok(memcmp(to,expected1,testsize) == 0, "Testing even size %d returned '%*.*s'\n", testsize, testsize, testsize, to);
107 /* Test 2 - uneven case */
108 memset(to,'$', sizeof(to));
109 memset(from,'@', sizeof(from));
111 memcpy(from, original, testsize);
112 _swab( from, to, testsize );
113 ok(memcmp(to,expected2,testsize) == 0, "Testing odd size %d returned '%*.*s'\n", testsize, testsize, testsize, to);
115 /* Test 3 - from = to */
116 memset(to,'$', sizeof(to));
117 memset(from,'@', sizeof(from));
119 memcpy(to, original, testsize);
120 _swab( to, to, testsize );
121 ok(memcmp(to,expected1,testsize) == 0, "Testing overlapped size %d returned '%*.*s'\n", testsize, testsize, testsize, to);
123 /* Test 4 - 1 bytes */
124 memset(to,'$', sizeof(to));
125 memset(from,'@', sizeof(from));
127 memcpy(from, original, testsize);
128 _swab( from, to, testsize );
129 ok(memcmp(to,expected3,testsize) == 0, "Testing small size %d returned '%*.*s'\n", testsize, testsize, testsize, to);
132 #if 0 /* use this to generate more tests */
134 static void test_codepage(int cp)
140 ok(_setmbcp(cp) == 0, "Couldn't set mbcp\n");
143 printf("static int result_cp_%d_mbctype[] = { ", cp);
144 for (i = 1; i < 257; i++)
146 if (p_mbctype[i] != prev)
148 printf("0x%x,%d, ", prev, count);
155 printf("0x%x,%d };\n", prev, count);
160 /* RLE-encoded mbctype tables for given codepages */
161 static int result_cp_932_mbctype[] = { 0x0,65, 0x8,1, 0x18,26, 0x8,6, 0x28,26, 0x8,4,
162 0x0,1, 0x8,1, 0xc,31, 0x8,1, 0xa,5, 0x9,58, 0xc,29, 0,3 };
163 static int result_cp_936_mbctype[] = { 0x0,65, 0x8,1, 0x18,26, 0x8,6, 0x28,26, 0x8,6,
165 static int result_cp_949_mbctype[] = { 0x0,66, 0x18,26, 0x8,6, 0x28,26, 0x8,6, 0xc,126,
167 static int result_cp_950_mbctype[] = { 0x0,65, 0x8,1, 0x18,26, 0x8,6, 0x28,26, 0x8,4,
168 0x0,2, 0x4,32, 0xc,94, 0,1 };
170 static void test_cp_table(int cp, int *result)
176 for (i = 0; i < 256; i++)
184 ok(p_mbctype[i] == curr, "CP%d: Mismatch in ctype for character %d - %d instead of %d\n", cp, i-1, p_mbctype[i], curr);
189 #define test_codepage(num) test_cp_table(num, result_cp_##num##_mbctype);
193 static void test_mbcp(void)
195 int mb_orig_max = *p__mb_cur_max;
196 int curr_mbcp = _getmbcp();
197 unsigned char *mbstring = (unsigned char *)"\xb0\xb1\xb2 \xb3\xb4 \xb5"; /* incorrect string */
198 unsigned char *mbstring2 = (unsigned char *)"\xb0\xb1\xb2\xb3Q\xb4\xb5"; /* correct string */
199 unsigned char *mbsonlylead = (unsigned char *)"\xb0\0\xb1\xb2 \xb3";
200 unsigned char buf[16];
206 /* An SBCS codepage test. The ctype of characters on e.g. CP1252 or CP1250 differs slightly
207 * between versions of Windows. Also Windows 9x seems to ignore the codepage and always uses
208 * CP1252 (or the ACP?) so we test only a few ASCII characters */
210 expect_eq(p_mbctype[10], 0, char, "%x");
211 expect_eq(p_mbctype[50], 0, char, "%x");
212 expect_eq(p_mbctype[66], _SBUP, char, "%x");
213 expect_eq(p_mbctype[100], _SBLOW, char, "%x");
214 expect_eq(p_mbctype[128], 0, char, "%x");
216 expect_eq(p_mbctype[10], 0, char, "%x");
217 expect_eq(p_mbctype[50], 0, char, "%x");
218 expect_eq(p_mbctype[66], _SBUP, char, "%x");
219 expect_eq(p_mbctype[100], _SBLOW, char, "%x");
220 expect_eq(p_mbctype[128], 0, char, "%x");
222 /* double byte code pages */
229 ok(*p__mb_cur_max == mb_orig_max, "__mb_cur_max shouldn't be updated (is %d != %d)\n", *p__mb_cur_max, mb_orig_max);
230 ok(_ismbblead('\354'), "\354 should be a lead byte\n");
231 ok(_ismbblead(' ') == FALSE, "' ' should not be a lead byte\n");
232 ok(_ismbblead(0x1234b0), "0x1234b0 should not be a lead byte\n");
233 ok(_ismbblead(0x123420) == FALSE, "0x123420 should not be a lead byte\n");
234 ok(_ismbbtrail('\xb0'), "\xa0 should be a trail byte\n");
235 ok(_ismbbtrail(' ') == FALSE, "' ' should not be a trail byte\n");
238 expect_eq(_ismbslead(mbstring, &mbstring[0]), -1, int, "%d");
239 expect_eq(_ismbslead(mbstring, &mbstring[1]), FALSE, int, "%d");
240 expect_eq(_ismbslead(mbstring, &mbstring[2]), -1, int, "%d");
241 expect_eq(_ismbslead(mbstring, &mbstring[3]), FALSE, int, "%d");
242 expect_eq(_ismbslead(mbstring, &mbstring[4]), -1, int, "%d");
243 expect_eq(_ismbslead(mbstring, &mbstring[5]), FALSE, int, "%d");
244 expect_eq(_ismbslead(mbstring, &mbstring[6]), FALSE, int, "%d");
245 expect_eq(_ismbslead(mbstring, &mbstring[7]), -1, int, "%d");
246 expect_eq(_ismbslead(mbstring, &mbstring[8]), FALSE, int, "%d");
248 expect_eq(_ismbslead(mbsonlylead, &mbsonlylead[0]), -1, int, "%d");
249 expect_eq(_ismbslead(mbsonlylead, &mbsonlylead[1]), FALSE, int, "%d");
250 expect_eq(_ismbslead(mbsonlylead, &mbsonlylead[2]), FALSE, int, "%d");
251 expect_eq(_ismbslead(mbsonlylead, &mbsonlylead[5]), FALSE, int, "%d");
254 expect_eq(_ismbstrail(mbstring, &mbstring[0]), FALSE, int, "%d");
255 expect_eq(_ismbstrail(mbstring, &mbstring[1]), -1, int, "%d");
256 expect_eq(_ismbstrail(mbstring, &mbstring[2]), FALSE, int, "%d");
257 expect_eq(_ismbstrail(mbstring, &mbstring[3]), -1, int, "%d");
258 expect_eq(_ismbstrail(mbstring, &mbstring[4]), FALSE, int, "%d");
259 expect_eq(_ismbstrail(mbstring, &mbstring[5]), -1, int, "%d");
260 expect_eq(_ismbstrail(mbstring, &mbstring[6]), FALSE, int, "%d");
261 expect_eq(_ismbstrail(mbstring, &mbstring[7]), FALSE, int, "%d");
262 expect_eq(_ismbstrail(mbstring, &mbstring[8]), -1, int, "%d");
264 expect_eq(_ismbstrail(mbsonlylead, &mbsonlylead[0]), FALSE, int, "%d");
265 expect_eq(_ismbstrail(mbsonlylead, &mbsonlylead[1]), -1, int, "%d");
266 expect_eq(_ismbstrail(mbsonlylead, &mbsonlylead[2]), FALSE, int, "%d");
267 expect_eq(_ismbstrail(mbsonlylead, &mbsonlylead[3]), FALSE, int, "%d");
268 expect_eq(_ismbstrail(mbsonlylead, &mbsonlylead[4]), FALSE, int, "%d");
269 expect_eq(_ismbstrail(mbsonlylead, &mbsonlylead[5]), FALSE, int, "%d");
272 expect_eq(_mbsbtype(mbstring, 0), _MBC_LEAD, int, "%d");
273 expect_eq(_mbsbtype(mbstring, 1), _MBC_TRAIL, int, "%d");
274 expect_eq(_mbsbtype(mbstring, 2), _MBC_LEAD, int, "%d");
275 expect_eq(_mbsbtype(mbstring, 3), _MBC_ILLEGAL, int, "%d");
276 expect_eq(_mbsbtype(mbstring, 4), _MBC_LEAD, int, "%d");
277 expect_eq(_mbsbtype(mbstring, 5), _MBC_TRAIL, int, "%d");
278 expect_eq(_mbsbtype(mbstring, 6), _MBC_SINGLE, int, "%d");
279 expect_eq(_mbsbtype(mbstring, 7), _MBC_LEAD, int, "%d");
280 expect_eq(_mbsbtype(mbstring, 8), _MBC_ILLEGAL, int, "%d");
282 expect_eq(_mbsbtype(mbsonlylead, 0), _MBC_LEAD, int, "%d");
283 expect_eq(_mbsbtype(mbsonlylead, 1), _MBC_ILLEGAL, int, "%d");
284 expect_eq(_mbsbtype(mbsonlylead, 2), _MBC_ILLEGAL, int, "%d");
285 expect_eq(_mbsbtype(mbsonlylead, 3), _MBC_ILLEGAL, int, "%d");
286 expect_eq(_mbsbtype(mbsonlylead, 4), _MBC_ILLEGAL, int, "%d");
287 expect_eq(_mbsbtype(mbsonlylead, 5), _MBC_ILLEGAL, int, "%d");
290 expect_eq(_mbsnextc(mbstring), 0xb0b1, int, "%x");
291 expect_eq(_mbsnextc(&mbstring[2]), 0xb220, int, "%x"); /* lead + invalid tail */
292 expect_eq(_mbsnextc(&mbstring[3]), 0x20, int, "%x"); /* single char */
294 /* _mbclen/_mbslen */
295 expect_eq(_mbclen(mbstring), 2, int, "%d");
296 expect_eq(_mbclen(&mbstring[2]), 2, int, "%d");
297 expect_eq(_mbclen(&mbstring[3]), 1, int, "%d");
298 expect_eq(_mbslen(mbstring2), 4, int, "%d");
299 expect_eq(_mbslen(mbsonlylead), 0, int, "%d"); /* lead + NUL not counted as character */
300 expect_eq(_mbslen(mbstring), 4, int, "%d"); /* lead + invalid trail counted */
302 /* _mbccpy/_mbsncpy */
303 memset(buf, 0xff, sizeof(buf));
304 _mbccpy(buf, mbstring);
305 expect_bin(buf, "\xb0\xb1\xff", 3);
307 memset(buf, 0xff, sizeof(buf));
308 _mbsncpy(buf, mbstring, 1);
309 expect_bin(buf, "\xb0\xb1\xff", 3);
310 memset(buf, 0xff, sizeof(buf));
311 _mbsncpy(buf, mbstring, 2);
312 expect_bin(buf, "\xb0\xb1\xb2 \xff", 5);
313 memset(buf, 0xff, sizeof(buf));
314 _mbsncpy(buf, mbstring, 3);
315 expect_bin(buf, "\xb0\xb1\xb2 \xb3\xb4\xff", 7);
316 memset(buf, 0xff, sizeof(buf));
317 _mbsncpy(buf, mbstring, 4);
318 expect_bin(buf, "\xb0\xb1\xb2 \xb3\xb4 \xff", 8);
319 memset(buf, 0xff, sizeof(buf));
320 _mbsncpy(buf, mbstring, 5);
321 expect_bin(buf, "\xb0\xb1\xb2 \xb3\xb4 \0\0\xff", 10);
322 memset(buf, 0xff, sizeof(buf));
323 _mbsncpy(buf, mbsonlylead, 6);
324 expect_bin(buf, "\0\0\0\0\0\0\0\xff", 8);
326 memset(buf, 0xff, sizeof(buf));
327 _mbsnbcpy(buf, mbstring2, 2);
328 expect_bin(buf, "\xb0\xb1\xff", 3);
329 _mbsnbcpy(buf, mbstring2, 3);
330 expect_bin(buf, "\xb0\xb1\0\xff", 4);
331 _mbsnbcpy(buf, mbstring2, 4);
332 expect_bin(buf, "\xb0\xb1\xb2\xb3\xff", 5);
333 memset(buf, 0xff, sizeof(buf));
334 _mbsnbcpy(buf, mbsonlylead, 5);
335 expect_bin(buf, "\0\0\0\0\0\xff", 6);
338 step = _mbsinc(mbstring) - mbstring;
339 ok(step == 2, "_mbsinc adds %d (exp. 2)\n", step);
340 step = _mbsinc(&mbstring[2]) - &mbstring[2]; /* lead + invalid tail */
341 ok(step == 2, "_mbsinc adds %d (exp. 2)\n", step);
343 step = _mbsninc(mbsonlylead, 1) - mbsonlylead;
344 ok(step == 0, "_mbsninc adds %d (exp. 0)\n", step);
345 step = _mbsninc(mbsonlylead, 2) - mbsonlylead; /* lead + NUL byte + lead + char */
346 ok(step == 0, "_mbsninc adds %d (exp. 0)\n", step);
347 step = _mbsninc(mbstring2, 0) - mbstring2;
348 ok(step == 0, "_mbsninc adds %d (exp. 2)\n", step);
349 step = _mbsninc(mbstring2, 1) - mbstring2;
350 ok(step == 2, "_mbsninc adds %d (exp. 2)\n", step);
351 step = _mbsninc(mbstring2, 2) - mbstring2;
352 ok(step == 4, "_mbsninc adds %d (exp. 4)\n", step);
353 step = _mbsninc(mbstring2, 3) - mbstring2;
354 ok(step == 5, "_mbsninc adds %d (exp. 5)\n", step);
355 step = _mbsninc(mbstring2, 4) - mbstring2;
356 ok(step == 7, "_mbsninc adds %d (exp. 7)\n", step);
357 step = _mbsninc(mbstring2, 5) - mbstring2;
358 ok(step == 7, "_mbsninc adds %d (exp. 7)\n", step);
359 step = _mbsninc(mbstring2, 17) - mbstring2;
360 ok(step == 7, "_mbsninc adds %d (exp. 7)\n", step);
362 /* functions that depend on locale codepage, not mbcp.
363 * we hope the current locale to be SBCS because setlocale(LC_ALL, ".1252") seems not to work yet
364 * (as of Wine 0.9.43)
366 GetCPInfo(GetACP(), &cp_info);
367 if (cp_info.MaxCharSize == 1)
369 expect_eq(mblen((char *)mbstring, 3), 1, int, "%x");
370 expect_eq(_mbstrlen((char *)mbstring2), 7, int, "%d");
373 skip("Current locale has double-byte charset - could lead to false positives\n");
376 expect_eq(_ismbblead(0x80), 0, int, "%d");
378 expect_eq(_ismbblead(0x81), 1, int, "%d");
379 expect_eq(_ismbblead(0x83), 1, int, "%d");
381 expect_eq(_ismbblead(0x84), 1, int, "%d");
382 expect_eq(_ismbblead(0xd3), 1, int, "%d");
383 expect_eq(_ismbblead(0xd7), 0, int, "%d");
385 expect_eq(_ismbblead(0xd8), 1, int, "%d");
387 expect_eq(_ismbblead(0xd9), 1, int, "%d");
389 expect_eq(_ismbbtrail(0x30), 0, int, "%d");
390 expect_eq(_ismbbtrail(0x31), 1, int, "%d");
391 expect_eq(_ismbbtrail(0x7e), 1, int, "%d");
392 expect_eq(_ismbbtrail(0x7f), 0, int, "%d");
393 expect_eq(_ismbbtrail(0x80), 0, int, "%d");
394 expect_eq(_ismbbtrail(0x81), 1, int, "%d");
395 expect_eq(_ismbbtrail(0xfe), 1, int, "%d");
396 expect_eq(_ismbbtrail(0xff), 0, int, "%d");
401 static void test_mbsspn( void)
403 unsigned char str1[]="cabernet";
404 unsigned char str2[]="shiraz";
405 unsigned char set[]="abc";
406 unsigned char empty[]="";
408 ret=_mbsspn( str1, set);
409 ok( ret==3, "_mbsspn returns %d should be 3\n", ret);
410 ret=_mbsspn( str2, set);
411 ok( ret==0, "_mbsspn returns %d should be 0\n", ret);
412 ret=_mbsspn( str1, empty);
413 ok( ret==0, "_mbsspn returns %d should be 0\n", ret);
416 static void test_mbsspnp( void)
418 unsigned char str1[]="cabernet";
419 unsigned char str2[]="shiraz";
420 unsigned char set[]="abc";
421 unsigned char empty[]="";
422 unsigned char full[]="abcenrt";
424 ret=_mbsspnp( str1, set);
425 ok( ret[0]=='e', "_mbsspnp returns %c should be e\n", ret[0]);
426 ret=_mbsspnp( str2, set);
427 ok( ret[0]=='s', "_mbsspnp returns %c should be s\n", ret[0]);
428 ret=_mbsspnp( str1, empty);
429 ok( ret[0]=='c', "_mbsspnp returns %c should be c\n", ret[0]);
430 ret=_mbsspnp( str1, full);
431 ok( ret==NULL, "_mbsspnp returns %p should be NULL\n", ret);
434 static void test_strdup(void)
438 ok( str == 0, "strdup returns %s should be 0\n", str);
442 static void test_strcpy_s(void)
445 const char *small = "small";
446 const char *big = "atoolongstringforthislittledestination";
451 skip("strcpy_s not found\n");
455 memset(dest, 'X', sizeof(dest));
456 ret = pstrcpy_s(dest, sizeof(dest), small);
457 ok(ret == 0, "Copying a string into a big enough destination returned %d, expected 0\n", ret);
458 ok(dest[0] == 's' && dest[1] == 'm' && dest[2] == 'a' && dest[3] == 'l' &&
459 dest[4] == 'l' && dest[5] == '\0'&& dest[6] == 'X' && dest[7] == 'X',
460 "Unexpected return data from strcpy_s: 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x\n",
461 dest[0], dest[1], dest[2], dest[3], dest[4], dest[5], dest[6], dest[7]);
463 memset(dest, 'X', sizeof(dest));
464 ret = pstrcpy_s(dest, 0, big);
465 ok(ret == EINVAL, "Copying into a destination of size 0 returned %d, expected EINVAL\n", ret);
466 ok(dest[0] == 'X' && dest[1] == 'X' && dest[2] == 'X' && dest[3] == 'X' &&
467 dest[4] == 'X' && dest[5] == 'X' && dest[6] == 'X' && dest[7] == 'X',
468 "Unexpected return data from strcpy_s: 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x\n",
469 dest[0], dest[1], dest[2], dest[3], dest[4], dest[5], dest[6], dest[7]);
470 ret = pstrcpy_s(dest, 0, NULL);
471 ok(ret == EINVAL, "Copying into a destination of size 0 returned %d, expected EINVAL\n", ret);
472 ok(dest[0] == 'X' && dest[1] == 'X' && dest[2] == 'X' && dest[3] == 'X' &&
473 dest[4] == 'X' && dest[5] == 'X' && dest[6] == 'X' && dest[7] == 'X',
474 "Unexpected return data from strcpy_s: 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x\n",
475 dest[0], dest[1], dest[2], dest[3], dest[4], dest[5], dest[6], dest[7]);
477 memset(dest, 'X', sizeof(dest));
478 ret = pstrcpy_s(dest, sizeof(dest), big);
479 ok(ret == ERANGE, "Copying a big string in a small location returned %d, expected ERANGE\n", ret);
480 ok(dest[0] == '\0'&& dest[1] == 't' && dest[2] == 'o' && dest[3] == 'o' &&
481 dest[4] == 'l' && dest[5] == 'o' && dest[6] == 'n' && dest[7] == 'g',
482 "Unexpected return data from strcpy_s: 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x\n",
483 dest[0], dest[1], dest[2], dest[3], dest[4], dest[5], dest[6], dest[7]);
485 memset(dest, 'X', sizeof(dest));
486 ret = pstrcpy_s(dest, sizeof(dest), NULL);
487 ok(ret == EINVAL, "Copying from a NULL source string returned %d, expected EINVAL\n", ret);
488 ok(dest[0] == '\0'&& dest[1] == 'X' && dest[2] == 'X' && dest[3] == 'X' &&
489 dest[4] == 'X' && dest[5] == 'X' && dest[6] == 'X' && dest[7] == 'X',
490 "Unexpected return data from strcpy_s: 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x\n",
491 dest[0], dest[1], dest[2], dest[3], dest[4], dest[5], dest[6], dest[7]);
493 ret = pstrcpy_s(NULL, sizeof(dest), small);
494 ok(ret == EINVAL, "Copying a big string a NULL dest returned %d, expected EINVAL\n", ret);
497 static void test_strcat_s(void)
500 const char *small = "sma";
505 skip("strcat_s not found\n");
509 memset(dest, 'X', sizeof(dest));
511 ret = pstrcat_s(dest, sizeof(dest), small);
512 ok(ret == 0, "strcat_s: Copying a string into a big enough destination returned %d, expected 0\n", ret);
513 ok(dest[0] == 's' && dest[1] == 'm' && dest[2] == 'a' && dest[3] == '\0'&&
514 dest[4] == 'X' && dest[5] == 'X' && dest[6] == 'X' && dest[7] == 'X',
515 "Unexpected return data from strcpy_s: 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x\n",
516 dest[0], dest[1], dest[2], dest[3], dest[4], dest[5], dest[6], dest[7]);
517 ret = pstrcat_s(dest, sizeof(dest), small);
518 ok(ret == 0, "strcat_s: Attaching a string to a big enough destination returned %d, expected 0\n", ret);
519 ok(dest[0] == 's' && dest[1] == 'm' && dest[2] == 'a' && dest[3] == 's' &&
520 dest[4] == 'm' && dest[5] == 'a' && dest[6] == '\0'&& dest[7] == 'X',
521 "Unexpected return data from strcpy_s: 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x\n",
522 dest[0], dest[1], dest[2], dest[3], dest[4], dest[5], dest[6], dest[7]);
524 ret = pstrcat_s(dest, sizeof(dest), small);
525 ok(ret == ERANGE, "strcat_s: Attaching a string to a filled up destination returned %d, expected ERANGE\n", ret);
526 ok(dest[0] == '\0'&& dest[1] == 'm' && dest[2] == 'a' && dest[3] == 's' &&
527 dest[4] == 'm' && dest[5] == 'a' && dest[6] == 's' && dest[7] == 'm',
528 "Unexpected return data from strcpy_s: 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x\n",
529 dest[0], dest[1], dest[2], dest[3], dest[4], dest[5], dest[6], dest[7]);
531 memset(dest, 'X', sizeof(dest));
535 ret = pstrcat_s(dest, 0, small);
536 ok(ret == EINVAL, "strcat_s: Source len = 0 returned %d, expected EINVAL\n", ret);
537 ok(dest[0] == 'a' && dest[1] == '\0'&& dest[2] == 'X' && dest[3] == 'X' &&
538 dest[4] == 'X' && dest[5] == 'X' && dest[6] == 'X' && dest[7] == 'X',
539 "Unexpected return data from strcpy_s: 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x\n",
540 dest[0], dest[1], dest[2], dest[3], dest[4], dest[5], dest[6], dest[7]);
542 ret = pstrcat_s(dest, 0, NULL);
543 ok(ret == EINVAL, "strcat_s: len = 0 and src = NULL returned %d, expected EINVAL\n", ret);
544 ok(dest[0] == 'a' && dest[1] == '\0'&& dest[2] == 'X' && dest[3] == 'X' &&
545 dest[4] == 'X' && dest[5] == 'X' && dest[6] == 'X' && dest[7] == 'X',
546 "Unexpected return data from strcpy_s: 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x\n",
547 dest[0], dest[1], dest[2], dest[3], dest[4], dest[5], dest[6], dest[7]);
549 ret = pstrcat_s(dest, sizeof(dest), NULL);
550 ok(ret == EINVAL, "strcat_s: Sourcing from NULL returned %d, expected EINVAL\n", ret);
551 ok(dest[0] == '\0'&& dest[1] == '\0'&& dest[2] == 'X' && dest[3] == 'X' &&
552 dest[4] == 'X' && dest[5] == 'X' && dest[6] == 'X' && dest[7] == 'X',
553 "Unexpected return data from strcpy_s: 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x\n",
554 dest[0], dest[1], dest[2], dest[3], dest[4], dest[5], dest[6], dest[7]);
556 ret = pstrcat_s(NULL, sizeof(dest), small);
557 ok(ret == EINVAL, "strcat_s: Writing to a NULL string returned %d, expected EINVAL\n", ret);
560 static void test__mbsnbcpy_s(void)
562 unsigned char dest[8];
563 const unsigned char big[] = "atoolongstringforthislittledestination";
564 const unsigned char small[] = "small";
569 skip("_mbsnbcpy_s not found\n");
573 memset(dest, 'X', sizeof(dest));
574 ret = p_mbsnbcpy_s(dest, sizeof(dest), small, sizeof(small));
575 ok(ret == 0, "_mbsnbcpy_s: Copying a string into a big enough destination returned %d, expected 0\n", ret);
576 ok(dest[0] == 's' && dest[1] == 'm' && dest[2] == 'a' && dest[3] == 'l' &&
577 dest[4] == 'l' && dest[5] == '\0'&& dest[6] == 'X' && dest[7] == 'X',
578 "Unexpected return data from _mbsnbcpy_s: 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x\n",
579 dest[0], dest[1], dest[2], dest[3], dest[4], dest[5], dest[6], dest[7]);
582 memset(dest, 'X', sizeof(dest));
583 ret = p_mbsnbcpy_s(dest, sizeof(dest) - 2, big, sizeof(small));
584 ok(ret == ERANGE, "_mbsnbcpy_s: Copying a too long string returned %d, expected ERANGE\n", ret);
585 ok(dest[0] == '\0'&& dest[1] == 't' && dest[2] == 'o' && dest[3] == 'o' &&
586 dest[4] == 'l' && dest[5] == 'o' && dest[6] == 'X' && dest[7] == 'X',
587 "Unexpected return data from _mbsnbcpy_s: 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x\n",
588 dest[0], dest[1], dest[2], dest[3], dest[4], dest[5], dest[6], dest[7]);
590 memset(dest, 'X', sizeof(dest));
591 ret = p_mbsnbcpy_s(dest, sizeof(dest) - 2, big, 4);
592 ok(ret == 0, "_mbsnbcpy_s: Copying a too long string with a count cap returned %d, expected 0\n", ret);
593 ok(dest[0] == 'a' && dest[1] == 't' && dest[2] == 'o' && dest[3] == 'o' &&
594 dest[4] == '\0'&& dest[5] == 'X' && dest[6] == 'X' && dest[7] == 'X',
595 "Unexpected return data from _mbsnbcpy_s: 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x\n",
596 dest[0], dest[1], dest[2], dest[3], dest[4], dest[5], dest[6], dest[7]);
598 memset(dest, 'X', sizeof(dest));
599 ret = p_mbsnbcpy_s(dest, sizeof(dest) - 2, small, sizeof(small) + 10);
600 ok(ret == 0, "_mbsnbcpy_s: Copying more data than the source string len returned %d, expected 0\n", ret);
601 ok(dest[0] == 's' && dest[1] == 'm' && dest[2] == 'a' && dest[3] == 'l' &&
602 dest[4] == 'l' && dest[5] == '\0'&& dest[6] == 'X' && dest[7] == 'X',
603 "Unexpected return data from _mbsnbcpy_s: 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x\n",
604 dest[0], dest[1], dest[2], dest[3], dest[4], dest[5], dest[6], dest[7]);
607 static void test_wcscpy_s(void)
609 static const WCHAR szLongText[] = { 'T','h','i','s','A','L','o','n','g','s','t','r','i','n','g',0 };
610 static WCHAR szDest[18];
611 static WCHAR szDestShort[8];
616 skip("wcscpy_s not found\n");
621 ret = p_wcscpy_s(NULL, 18, szLongText);
622 ok(ret == EINVAL, "p_wcscpy_s expect EINVAL got %d\n", ret);
624 /* Test NULL Source */
626 ret = p_wcscpy_s(szDest, 18, NULL);
627 ok(ret == EINVAL, "expected EINVAL got %d\n", ret);
628 ok(szDest[0] == 0, "szDest[0] not 0\n");
630 /* Test invalid size */
632 ret = p_wcscpy_s(szDest, 0, szLongText);
633 /* Later versions changed the return value for this case to EINVAL,
634 * and don't modify the result if the dest size is 0.
636 ok(ret == ERANGE || ret == EINVAL, "expected ERANGE/EINVAL got %d\n", ret);
637 ok(szDest[0] == 0 || ret == EINVAL, "szDest[0] not 0\n");
639 /* Copy same buffer size */
640 ret = p_wcscpy_s(szDest, 18, szLongText);
641 ok(ret == 0, "expected 0 got %d\n", ret);
642 ok(lstrcmpW(szDest, szLongText) == 0, "szDest != szLongText\n");
644 /* Copy smaller buffer size */
646 ret = p_wcscpy_s(szDestShort, 8, szLongText);
647 ok(ret == ERANGE || ret == EINVAL, "expected ERANGE/EINVAL got %d\n", ret);
648 ok(szDestShort[0] == 0, "szDestShort[0] not 0\n");
651 static void test__wcsupr_s(void)
653 static const WCHAR mixedString[] = {'M', 'i', 'X', 'e', 'D', 'l', 'o', 'w',
654 'e', 'r', 'U', 'P', 'P', 'E', 'R', 0};
655 static const WCHAR expectedString[] = {'M', 'I', 'X', 'E', 'D', 'L', 'O',
656 'W', 'E', 'R', 'U', 'P', 'P', 'E',
658 WCHAR testBuffer[2*sizeof(mixedString)/sizeof(WCHAR)];
663 win_skip("_wcsupr_s not found\n");
667 /* Test NULL input string and invalid size. */
669 ret = p_wcsupr_s(NULL, 0);
670 ok(ret == EINVAL, "Expected _wcsupr_s to fail with EINVAL, got %d\n", ret);
671 ok(errno == EINVAL, "Expected errno to be EINVAL, got %d\n", errno);
673 /* Test NULL input string and valid size. */
675 ret = p_wcsupr_s(NULL, sizeof(testBuffer)/sizeof(WCHAR));
676 ok(ret == EINVAL, "Expected _wcsupr_s to fail with EINVAL, got %d\n", ret);
677 ok(errno == EINVAL, "Expected errno to be EINVAL, got %d\n", errno);
679 /* Test empty string with zero size. */
681 testBuffer[0] = '\0';
682 ret = p_wcsupr_s(testBuffer, 0);
683 ok(ret == EINVAL, "Expected _wcsupr_s to fail with EINVAL, got %d\n", ret);
684 ok(errno == EINVAL, "Expected errno to be EINVAL, got %d\n", errno);
685 ok(testBuffer[0] == '\0', "Expected the buffer to be unchanged\n");
687 /* Test empty string with size of one. */
688 testBuffer[0] = '\0';
689 ret = p_wcsupr_s(testBuffer, 1);
690 ok(ret == 0, "Expected _wcsupr_s to succeed, got %d\n", ret);
691 ok(testBuffer[0] == '\0', "Expected the buffer to be unchanged\n");
693 /* Test one-byte buffer with zero size. */
696 ret = p_wcsupr_s(testBuffer, 0);
697 ok(ret == EINVAL, "Expected _wcsupr_s to fail with EINVAL, got %d\n", ret);
698 ok(errno == EINVAL, "Expected errno to be EINVAL, got %d\n", errno);
699 ok(testBuffer[0] == '\0', "Expected the first buffer character to be null\n");
701 /* Test one-byte buffer with size of one. */
704 ret = p_wcsupr_s(testBuffer, 1);
705 ok(ret == EINVAL, "Expected _wcsupr_s to fail with EINVAL, got %d\n", ret);
706 ok(errno == EINVAL, "Expected errno to be EINVAL, got %d\n", errno);
707 ok(testBuffer[0] == '\0', "Expected the first buffer character to be null\n");
709 /* Test invalid size. */
710 wcscpy(testBuffer, mixedString);
712 ret = p_wcsupr_s(testBuffer, 0);
713 ok(ret == EINVAL, "Expected _wcsupr_s to fail with EINVAL, got %d\n", ret);
714 ok(errno == EINVAL, "Expected errno to be EINVAL, got %d\n", errno);
715 ok(testBuffer[0] == '\0', "Expected the first buffer character to be null\n");
717 /* Test normal string uppercasing. */
718 wcscpy(testBuffer, mixedString);
719 ret = p_wcsupr_s(testBuffer, sizeof(mixedString)/sizeof(WCHAR));
720 ok(ret == 0, "Expected _wcsupr_s to succeed, got %d\n", ret);
721 ok(!wcscmp(testBuffer, expectedString), "Expected the string to be fully upper-case\n");
723 /* Test uppercasing with a shorter buffer size count. */
724 wcscpy(testBuffer, mixedString);
726 ret = p_wcsupr_s(testBuffer, sizeof(mixedString)/sizeof(WCHAR) - 1);
727 ok(ret == EINVAL, "Expected _wcsupr_s to fail with EINVAL, got %d\n", ret);
728 ok(errno == EINVAL, "Expected errno to be EINVAL, got %d\n", errno);
729 ok(testBuffer[0] == '\0', "Expected the first buffer character to be null\n");
731 /* Test uppercasing with a longer buffer size count. */
732 wcscpy(testBuffer, mixedString);
733 ret = p_wcsupr_s(testBuffer, sizeof(testBuffer)/sizeof(WCHAR));
734 ok(ret == 0, "Expected _wcsupr_s to succeed, got %d\n", ret);
735 ok(!wcscmp(testBuffer, expectedString), "Expected the string to be fully upper-case\n");
738 static void test__wcslwr_s(void)
740 static const WCHAR mixedString[] = {'M', 'i', 'X', 'e', 'D', 'l', 'o', 'w',
741 'e', 'r', 'U', 'P', 'P', 'E', 'R', 0};
742 static const WCHAR expectedString[] = {'m', 'i', 'x', 'e', 'd', 'l', 'o',
743 'w', 'e', 'r', 'u', 'p', 'p', 'e',
745 WCHAR buffer[2*sizeof(mixedString)/sizeof(WCHAR)];
750 win_skip("_wcslwr_s not found\n");
754 /* Test NULL input string and invalid size. */
756 ret = p_wcslwr_s(NULL, 0);
757 ok(ret == EINVAL, "expected EINVAL, got %d\n", ret);
758 ok(errno == EINVAL, "expected errno EINVAL, got %d\n", errno);
760 /* Test NULL input string and valid size. */
762 ret = p_wcslwr_s(NULL, sizeof(buffer)/sizeof(wchar_t));
763 ok(ret == EINVAL, "expected EINVAL, got %d\n", ret);
764 ok(errno == EINVAL, "expected errno EINVAL, got %d\n", errno);
766 /* Test empty string with zero size. */
769 ret = p_wcslwr_s(buffer, 0);
770 ok(ret == EINVAL, "expected EINVAL, got %d\n", ret);
771 ok(errno == EINVAL, "expected errno EINVAL, got %d\n", errno);
772 ok(buffer[0] == 0, "expected empty string\n");
774 /* Test empty string with size of one. */
776 ret = p_wcslwr_s(buffer, 1);
777 ok(ret == 0, "got %d\n", ret);
778 ok(buffer[0] == 0, "expected buffer to be unchanged\n");
780 /* Test one-byte buffer with zero size. */
783 ret = p_wcslwr_s(buffer, 0);
784 ok(ret == EINVAL, "expected EINVAL, got %d\n", ret);
785 ok(errno == EINVAL, "expected errno to be EINVAL, got %d\n", errno);
786 ok(buffer[0] == '\0', "expected empty string\n");
788 /* Test one-byte buffer with size of one. */
791 ret = p_wcslwr_s(buffer, 1);
792 ok(ret == EINVAL, "expected EINVAL, got %d\n", ret);
793 ok(errno == EINVAL, "expected errno to be EINVAL, got %d\n", errno);
794 ok(buffer[0] == '\0', "expected empty string\n");
796 /* Test invalid size. */
797 wcscpy(buffer, mixedString);
799 ret = p_wcslwr_s(buffer, 0);
800 ok(ret == EINVAL, "Expected EINVAL, got %d\n", ret);
801 ok(errno == EINVAL, "expected errno to be EINVAL, got %d\n", errno);
802 ok(buffer[0] == '\0', "expected empty string\n");
804 /* Test normal string uppercasing. */
805 wcscpy(buffer, mixedString);
806 ret = p_wcslwr_s(buffer, sizeof(mixedString)/sizeof(WCHAR));
807 ok(ret == 0, "expected 0, got %d\n", ret);
808 ok(!wcscmp(buffer, expectedString), "expected lowercase\n");
810 /* Test uppercasing with a shorter buffer size count. */
811 wcscpy(buffer, mixedString);
813 ret = p_wcslwr_s(buffer, sizeof(mixedString)/sizeof(WCHAR) - 1);
814 ok(ret == EINVAL, "expected EINVAL, got %d\n", ret);
815 ok(errno == EINVAL, "expected errno to be EINVAL, got %d\n", errno);
816 ok(buffer[0] == '\0', "expected empty string\n");
818 /* Test uppercasing with a longer buffer size count. */
819 wcscpy(buffer, mixedString);
820 ret = p_wcslwr_s(buffer, sizeof(buffer)/sizeof(WCHAR));
821 ok(ret == 0, "expected 0, got %d\n", ret);
822 ok(!wcscmp(buffer, expectedString), "expected lowercase\n");
825 static void test_mbcjisjms(void)
827 /* List of value-pairs to test. The test assumes the last pair to be {0, ..} */
828 unsigned int jisjms[][2] = { {0x2020, 0}, {0x2021, 0}, {0x2120, 0}, {0x2121, 0x8140},
829 {0x7f7f, 0}, {0x7f7e, 0}, {0x7e7f, 0}, {0x7e7e, 0xeffc},
830 {0x2121FFFF, 0}, {0x2223, 0x81a1}, {0x237e, 0x829e}, {0, 0}};
831 unsigned int ret, exp, i;
836 ret = _mbcjistojms(jisjms[i][0]);
838 if(_getmbcp() == 932) /* Japanese codepage? */
841 exp = jisjms[i][0]; /* If not, no conversion */
843 ok(ret == exp, "Expected 0x%x, got 0x%x\n", exp, ret);
844 } while(jisjms[i++][0] != 0);
847 static void test_mbctombb(void)
849 static const unsigned int mbcmbb_932[][2] = {
850 {0x829e, 0x829e}, {0x829f, 0xa7}, {0x82f1, 0xdd}, {0x82f2, 0x82f2},
851 {0x833f, 0x833f}, {0x8340, 0xa7}, {0x837e, 0xd0}, {0x837f, 0x837f},
852 {0x8380, 0xd1}, {0x8396, 0xb9}, {0x8397, 0x8397}, {0x813f, 0x813f},
853 {0x8140, 0x20}, {0x814c, 0x814c}, {0x814f, 0x5e}, {0x8197, 0x40},
854 {0x8198, 0x8198}, {0x8258, 0x39}, {0x8259, 0x8259}, {0x825f, 0x825f},
855 {0x8260, 0x41}, {0x82f1, 0xdd}, {0x82f2, 0x82f2}, {0,0}};
856 unsigned int exp, ret, i;
857 unsigned int prev_cp = _getmbcp();
860 for (i = 0; mbcmbb_932[i][0] != 0; i++)
862 ret = _mbctombb(mbcmbb_932[i][0]);
863 exp = mbcmbb_932[i][1];
864 ok(ret == exp, "Expected 0x%x, got 0x%x\n", exp, ret);
869 static void test_ismbclegal(void) {
870 unsigned int prev_cp = _getmbcp();
874 _setmbcp(932); /* Japanese */
876 for(i = 0; i < 0x10000; i++) {
877 ret = _ismbclegal(i);
878 exp = ((HIBYTE(i) >= 0x81 && HIBYTE(i) <= 0x9F) ||
879 (HIBYTE(i) >= 0xE0 && HIBYTE(i) <= 0xFC)) &&
880 ((LOBYTE(i) >= 0x40 && LOBYTE(i) <= 0x7E) ||
881 (LOBYTE(i) >= 0x80 && LOBYTE(i) <= 0xFC));
887 ok(!err, "_ismbclegal (932) : Expected 0x%x, got 0x%x (0x%x)\n", exp, ret, i);
888 _setmbcp(936); /* Chinese (GBK) */
890 for(i = 0; i < 0x10000; i++) {
891 ret = _ismbclegal(i);
892 exp = HIBYTE(i) >= 0x81 && HIBYTE(i) <= 0xFE &&
893 LOBYTE(i) >= 0x40 && LOBYTE(i) <= 0xFE;
899 ok(!err, "_ismbclegal (936) : Expected 0x%x, got 0x%x (0x%x)\n", exp, ret, i);
900 _setmbcp(949); /* Korean */
902 for(i = 0; i < 0x10000; i++) {
903 ret = _ismbclegal(i);
904 exp = HIBYTE(i) >= 0x81 && HIBYTE(i) <= 0xFE &&
905 LOBYTE(i) >= 0x41 && LOBYTE(i) <= 0xFE;
911 ok(!err, "_ismbclegal (949) : Expected 0x%x, got 0x%x (0x%x)\n", exp, ret, i);
912 _setmbcp(950); /* Chinese (Big5) */
914 for(i = 0; i < 0x10000; i++) {
915 ret = _ismbclegal(i);
916 exp = HIBYTE(i) >= 0x81 && HIBYTE(i) <= 0xFE &&
917 ((LOBYTE(i) >= 0x40 && LOBYTE(i) <= 0x7E) ||
918 (LOBYTE(i) >= 0xA1 && LOBYTE(i) <= 0xFE));
924 ok(!err, "_ismbclegal (950) : Expected 0x%x, got 0x%x (0x%x)\n", exp, ret, i);
925 _setmbcp(1361); /* Korean (Johab) */
927 for(i = 0; i < 0x10000; i++) {
928 ret = _ismbclegal(i);
929 exp = ((HIBYTE(i) >= 0x81 && HIBYTE(i) <= 0xD3) ||
930 (HIBYTE(i) >= 0xD8 && HIBYTE(i) <= 0xF9)) &&
931 ((LOBYTE(i) >= 0x31 && LOBYTE(i) <= 0x7E) ||
932 (LOBYTE(i) >= 0x81 && LOBYTE(i) <= 0xFE)) &&
939 todo_wine ok(!err, "_ismbclegal (1361) : Expected 0x%x, got 0x%x (0x%x)\n", exp, ret, i);
944 static const struct {
946 const char* delimiter;
947 int exp_offsetret1; /* returned offset from string after first call to strtok()
949 int exp_offsetret2; /* returned offset from string after second call to strtok()
951 int exp_offsetret3; /* returned offset from string after third call to strtok()
953 } testcases_strtok[] = {
954 { "red cabernet", " ", 0, 4, -1 },
955 { "sparkling white riesling", " ", 0, 10, 16 },
956 { " pale cream sherry", "e ", 1, 6, 9 },
961 static void test_strtok(void)
966 for( i = 0; testcases_strtok[i].string; i++){
967 strcpy( teststr, testcases_strtok[i].string);
968 strret = strtok( teststr, testcases_strtok[i].delimiter);
969 ok( (int)(strret - teststr) == testcases_strtok[i].exp_offsetret1 ||
970 (!strret && testcases_strtok[i].exp_offsetret1 == -1),
971 "string (%p) \'%s\' return %p\n",
972 teststr, testcases_strtok[i].string, strret);
973 if( !strret) continue;
974 strret = strtok( NULL, testcases_strtok[i].delimiter);
975 ok( (int)(strret - teststr) == testcases_strtok[i].exp_offsetret2 ||
976 (!strret && testcases_strtok[i].exp_offsetret2 == -1),
977 "second call string (%p) \'%s\' return %p\n",
978 teststr, testcases_strtok[i].string, strret);
979 if( !strret) continue;
980 strret = strtok( NULL, testcases_strtok[i].delimiter);
981 ok( (int)(strret - teststr) == testcases_strtok[i].exp_offsetret3 ||
982 (!strret && testcases_strtok[i].exp_offsetret3 == -1),
983 "third call string (%p) \'%s\' return %p\n",
984 teststr, testcases_strtok[i].string, strret);
988 static void test_strtol(void)
994 /* errno is only set in case of error, so reset errno to EBADF to check for errno modification */
995 /* errno is modified on W2K8+ */
997 l = strtol("-1234", &e, 0);
998 ok(l==-1234, "wrong value %d\n", l);
999 ok(errno == EBADF || broken(errno == 0), "wrong errno %d\n", errno);
1001 ul = strtoul("1234", &e, 0);
1002 ok(ul==1234, "wrong value %u\n", ul);
1003 ok(errno == EBADF || broken(errno == 0), "wrong errno %d\n", errno);
1006 l = strtol("2147483647L", &e, 0);
1007 ok(l==2147483647, "wrong value %d\n", l);
1008 ok(errno == EBADF || broken(errno == 0), "wrong errno %d\n", errno);
1010 l = strtol("-2147483648L", &e, 0);
1011 ok(l==-2147483647L - 1, "wrong value %d\n", l);
1012 ok(errno == EBADF || broken(errno == 0), "wrong errno %d\n", errno);
1014 ul = strtoul("4294967295UL", &e, 0);
1015 ok(ul==4294967295ul, "wrong value %u\n", ul);
1016 ok(errno == EBADF || broken(errno == 0), "wrong errno %d\n", errno);
1019 l = strtol("9223372036854775807L", &e, 0);
1020 ok(l==2147483647, "wrong value %d\n", l);
1021 ok(errno == ERANGE, "wrong errno %d\n", errno);
1023 ul = strtoul("9223372036854775807L", &e, 0);
1024 ok(ul==4294967295ul, "wrong value %u\n", ul);
1025 ok(errno == ERANGE, "wrong errno %d\n", errno);
1028 static void test_strnlen(void)
1030 static const char str[] = "string";
1034 win_skip("strnlen not found\n");
1038 res = p_strnlen(str, 20);
1039 ok(res == 6, "Returned length = %d\n", (int)res);
1041 res = p_strnlen(str, 3);
1042 ok(res == 3, "Returned length = %d\n", (int)res);
1044 res = p_strnlen(NULL, 0);
1045 ok(res == 0, "Returned length = %d\n", (int)res);
1048 static void test__strtoi64(void)
1050 static const char no1[] = "31923";
1051 static const char no2[] = "-213312";
1052 static const char no3[] = "12aa";
1053 static const char no4[] = "abc12";
1054 static const char overflow[] = "99999999999999999999";
1055 static const char neg_overflow[] = "-99999999999999999999";
1056 static const char hex[] = "0x123";
1057 static const char oct[] = "000123";
1058 static const char blanks[] = " 12 212.31";
1061 unsigned __int64 ures;
1064 if(!p_strtoi64 || !p_strtoui64) {
1065 win_skip("_strtoi64 or _strtoui64 not found\n");
1070 res = p_strtoi64(no1, NULL, 10);
1071 ok(res == 31923, "res != 31923\n");
1072 res = p_strtoi64(no2, NULL, 10);
1073 ok(res == -213312, "res != -213312\n");
1074 res = p_strtoi64(no3, NULL, 10);
1075 ok(res == 12, "res != 12\n");
1076 res = p_strtoi64(no4, &endpos, 10);
1077 ok(res == 0, "res != 0\n");
1078 ok(endpos == no4, "Scanning was not stopped on first character\n");
1079 res = p_strtoi64(hex, &endpos, 10);
1080 ok(res == 0, "res != 0\n");
1081 ok(endpos == hex+1, "Incorrect endpos (%p-%p)\n", hex, endpos);
1082 res = p_strtoi64(oct, &endpos, 10);
1083 ok(res == 123, "res != 123\n");
1084 ok(endpos == oct+strlen(oct), "Incorrect endpos (%p-%p)\n", oct, endpos);
1085 res = p_strtoi64(blanks, &endpos, 10);
1086 ok(res == 12, "res != 12\n");
1087 ok(endpos == blanks+10, "Incorrect endpos (%p-%p)\n", blanks, endpos);
1088 ok(errno == 0xdeadbeef, "errno = %x\n", errno);
1091 res = p_strtoi64(overflow, &endpos, 10);
1092 ok(res == _I64_MAX, "res != _I64_MAX\n");
1093 ok(endpos == overflow+strlen(overflow), "Incorrect endpos (%p-%p)\n", overflow, endpos);
1094 ok(errno == ERANGE, "errno = %x\n", errno);
1097 res = p_strtoi64(neg_overflow, &endpos, 10);
1098 ok(res == _I64_MIN, "res != _I64_MIN\n");
1099 ok(endpos == neg_overflow+strlen(neg_overflow), "Incorrect endpos (%p-%p)\n", neg_overflow, endpos);
1100 ok(errno == ERANGE, "errno = %x\n", errno);
1103 res = p_strtoi64(no1, &endpos, 16);
1104 ok(res == 203043, "res != 203043\n");
1105 ok(endpos == no1+strlen(no1), "Incorrect endpos (%p-%p)\n", no1, endpos);
1106 res = p_strtoi64(no2, &endpos, 16);
1107 ok(res == -2175762, "res != -2175762\n");
1108 ok(endpos == no2+strlen(no2), "Incorrect endpos (%p-%p)\n", no2, endpos);
1109 res = p_strtoi64(no3, &endpos, 16);
1110 ok(res == 4778, "res != 4778\n");
1111 ok(endpos == no3+strlen(no3), "Incorrect endpos (%p-%p)\n", no3, endpos);
1112 res = p_strtoi64(no4, &endpos, 16);
1113 ok(res == 703506, "res != 703506\n");
1114 ok(endpos == no4+strlen(no4), "Incorrect endpos (%p-%p)\n", no4, endpos);
1115 res = p_strtoi64(hex, &endpos, 16);
1116 ok(res == 291, "res != 291\n");
1117 ok(endpos == hex+strlen(hex), "Incorrect endpos (%p-%p)\n", hex, endpos);
1118 res = p_strtoi64(oct, &endpos, 16);
1119 ok(res == 291, "res != 291\n");
1120 ok(endpos == oct+strlen(oct), "Incorrect endpos (%p-%p)\n", oct, endpos);
1121 res = p_strtoi64(blanks, &endpos, 16);
1122 ok(res == 18, "res != 18\n");
1123 ok(endpos == blanks+10, "Incorrect endpos (%p-%p)\n", blanks, endpos);
1124 ok(errno == 0xdeadbeef, "errno = %x\n", errno);
1127 res = p_strtoi64(hex, &endpos, 36);
1128 ok(res == 1541019, "res != 1541019\n");
1129 ok(endpos == hex+strlen(hex), "Incorrect endpos (%p-%p)\n", hex, endpos);
1130 ok(errno == 0xdeadbeef, "errno = %x\n", errno);
1133 res = p_strtoi64(no1, &endpos, 0);
1134 ok(res == 31923, "res != 31923\n");
1135 ok(endpos == no1+strlen(no1), "Incorrect endpos (%p-%p)\n", no1, endpos);
1136 res = p_strtoi64(no2, &endpos, 0);
1137 ok(res == -213312, "res != -213312\n");
1138 ok(endpos == no2+strlen(no2), "Incorrect endpos (%p-%p)\n", no2, endpos);
1139 res = p_strtoi64(no3, &endpos, 10);
1140 ok(res == 12, "res != 12\n");
1141 ok(endpos == no3+2, "Incorrect endpos (%p-%p)\n", no3, endpos);
1142 res = p_strtoi64(no4, &endpos, 10);
1143 ok(res == 0, "res != 0\n");
1144 ok(endpos == no4, "Incorrect endpos (%p-%p)\n", no4, endpos);
1145 res = p_strtoi64(hex, &endpos, 10);
1146 ok(res == 0, "res != 0\n");
1147 ok(endpos == hex+1, "Incorrect endpos (%p-%p)\n", hex, endpos);
1148 res = p_strtoi64(oct, &endpos, 10);
1149 ok(res == 123, "res != 123\n");
1150 ok(endpos == oct+strlen(oct), "Incorrect endpos (%p-%p)\n", oct, endpos);
1151 res = p_strtoi64(blanks, &endpos, 10);
1152 ok(res == 12, "res != 12\n");
1153 ok(endpos == blanks+10, "Incorrect endpos (%p-%p)\n", blanks, endpos);
1154 ok(errno == 0xdeadbeef, "errno = %x\n", errno);
1157 ures = p_strtoui64(no1, &endpos, 0);
1158 ok(ures == 31923, "ures != 31923\n");
1159 ok(endpos == no1+strlen(no1), "Incorrect endpos (%p-%p)\n", no1, endpos);
1160 ures = p_strtoui64(no2, &endpos, 0);
1161 ok(ures == -213312, "ures != -213312\n");
1162 ok(endpos == no2+strlen(no2), "Incorrect endpos (%p-%p)\n", no2, endpos);
1163 ures = p_strtoui64(no3, &endpos, 10);
1164 ok(ures == 12, "ures != 12\n");
1165 ok(endpos == no3+2, "Incorrect endpos (%p-%p)\n", no3, endpos);
1166 ures = p_strtoui64(no4, &endpos, 10);
1167 ok(ures == 0, "ures != 0\n");
1168 ok(endpos == no4, "Incorrect endpos (%p-%p)\n", no4, endpos);
1169 ures = p_strtoui64(hex, &endpos, 10);
1170 ok(ures == 0, "ures != 0\n");
1171 ok(endpos == hex+1, "Incorrect endpos (%p-%p)\n", hex, endpos);
1172 ures = p_strtoui64(oct, &endpos, 10);
1173 ok(ures == 123, "ures != 123\n");
1174 ok(endpos == oct+strlen(oct), "Incorrect endpos (%p-%p)\n", oct, endpos);
1175 ures = p_strtoui64(blanks, &endpos, 10);
1176 ok(ures == 12, "ures != 12\n");
1177 ok(endpos == blanks+10, "Incorrect endpos (%p-%p)\n", blanks, endpos);
1178 ok(errno == 0xdeadbeef, "errno = %x\n", errno);
1181 ures = p_strtoui64(overflow, &endpos, 10);
1182 ok(ures == _UI64_MAX, "ures != _UI64_MAX\n");
1183 ok(endpos == overflow+strlen(overflow), "Incorrect endpos (%p-%p)\n", overflow, endpos);
1184 ok(errno == ERANGE, "errno = %x\n", errno);
1187 ures = p_strtoui64(neg_overflow, &endpos, 10);
1188 ok(ures == 1, "ures != 1\n");
1189 ok(endpos == neg_overflow+strlen(neg_overflow), "Incorrect endpos (%p-%p)\n", neg_overflow, endpos);
1190 ok(errno == ERANGE, "errno = %x\n", errno);
1193 static inline BOOL almost_equal(double d1, double d2) {
1194 if(d1-d2>-1e-30 && d1-d2<1e-30)
1199 static void test__strtod(void)
1201 const char double1[] = "12.1";
1202 const char double2[] = "-13.721";
1203 const char double3[] = "INF";
1204 const char double4[] = ".21e12";
1205 const char double5[] = "214353e-3";
1206 const char overflow[] = "1d9999999999999999999";
1207 const char white_chars[] = " d10";
1212 d = strtod(double1, &end);
1213 ok(almost_equal(d, 12.1), "d = %lf\n", d);
1214 ok(end == double1+4, "incorrect end (%d)\n", (int)(end-double1));
1216 d = strtod(double2, &end);
1217 ok(almost_equal(d, -13.721), "d = %lf\n", d);
1218 ok(end == double2+7, "incorrect end (%d)\n", (int)(end-double2));
1220 d = strtod(double3, &end);
1221 ok(almost_equal(d, 0), "d = %lf\n", d);
1222 ok(end == double3, "incorrect end (%d)\n", (int)(end-double3));
1224 d = strtod(double4, &end);
1225 ok(almost_equal(d, 210000000000.0), "d = %lf\n", d);
1226 ok(end == double4+6, "incorrect end (%d)\n", (int)(end-double4));
1228 d = strtod(double5, &end);
1229 ok(almost_equal(d, 214.353), "d = %lf\n", d);
1230 ok(end == double5+9, "incorrect end (%d)\n", (int)(end-double5));
1232 d = strtod("12.1d2", NULL);
1233 ok(almost_equal(d, 12.1e2), "d = %lf\n", d);
1235 d = strtod(white_chars, &end);
1236 ok(almost_equal(d, 0), "d = %lf\n", d);
1237 ok(end == white_chars, "incorrect end (%d)\n", (int)(end-white_chars));
1239 /* Set locale with non '.' decimal point (',') */
1240 if(!setlocale(LC_ALL, "Polish")) {
1241 win_skip("system with limited locales\n");
1245 d = strtod("12.1", NULL);
1246 ok(almost_equal(d, 12.0), "d = %lf\n", d);
1248 d = strtod("12,1", NULL);
1249 ok(almost_equal(d, 12.1), "d = %lf\n", d);
1251 setlocale(LC_ALL, "C");
1253 /* Precision tests */
1254 d = strtod("0.1", NULL);
1255 ok(almost_equal(d, 0.1), "d = %lf\n", d);
1256 d = strtod("-0.1", NULL);
1257 ok(almost_equal(d, -0.1), "d = %lf\n", d);
1258 d = strtod("0.1281832188491894198128921", NULL);
1259 ok(almost_equal(d, 0.1281832188491894198128921), "d = %lf\n", d);
1260 d = strtod("0.82181281288121", NULL);
1261 ok(almost_equal(d, 0.82181281288121), "d = %lf\n", d);
1262 d = strtod("21921922352523587651128218821", NULL);
1263 ok(almost_equal(d, 21921922352523587651128218821.0), "d = %lf\n", d);
1264 d = strtod("0.1d238", NULL);
1265 ok(almost_equal(d, 0.1e238L), "d = %lf\n", d);
1266 d = strtod("0.1D-4736", NULL);
1267 ok(almost_equal(d, 0.1e-4736L), "d = %lf\n", d);
1270 strtod(overflow, &end);
1271 ok(errno == ERANGE, "errno = %x\n", errno);
1272 ok(end == overflow+21, "incorrect end (%d)\n", (int)(end-overflow));
1275 strtod("-1d309", NULL);
1276 ok(errno == ERANGE, "errno = %x\n", errno);
1279 static void test_mbstowcs(void)
1281 static const wchar_t wSimple[] = { 't','e','x','t',0 };
1282 static const wchar_t wHiragana[] = { 0x3042,0x3043,0 };
1283 static const char mSimple[] = "text";
1284 static const char mHiragana[] = { 0x82,0xa0,0x82,0xa1,0 };
1291 wOut[4] = '!'; wOut[5] = '\0';
1292 mOut[4] = '!'; mOut[5] = '\0';
1294 ret = mbstowcs(NULL, mSimple, 0);
1295 ok(ret == 4, "mbstowcs did not return 4\n");
1297 ret = mbstowcs(wOut, mSimple, 4);
1298 ok(ret == 4, "mbstowcs did not return 4\n");
1299 ok(!memcmp(wOut, wSimple, 4*sizeof(wchar_t)), "wOut = %s\n", wine_dbgstr_w(wOut));
1300 ok(wOut[4] == '!', "wOut[4] != \'!\'\n");
1302 ret = wcstombs(NULL, wSimple, 0);
1303 ok(ret == 4, "wcstombs did not return 4\n");
1305 ret = wcstombs(mOut, wSimple, 6);
1306 ok(ret == 4, "wcstombs did not return 4\n");
1307 ok(!memcmp(mOut, mSimple, 5*sizeof(char)), "mOut = %s\n", mOut);
1309 ret = wcstombs(mOut, wSimple, 2);
1310 ok(ret == 2, "wcstombs did not return 2\n");
1311 ok(!memcmp(mOut, mSimple, 5*sizeof(char)), "mOut = %s\n", mOut);
1313 if(!setlocale(LC_ALL, "Japanese_Japan.932")) {
1314 win_skip("Japanese_Japan.932 locale not available\n");
1318 ret = mbstowcs(wOut, mHiragana, 6);
1319 ok(ret == 2, "mbstowcs did not return 2\n");
1320 ok(!memcmp(wOut, wHiragana, sizeof(wHiragana)), "wOut = %s\n", wine_dbgstr_w(wOut));
1322 ret = wcstombs(mOut, wHiragana, 6);
1323 ok(ret == 4, "wcstombs did not return 4\n");
1324 ok(!memcmp(mOut, mHiragana, sizeof(mHiragana)), "mOut = %s\n", mOut);
1326 if(!pmbstowcs_s || !pwcstombs_s) {
1327 win_skip("mbstowcs_s or wcstombs_s not available\n");
1331 err = pmbstowcs_s(&ret, wOut, 6, mSimple, _TRUNCATE);
1332 ok(err == 0, "err = %d\n", err);
1333 ok(ret == 5, "ret = %d\n", (int)ret);
1334 ok(!memcmp(wOut, wSimple, sizeof(wSimple)), "wOut = %s\n", wine_dbgstr_w(wOut));
1336 err = pmbstowcs_s(&ret, wOut, 6, mHiragana, _TRUNCATE);
1337 ok(err == 0, "err = %d\n", err);
1338 ok(ret == 3, "ret = %d\n", (int)ret);
1339 ok(!memcmp(wOut, wHiragana, sizeof(wHiragana)), "wOut = %s\n", wine_dbgstr_w(wOut));
1341 err = pmbstowcs_s(&ret, NULL, 0, mHiragana, 1);
1342 ok(err == 0, "err = %d\n", err);
1343 ok(ret == 3, "ret = %d\n", (int)ret);
1345 err = pwcstombs_s(&ret, mOut, 6, wSimple, _TRUNCATE);
1346 ok(err == 0, "err = %d\n", err);
1347 ok(ret == 5, "ret = %d\n", (int)ret);
1348 ok(!memcmp(mOut, mSimple, sizeof(mSimple)), "mOut = %s\n", mOut);
1350 err = pwcstombs_s(&ret, mOut, 6, wHiragana, _TRUNCATE);
1351 ok(err == 0, "err = %d\n", err);
1352 ok(ret == 5, "ret = %d\n", (int)ret);
1353 ok(!memcmp(mOut, mHiragana, sizeof(mHiragana)), "mOut = %s\n", mOut);
1355 err = pwcstombs_s(&ret, NULL, 0, wHiragana, 1);
1356 ok(err == 0, "err = %d\n", err);
1357 ok(ret == 5, "ret = %d\n", (int)ret);
1360 static void test_gcvt(void)
1362 char buf[1024], *res;
1366 win_skip("Skipping _gcvt tests\n");
1371 res = _gcvt(1.2, -1, buf);
1372 ok(res == NULL, "res != NULL\n");
1373 ok(errno == ERANGE, "errno = %d\n", errno);
1376 res = _gcvt(1.2, 5, NULL);
1377 ok(res == NULL, "res != NULL\n");
1378 ok(errno == EINVAL, "errno = %d\n", errno);
1380 res = gcvt(1.2, 5, buf);
1381 ok(res == buf, "res != buf\n");
1382 ok(!strcmp(buf, "1.2"), "buf = %s\n", buf);
1385 err = p_gcvt_s(buf, 5, 1.2, 10);
1386 ok(err == ERANGE, "err = %d\n", err);
1387 ok(buf[0] == '\0', "buf[0] = %c\n", buf[0]);
1390 err = p_gcvt_s(buf, 4, 123456, 2);
1391 ok(err == ERANGE, "err = %d\n", err);
1392 ok(buf[0] == '\0', "buf[0] = %c\n", buf[0]);
1395 static void test__itoa_s(void)
1402 win_skip("Skipping _itoa_s tests\n");
1406 if (p_set_invalid_parameter_handler)
1407 ok(p_set_invalid_parameter_handler(test_invalid_parameter_handler) == NULL,
1408 "Invalid parameter handler was already set\n");
1411 ret = p_itoa_s(0, NULL, 0, 0);
1412 ok(ret == EINVAL, "Expected _itoa_s to return EINVAL, got %d\n", ret);
1413 ok(errno == EINVAL, "Expected errno to be EINVAL, got %d\n", errno);
1415 memset(buffer, 'X', sizeof(buffer));
1417 ret = p_itoa_s(0, buffer, 0, 0);
1418 ok(ret == EINVAL, "Expected _itoa_s to return EINVAL, got %d\n", ret);
1419 ok(errno == EINVAL, "Expected errno to be EINVAL, got %d\n", errno);
1420 ok(buffer[0] == 'X', "Expected the output buffer to be untouched\n");
1422 memset(buffer, 'X', sizeof(buffer));
1424 ret = p_itoa_s(0, buffer, sizeof(buffer), 0);
1425 ok(ret == EINVAL, "Expected _itoa_s to return EINVAL, got %d\n", ret);
1426 ok(errno == EINVAL, "Expected errno to be EINVAL, got %d\n", errno);
1427 ok(buffer[0] == '\0', "Expected the output buffer to be null terminated\n");
1429 memset(buffer, 'X', sizeof(buffer));
1431 ret = p_itoa_s(0, buffer, sizeof(buffer), 64);
1432 ok(ret == EINVAL, "Expected _itoa_s to return EINVAL, got %d\n", ret);
1433 ok(errno == EINVAL, "Expected errno to be EINVAL, got %d\n", errno);
1434 ok(buffer[0] == '\0', "Expected the output buffer to be null terminated\n");
1436 memset(buffer, 'X', sizeof(buffer));
1438 ret = p_itoa_s(12345678, buffer, 4, 10);
1439 ok(ret == ERANGE, "Expected _itoa_s to return ERANGE, got %d\n", ret);
1440 ok(errno == ERANGE, "Expected errno to be ERANGE, got %d\n", errno);
1441 ok(!memcmp(buffer, "\000765", 4),
1442 "Expected the output buffer to be null terminated with truncated output\n");
1444 memset(buffer, 'X', sizeof(buffer));
1446 ret = p_itoa_s(12345678, buffer, 8, 10);
1447 ok(ret == ERANGE, "Expected _itoa_s to return ERANGE, got %d\n", ret);
1448 ok(errno == ERANGE, "Expected errno to be ERANGE, got %d\n", errno);
1449 ok(!memcmp(buffer, "\0007654321", 8),
1450 "Expected the output buffer to be null terminated with truncated output\n");
1452 memset(buffer, 'X', sizeof(buffer));
1454 ret = p_itoa_s(-12345678, buffer, 9, 10);
1455 ok(ret == ERANGE, "Expected _itoa_s to return ERANGE, got %d\n", ret);
1456 ok(errno == ERANGE, "Expected errno to be ERANGE, got %d\n", errno);
1457 ok(!memcmp(buffer, "\00087654321", 9),
1458 "Expected the output buffer to be null terminated with truncated output\n");
1460 ret = p_itoa_s(12345678, buffer, 9, 10);
1461 ok(ret == 0, "Expected _itoa_s to return 0, got %d\n", ret);
1462 ok(!strcmp(buffer, "12345678"),
1463 "Expected output buffer string to be \"12345678\", got \"%s\"\n",
1466 ret = p_itoa_s(43690, buffer, sizeof(buffer), 2);
1467 ok(ret == 0, "Expected _itoa_s to return 0, got %d\n", ret);
1468 ok(!strcmp(buffer, "1010101010101010"),
1469 "Expected output buffer string to be \"1010101010101010\", got \"%s\"\n",
1472 ret = p_itoa_s(1092009, buffer, sizeof(buffer), 36);
1473 ok(ret == 0, "Expected _itoa_s to return 0, got %d\n", ret);
1474 ok(!strcmp(buffer, "nell"),
1475 "Expected output buffer string to be \"nell\", got \"%s\"\n",
1478 ret = p_itoa_s(5704, buffer, sizeof(buffer), 18);
1479 ok(ret == 0, "Expected _itoa_s to return 0, got %d\n", ret);
1480 ok(!strcmp(buffer, "hag"),
1481 "Expected output buffer string to be \"hag\", got \"%s\"\n",
1484 ret = p_itoa_s(-12345678, buffer, sizeof(buffer), 10);
1485 ok(ret == 0, "Expected _itoa_s to return 0, got %d\n", ret);
1486 ok(!strcmp(buffer, "-12345678"),
1487 "Expected output buffer string to be \"-12345678\", got \"%s\"\n",
1489 if (p_set_invalid_parameter_handler)
1490 ok(p_set_invalid_parameter_handler(NULL) == test_invalid_parameter_handler,
1491 "Cannot reset invalid parameter handler\n");
1494 static void test__strlwr_s(void)
1501 win_skip("Skipping _strlwr_s tests\n");
1506 ret = p_strlwr_s(NULL, 0);
1507 ok(ret == EINVAL, "Expected _strlwr_s to return EINVAL, got %d\n", ret);
1508 ok(errno == EINVAL, "Expected errno to be EINVAL, got %d\n", errno);
1511 ret = p_strlwr_s(NULL, sizeof(buffer));
1512 ok(ret == EINVAL, "Expected _strlwr_s to return EINVAL, got %d\n", ret);
1513 ok(errno == EINVAL, "Expected errno to be EINVAL, got %d\n", errno);
1516 ret = p_strlwr_s(buffer, 0);
1517 ok(ret == EINVAL, "Expected _strlwr_s to return EINVAL, got %d\n", ret);
1518 ok(errno == EINVAL, "Expected errno to be EINVAL, got %d\n", errno);
1520 strcpy(buffer, "GoRrIsTeR");
1522 ret = p_strlwr_s(buffer, 5);
1523 ok(ret == EINVAL, "Expected _strlwr_s to return EINVAL, got %d\n", ret);
1524 ok(errno == EINVAL, "Expected errno to be EINVAL, got %d\n", errno);
1525 ok(!memcmp(buffer, "\0oRrIsTeR", sizeof("\0oRrIsTeR")),
1526 "Expected the output buffer to be \"gorrIsTeR\"\n");
1528 strcpy(buffer, "GoRrIsTeR");
1530 ret = p_strlwr_s(buffer, sizeof("GoRrIsTeR") - 1);
1531 ok(ret == EINVAL, "Expected _strlwr_s to return EINVAL, got %d\n", ret);
1532 ok(errno == EINVAL, "Expected errno to be EINVAL, got %d\n", errno);
1533 ok(!memcmp(buffer, "\0oRrIsTeR", sizeof("\0oRrIsTeR")),
1534 "Expected the output buffer to be \"gorrIsTeR\"\n");
1536 strcpy(buffer, "GoRrIsTeR");
1537 ret = p_strlwr_s(buffer, sizeof("GoRrIsTeR"));
1538 ok(ret == 0, "Expected _strlwr_s to return 0, got %d\n", ret);
1539 ok(!strcmp(buffer, "gorrister"),
1540 "Expected the output buffer to be \"gorrister\", got \"%s\"\n",
1543 memcpy(buffer, "GoRrIsTeR\0ELLEN", sizeof("GoRrIsTeR\0ELLEN"));
1544 ret = p_strlwr_s(buffer, sizeof(buffer));
1545 ok(ret == 0, "Expected _strlwr_s to return 0, got %d\n", ret);
1546 ok(!memcmp(buffer, "gorrister\0ELLEN", sizeof("gorrister\0ELLEN")),
1547 "Expected the output buffer to be \"gorrister\\0ELLEN\", got \"%s\"\n",
1551 static void test_wcsncat_s(void)
1553 static wchar_t abcW[] = {'a','b','c',0};
1560 win_skip("skipping wcsncat_s tests\n");
1564 if (p_set_invalid_parameter_handler)
1565 ok(p_set_invalid_parameter_handler(test_invalid_parameter_handler) == NULL,
1566 "Invalid parameter handler was already set\n");
1568 memcpy(src, abcW, sizeof(abcW));
1570 ret = p_wcsncat_s(NULL, 4, src, 4);
1571 ok(ret == EINVAL, "err = %d\n", ret);
1572 ret = p_wcsncat_s(dst, 0, src, 4);
1573 ok(ret == EINVAL, "err = %d\n", ret);
1574 ret = p_wcsncat_s(dst, 0, src, _TRUNCATE);
1575 ok(ret == EINVAL, "err = %d\n", ret);
1576 ret = p_wcsncat_s(dst, 4, NULL, 0);
1577 ok(ret == 0, "err = %d\n", ret);
1580 ret = p_wcsncat_s(dst, 2, src, 4);
1581 ok(ret == ERANGE, "err = %d\n", ret);
1584 ret = p_wcsncat_s(dst, 2, src, _TRUNCATE);
1585 ok(ret == STRUNCATE, "err = %d\n", ret);
1586 ok(dst[0] == 'a' && dst[1] == 0, "dst is %s\n", wine_dbgstr_w(dst));
1588 memcpy(dst, abcW, sizeof(abcW));
1590 ret = p_wcsncat_s(dst, 4, src, 4);
1591 ok(ret == EINVAL, "err = %d\n", ret);
1593 if (p_set_invalid_parameter_handler)
1594 ok(p_set_invalid_parameter_handler(NULL) == test_invalid_parameter_handler,
1595 "Cannot reset invalid parameter handler\n");
1598 static void test__mbsnbcat_s(void)
1600 unsigned char dest[16];
1601 const unsigned char first[] = "dinosaur";
1602 const unsigned char second[] = "duck";
1607 win_skip("Skipping _mbsnbcat_s tests\n");
1611 /* Test invalid arguments. */
1612 ret = p_mbsnbcat_s(NULL, 0, NULL, 0);
1613 ok(ret == 0, "Expected _mbsnbcat_s to return 0, got %d\n", ret);
1616 ret = p_mbsnbcat_s(NULL, 10, NULL, 0);
1617 ok(ret == EINVAL, "Expected _mbsnbcat_s to return EINVAL, got %d\n", ret);
1618 ok(errno == EINVAL, "Expected errno to be EINVAL, got %d\n", errno);
1621 ret = p_mbsnbcat_s(NULL, 0, NULL, 10);
1622 ok(ret == EINVAL, "Expected _mbsnbcat_s to return EINVAL, got %d\n", ret);
1623 ok(errno == EINVAL, "Expected errno to be EINVAL, got %d\n", errno);
1625 memset(dest, 'X', sizeof(dest));
1627 ret = p_mbsnbcat_s(dest, 0, NULL, 0);
1628 ok(ret == EINVAL, "Expected _mbsnbcat_s to return EINVAL, got %d\n", ret);
1629 ok(errno == EINVAL, "Expected errno to be EINVAL, got %d\n", errno);
1630 ok(dest[0] == 'X', "Expected the output buffer to be untouched\n");
1632 memset(dest, 'X', sizeof(dest));
1634 ret = p_mbsnbcat_s(dest, 0, second, 0);
1635 ok(ret == EINVAL, "Expected _mbsnbcat_s to return EINVAL, got %d\n", ret);
1636 ok(errno == EINVAL, "Expected errno to be EINVAL, got %d\n", errno);
1637 ok(dest[0] == 'X', "Expected the output buffer to be untouched\n");
1639 memset(dest, 'X', sizeof(dest));
1641 ret = p_mbsnbcat_s(dest, sizeof(dest), NULL, 0);
1642 ok(ret == EINVAL, "Expected _mbsnbcat_s to return EINVAL, got %d\n", ret);
1643 ok(errno == EINVAL, "Expected errno to be EINVAL, got %d\n", errno);
1644 ok(dest[0] == '\0', "Expected the output buffer to be null terminated\n");
1646 memset(dest, 'X', sizeof(dest));
1648 ret = p_mbsnbcat_s(dest, sizeof(dest), NULL, 10);
1649 ok(ret == EINVAL, "Expected _mbsnbcat_s to return EINVAL, got %d\n", ret);
1650 ok(errno == EINVAL, "Expected errno to be EINVAL, got %d\n", errno);
1651 ok(dest[0] == '\0', "Expected the output buffer to be null terminated\n");
1653 memset(dest, 'X', sizeof(dest));
1655 ret = p_mbsnbcat_s(dest, sizeof(dest), second, sizeof(second));
1656 ok(ret == 0, "Expected _mbsnbcat_s to return 0, got %d\n", ret);
1657 ok(!memcmp(dest, second, sizeof(second)),
1658 "Expected the output buffer string to be \"duck\"\n");
1660 /* Test source truncation behavior. */
1661 memset(dest, 'X', sizeof(dest));
1662 memcpy(dest, first, sizeof(first));
1663 ret = p_mbsnbcat_s(dest, sizeof(dest), second, 0);
1664 ok(ret == 0, "Expected _mbsnbcat_s to return 0, got %d\n", ret);
1665 ok(!memcmp(dest, first, sizeof(first)),
1666 "Expected the output buffer string to be \"dinosaur\"\n");
1668 memset(dest, 'X', sizeof(dest));
1669 memcpy(dest, first, sizeof(first));
1670 ret = p_mbsnbcat_s(dest, sizeof(dest), second, sizeof(second));
1671 ok(ret == 0, "Expected _mbsnbcat_s to return 0, got %d\n", ret);
1672 ok(!memcmp(dest, "dinosaurduck", sizeof("dinosaurduck")),
1673 "Expected the output buffer string to be \"dinosaurduck\"\n");
1675 memset(dest, 'X', sizeof(dest));
1676 memcpy(dest, first, sizeof(first));
1677 ret = p_mbsnbcat_s(dest, sizeof(dest), second, sizeof(second) + 1);
1678 ok(ret == 0, "Expected _mbsnbcat_s to return 0, got %d\n", ret);
1679 ok(!memcmp(dest, "dinosaurduck", sizeof("dinosaurduck")),
1680 "Expected the output buffer string to be \"dinosaurduck\"\n");
1682 memset(dest, 'X', sizeof(dest));
1683 memcpy(dest, first, sizeof(first));
1684 ret = p_mbsnbcat_s(dest, sizeof(dest), second, sizeof(second) - 1);
1685 ok(ret == 0, "Expected _mbsnbcat_s to return 0, got %d\n", ret);
1686 ok(!memcmp(dest, "dinosaurduck", sizeof("dinosaurduck")),
1687 "Expected the output buffer string to be \"dinosaurduck\"\n");
1689 memset(dest, 'X', sizeof(dest));
1690 memcpy(dest, first, sizeof(first));
1691 ret = p_mbsnbcat_s(dest, sizeof(dest), second, sizeof(second) - 2);
1692 ok(ret == 0, "Expected _mbsnbcat_s to return 0, got %d\n", ret);
1693 ok(!memcmp(dest, "dinosaurduc", sizeof("dinosaurduc")),
1694 "Expected the output buffer string to be \"dinosaurduc\"\n");
1696 /* Test destination truncation behavior. */
1697 memset(dest, 'X', sizeof(dest));
1698 memcpy(dest, first, sizeof(first));
1700 ret = p_mbsnbcat_s(dest, sizeof(first) - 1, second, sizeof(second));
1701 ok(ret == EINVAL, "Expected _mbsnbcat_s to return EINVAL, got %d\n", ret);
1702 ok(errno == EINVAL, "Expected errno to be EINVAL, got %d\n", errno);
1703 ok(!memcmp(dest, "\0inosaur", sizeof("\0inosaur") - 1),
1704 "Expected the output buffer string to be \"\\0inosaur\" without ending null terminator\n");
1706 memset(dest, 'X', sizeof(dest));
1707 memcpy(dest, first, sizeof(first));
1709 ret = p_mbsnbcat_s(dest, sizeof(first), second, sizeof(second));
1710 ok(ret == ERANGE, "Expected _mbsnbcat_s to return ERANGE, got %d\n", ret);
1711 ok(errno == ERANGE, "Expected errno to be ERANGE, got %d\n", errno);
1712 ok(!memcmp(dest, "\0inosaurd", sizeof("\0inosaurd") - 1),
1713 "Expected the output buffer string to be \"\\0inosaurd\" without ending null terminator\n");
1715 memset(dest, 'X', sizeof(dest));
1716 memcpy(dest, first, sizeof(first));
1718 ret = p_mbsnbcat_s(dest, sizeof(first) + 1, second, sizeof(second));
1719 ok(ret == ERANGE, "Expected _mbsnbcat_s to return ERANGE, got %d\n", ret);
1720 ok(errno == ERANGE, "Expected errno to be ERANGE, got %d\n", errno);
1721 ok(!memcmp(dest, "\0inosaurdu", sizeof("\0inosaurdu") - 1),
1722 "Expected the output buffer string to be \"\\0inosaurdu\" without ending null terminator\n");
1725 static void test__mbsupr_s(void)
1728 unsigned char buffer[20];
1732 win_skip("Skipping _mbsupr_s tests\n");
1737 ret = p_mbsupr_s(NULL, 0);
1738 ok(ret == 0, "Expected _mbsupr_s to return 0, got %d\n", ret);
1741 ret = p_mbsupr_s(NULL, sizeof(buffer));
1742 ok(ret == EINVAL, "Expected _mbsupr_s to return EINVAL, got %d\n", ret);
1743 ok(errno == EINVAL, "Expected errno to be EINVAL, got %d\n", errno);
1746 ret = p_mbsupr_s(buffer, 0);
1747 ok(ret == EINVAL, "Expected _mbsupr_s to return EINVAL, got %d\n", ret);
1748 ok(errno == EINVAL, "Expected errno to be EINVAL, got %d\n", errno);
1750 memcpy(buffer, "abcdefgh", sizeof("abcdefgh"));
1752 ret = p_mbsupr_s(buffer, sizeof("abcdefgh"));
1753 ok(ret == 0, "Expected _mbsupr_s to return 0, got %d\n", ret);
1754 ok(!memcmp(buffer, "ABCDEFGH", sizeof("ABCDEFGH")),
1755 "Expected the output buffer to be \"ABCDEFGH\", got \"%s\"\n",
1758 memcpy(buffer, "abcdefgh", sizeof("abcdefgh"));
1760 ret = p_mbsupr_s(buffer, sizeof(buffer));
1761 ok(ret == 0, "Expected _mbsupr_s to return 0, got %d\n", ret);
1762 ok(!memcmp(buffer, "ABCDEFGH", sizeof("ABCDEFGH")),
1763 "Expected the output buffer to be \"ABCDEFGH\", got \"%s\"\n",
1766 memcpy(buffer, "abcdefgh", sizeof("abcdefgh"));
1768 ret = p_mbsupr_s(buffer, 4);
1769 ok(ret == EINVAL, "Expected _mbsupr_s to return EINVAL, got %d\n", ret);
1770 ok(errno == EINVAL, "Expected errno to be EINVAL, got %d\n", errno);
1772 memcpy(buffer, "abcdefgh\0ijklmnop", sizeof("abcdefgh\0ijklmnop"));
1774 ret = p_mbsupr_s(buffer, sizeof(buffer));
1775 ok(ret == 0, "Expected _mbsupr_s to return 0, got %d\n", ret);
1776 ok(!memcmp(buffer, "ABCDEFGH\0ijklmnop", sizeof("ABCDEFGH\0ijklmnop")),
1777 "Expected the output buffer to be \"ABCDEFGH\\0ijklmnop\", got \"%s\"\n",
1782 static void test__mbslwr_s(void)
1785 unsigned char buffer[20];
1789 win_skip("Skipping _mbslwr_s tests\n");
1794 ret = p_mbslwr_s(NULL, 0);
1795 ok(ret == 0, "Expected _mbslwr_s to return 0, got %d\n", ret);
1798 ret = p_mbslwr_s(NULL, sizeof(buffer));
1799 ok(ret == EINVAL, "Expected _mbslwr_s to return EINVAL, got %d\n", ret);
1800 ok(errno == EINVAL, "Expected errno to be EINVAL, got %d\n", errno);
1803 ret = p_mbslwr_s(buffer, 0);
1804 ok(ret == EINVAL, "Expected _mbslwr_s to return EINVAL, got %d\n", ret);
1805 ok(errno == EINVAL, "Expected errno to be EINVAL, got %d\n", errno);
1807 memcpy(buffer, "ABCDEFGH", sizeof("ABCDEFGH"));
1809 ret = p_mbslwr_s(buffer, sizeof("ABCDEFGH"));
1810 ok(ret == 0, "Expected _mbslwr_s to return 0, got %d\n", ret);
1811 ok(!memcmp(buffer, "abcdefgh", sizeof("abcdefgh")),
1812 "Expected the output buffer to be \"abcdefgh\", got \"%s\"\n",
1815 memcpy(buffer, "ABCDEFGH", sizeof("ABCDEFGH"));
1817 ret = p_mbslwr_s(buffer, sizeof(buffer));
1818 ok(ret == 0, "Expected _mbslwr_s to return 0, got %d\n", ret);
1819 ok(!memcmp(buffer, "abcdefgh", sizeof("abcdefgh")),
1820 "Expected the output buffer to be \"abcdefgh\", got \"%s\"\n",
1823 memcpy(buffer, "ABCDEFGH", sizeof("ABCDEFGH"));
1825 ret = p_mbslwr_s(buffer, 4);
1826 ok(ret == EINVAL, "Expected _mbslwr_s to return EINVAL, got %d\n", ret);
1827 ok(errno == EINVAL, "Expected errno to be EINVAL, got %d\n", errno);
1829 memcpy(buffer, "ABCDEFGH\0IJKLMNOP", sizeof("ABCDEFGH\0IJKLMNOP"));
1831 ret = p_mbslwr_s(buffer, sizeof(buffer));
1832 ok(ret == 0, "Expected _mbslwr_s to return 0, got %d\n", ret);
1833 ok(!memcmp(buffer, "abcdefgh\0IJKLMNOP", sizeof("abcdefgh\0IJKLMNOP")),
1834 "Expected the output buffer to be \"abcdefgh\\0IJKLMNOP\", got \"%s\"\n",
1839 static void test__ultoa_s(void)
1846 win_skip("Skipping _ultoa_s tests\n");
1851 ret = p_ultoa_s(0, NULL, 0, 0);
1852 ok(ret == EINVAL, "Expected _ultoa_s to return EINVAL, got %d\n", ret);
1853 ok(errno == EINVAL, "Expected errno to be EINVAL, got %d\n", errno);
1855 memset(buffer, 'X', sizeof(buffer));
1857 ret = p_ultoa_s(0, buffer, 0, 0);
1858 ok(ret == EINVAL, "Expected _ultoa_s to return EINVAL, got %d\n", ret);
1859 ok(errno == EINVAL, "Expected errno to be EINVAL, got %d\n", errno);
1860 ok(buffer[0] == 'X', "Expected the output buffer to be untouched\n");
1862 memset(buffer, 'X', sizeof(buffer));
1864 ret = p_ultoa_s(0, buffer, sizeof(buffer), 0);
1865 ok(ret == EINVAL, "Expected _ultoa_s to return EINVAL, got %d\n", ret);
1866 ok(errno == EINVAL, "Expected errno to be EINVAL, got %d\n", errno);
1867 ok(buffer[0] == '\0', "Expected the output buffer to be null terminated\n");
1869 memset(buffer, 'X', sizeof(buffer));
1871 ret = p_ultoa_s(0, buffer, sizeof(buffer), 64);
1872 ok(ret == EINVAL, "Expected _ultoa_s to return EINVAL, got %d\n", ret);
1873 ok(errno == EINVAL, "Expected errno to be EINVAL, got %d\n", errno);
1874 ok(buffer[0] == '\0', "Expected the output buffer to be null terminated\n");
1876 memset(buffer, 'X', sizeof(buffer));
1878 ret = p_ultoa_s(12345678, buffer, 4, 10);
1879 ok(ret == ERANGE, "Expected _ultoa_s to return ERANGE, got %d\n", ret);
1880 ok(errno == ERANGE, "Expected errno to be ERANGE, got %d\n", errno);
1881 ok(!memcmp(buffer, "\000765", 4),
1882 "Expected the output buffer to be null terminated with truncated output\n");
1884 memset(buffer, 'X', sizeof(buffer));
1886 ret = p_ultoa_s(12345678, buffer, 8, 10);
1887 ok(ret == ERANGE, "Expected _ultoa_s to return ERANGE, got %d\n", ret);
1888 ok(errno == ERANGE, "Expected errno to be ERANGE, got %d\n", errno);
1889 ok(!memcmp(buffer, "\0007654321", 8),
1890 "Expected the output buffer to be null terminated with truncated output\n");
1892 ret = p_ultoa_s(12345678, buffer, 9, 10);
1893 ok(ret == 0, "Expected _ultoa_s to return 0, got %d\n", ret);
1894 ok(!strcmp(buffer, "12345678"),
1895 "Expected output buffer string to be \"12345678\", got \"%s\"\n",
1898 ret = p_ultoa_s(43690, buffer, sizeof(buffer), 2);
1899 ok(ret == 0, "Expected _ultoa_s to return 0, got %d\n", ret);
1900 ok(!strcmp(buffer, "1010101010101010"),
1901 "Expected output buffer string to be \"1010101010101010\", got \"%s\"\n",
1904 ret = p_ultoa_s(1092009, buffer, sizeof(buffer), 36);
1905 ok(ret == 0, "Expected _ultoa_s to return 0, got %d\n", ret);
1906 ok(!strcmp(buffer, "nell"),
1907 "Expected output buffer string to be \"nell\", got \"%s\"\n",
1910 ret = p_ultoa_s(5704, buffer, sizeof(buffer), 18);
1911 ok(ret == 0, "Expected _ultoa_s to return 0, got %d\n", ret);
1912 ok(!strcmp(buffer, "hag"),
1913 "Expected output buffer string to be \"hag\", got \"%s\"\n",
1917 static void test_wctob(void)
1921 if(!p_wctob || !setlocale(LC_ALL, "chinese-traditional")) {
1922 win_skip("Skipping wctob tests\n");
1926 ret = p_wctob(0x8141);
1927 ok(ret == EOF, "ret = %x\n", ret);
1929 ret = p_wctob(0x81);
1930 ok(ret == EOF, "ret = %x\n", ret);
1932 ret = p_wctob(0xe0);
1933 ok(ret == 0x61, "ret = %x\n", ret);
1936 ret = p_wctob(0x81);
1937 /* wctob should not be affected by _setmbcp */
1938 todo_wine ok(ret == EOF, "ret = %x\n", ret);
1940 setlocale(LC_ALL, "C");
1941 ret = p_wctob(0x8141);
1942 ok(ret == EOF, "ret = %x\n", ret);
1944 ret = p_wctob(0x81);
1945 ok(ret == (int)(char)0x81, "ret = %x\n", ret);
1947 ret = p_wctob(0xe0);
1948 ok(ret == (int)(char)0xe0, "ret = %x\n", ret);
1954 static const char xilstring[]="c:/xilinx";
1957 hMsvcrt = GetModuleHandleA("msvcrt.dll");
1959 hMsvcrt = GetModuleHandleA("msvcrtd.dll");
1960 ok(hMsvcrt != 0, "GetModuleHandleA failed\n");
1961 SET(pmemcpy,"memcpy");
1962 SET(pmemcmp,"memcmp");
1963 SET(p_mbctype,"_mbctype");
1964 SET(p__mb_cur_max,"__mb_cur_max");
1965 pstrcpy_s = (void *)GetProcAddress( hMsvcrt,"strcpy_s" );
1966 pstrcat_s = (void *)GetProcAddress( hMsvcrt,"strcat_s" );
1967 p_mbsnbcat_s = (void *)GetProcAddress( hMsvcrt,"_mbsnbcat_s" );
1968 p_mbsnbcpy_s = (void *)GetProcAddress( hMsvcrt,"_mbsnbcpy_s" );
1969 p_wcscpy_s = (void *)GetProcAddress( hMsvcrt,"wcscpy_s" );
1970 p_wcsncat_s = (void *)GetProcAddress( hMsvcrt,"wcsncat_s" );
1971 p_wcsupr_s = (void *)GetProcAddress( hMsvcrt,"_wcsupr_s" );
1972 p_strnlen = (void *)GetProcAddress( hMsvcrt,"strnlen" );
1973 p_strtoi64 = (void *)GetProcAddress(hMsvcrt, "_strtoi64");
1974 p_strtoui64 = (void *)GetProcAddress(hMsvcrt, "_strtoui64");
1975 pmbstowcs_s = (void *)GetProcAddress(hMsvcrt, "mbstowcs_s");
1976 pwcstombs_s = (void *)GetProcAddress(hMsvcrt, "wcstombs_s");
1977 p_gcvt_s = (void *)GetProcAddress(hMsvcrt, "_gcvt_s");
1978 p_itoa_s = (void *)GetProcAddress(hMsvcrt, "_itoa_s");
1979 p_strlwr_s = (void *)GetProcAddress(hMsvcrt, "_strlwr_s");
1980 p_ultoa_s = (void *)GetProcAddress(hMsvcrt, "_ultoa_s");
1981 p_set_invalid_parameter_handler = (void *) GetProcAddress(hMsvcrt, "_set_invalid_parameter_handler");
1982 p_wcslwr_s = (void*)GetProcAddress(hMsvcrt, "_wcslwr_s");
1983 p_mbsupr_s = (void*)GetProcAddress(hMsvcrt, "_mbsupr_s");
1984 p_mbslwr_s = (void*)GetProcAddress(hMsvcrt, "_mbslwr_s");
1985 p_wctob = (void*)GetProcAddress(hMsvcrt, "wctob");
1987 /* MSVCRT memcpy behaves like memmove for overlapping moves,
1988 MFC42 CString::Insert seems to rely on that behaviour */
1989 strcpy(mem,xilstring);
1990 nLen=strlen(xilstring);
1991 pmemcpy(mem+5, mem,nLen+1);
1992 ok(pmemcmp(mem+5,xilstring, nLen) == 0,
1993 "Got result %s\n",mem+5);
1995 /* Test _swab function */
2029 /* This test is changing locale */