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 /* make it use a definition from string.h */
38 static char *buf_to_string(const unsigned char *bin
, int len
, int nr
)
40 static char buf
[2][1024];
44 for (i
= 0; i
< len
; i
++)
46 sprintf(w
, "%02x ", (unsigned char)bin
[i
]);
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)); }
55 static void* (__cdecl
*pmemcpy
)(void *, const void *, size_t n
);
56 static int (__cdecl
*p_memcpy_s
)(void *, size_t, const void *, size_t);
57 static int (__cdecl
*p_memmove_s
)(void *, size_t, const void *, size_t);
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__mbscpy_s
)(unsigned char*, size_t, const unsigned char*);
64 static int (__cdecl
*p_wcscpy_s
)(wchar_t *wcDest
, size_t size
, const wchar_t *wcSrc
);
65 static int (__cdecl
*p_wcsncpy_s
)(wchar_t *wcDest
, size_t size
, const wchar_t *wcSrc
, size_t count
);
66 static int (__cdecl
*p_wcsncat_s
)(wchar_t *dst
, size_t elem
, const wchar_t *src
, size_t count
);
67 static int (__cdecl
*p_wcsupr_s
)(wchar_t *str
, size_t size
);
68 static size_t (__cdecl
*p_strnlen
)(const char *, size_t);
69 static __int64 (__cdecl
*p_strtoi64
)(const char *, char **, int);
70 static unsigned __int64 (__cdecl
*p_strtoui64
)(const char *, char **, int);
71 static __int64 (__cdecl
*p_wcstoi64
)(const wchar_t *, wchar_t **, int);
72 static unsigned __int64 (__cdecl
*p_wcstoui64
)(const wchar_t *, wchar_t **, int);
73 static int (__cdecl
*pwcstombs_s
)(size_t*,char*,size_t,const wchar_t*,size_t);
74 static int (__cdecl
*pmbstowcs_s
)(size_t*,wchar_t*,size_t,const char*,size_t);
75 static size_t (__cdecl
*p_mbsrtowcs
)(wchar_t*, const char**, size_t, mbstate_t*);
76 static size_t (__cdecl
*pwcsrtombs
)(char*, const wchar_t**, size_t, int*);
77 static errno_t (__cdecl
*p_gcvt_s
)(char*,size_t,double,int);
78 static errno_t (__cdecl
*p_itoa_s
)(int,char*,size_t,int);
79 static errno_t (__cdecl
*p_strlwr_s
)(char*,size_t);
80 static errno_t (__cdecl
*p_ultoa_s
)(__msvcrt_ulong
,char*,size_t,int);
81 static int *p__mb_cur_max
;
82 static unsigned char *p_mbctype
;
83 static int (__cdecl
*p_wcslwr_s
)(wchar_t*,size_t);
84 static errno_t (__cdecl
*p_mbsupr_s
)(unsigned char *str
, size_t numberOfElements
);
85 static errno_t (__cdecl
*p_mbslwr_s
)(unsigned char *str
, size_t numberOfElements
);
86 static int (__cdecl
*p_wctob
)(wint_t);
87 static size_t (__cdecl
*p_wcrtomb
)(char*, wchar_t, mbstate_t*);
88 static int (__cdecl
*p_tolower
)(int);
89 static size_t (__cdecl
*p_mbrlen
)(const char*, size_t, mbstate_t*);
90 static size_t (__cdecl
*p_mbrtowc
)(wchar_t*, const char*, size_t, mbstate_t*);
91 static int (__cdecl
*p__atodbl_l
)(_CRT_DOUBLE
*,char*,_locale_t
);
92 static int (__cdecl
*p__strnset_s
)(char*,size_t,int,size_t);
94 #define SETNOFAIL(x,y) x = (void*)GetProcAddress(hMsvcrt,y)
95 #define SET(x,y) SETNOFAIL(x,y); ok(x != NULL, "Export '%s' not found\n", y)
97 static HMODULE hMsvcrt
;
99 static void test_swab( void ) {
100 char original
[] = "BADCFEHGJILKNMPORQTSVUXWZY@#";
101 char expected1
[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ@#";
102 char expected2
[] = "ABCDEFGHIJKLMNOPQRSTUVWX$";
103 char expected3
[] = "$";
110 /* Test 1 - normal even case */
111 memset(to
,'$', sizeof(to
));
112 memset(from
,'@', sizeof(from
));
114 memcpy(from
, original
, testsize
);
115 _swab( from
, to
, testsize
);
116 ok(memcmp(to
,expected1
,testsize
) == 0, "Testing even size %d returned '%*.*s'\n", testsize
, testsize
, testsize
, to
);
118 /* Test 2 - uneven case */
119 memset(to
,'$', sizeof(to
));
120 memset(from
,'@', sizeof(from
));
122 memcpy(from
, original
, testsize
);
123 _swab( from
, to
, testsize
);
124 ok(memcmp(to
,expected2
,testsize
) == 0, "Testing odd size %d returned '%*.*s'\n", testsize
, testsize
, testsize
, to
);
126 /* Test 3 - from = to */
127 memset(to
,'$', sizeof(to
));
128 memset(from
,'@', sizeof(from
));
130 memcpy(to
, original
, testsize
);
131 _swab( to
, to
, testsize
);
132 ok(memcmp(to
,expected1
,testsize
) == 0, "Testing overlapped size %d returned '%*.*s'\n", testsize
, testsize
, testsize
, to
);
134 /* Test 4 - 1 bytes */
135 memset(to
,'$', sizeof(to
));
136 memset(from
,'@', sizeof(from
));
138 memcpy(from
, original
, testsize
);
139 _swab( from
, to
, testsize
);
140 ok(memcmp(to
,expected3
,testsize
) == 0, "Testing small size %d returned '%*.*s'\n", testsize
, testsize
, testsize
, to
);
143 #if 0 /* use this to generate more tests */
145 static void test_codepage(int cp
)
151 ok(_setmbcp(cp
) == 0, "Couldn't set mbcp\n");
154 printf("static int result_cp_%d_mbctype[] = { ", cp
);
155 for (i
= 1; i
< 257; i
++)
157 if (p_mbctype
[i
] != prev
)
159 printf("0x%x,%d, ", prev
, count
);
166 printf("0x%x,%d };\n", prev
, count
);
171 /* RLE-encoded mbctype tables for given codepages */
172 static int result_cp_932_mbctype
[] = { 0x0,65, 0x8,1, 0x18,26, 0x8,6, 0x28,26, 0x8,4,
173 0x0,1, 0x8,1, 0xc,31, 0x8,1, 0xa,5, 0x9,58, 0xc,29, 0,3 };
174 static int result_cp_936_mbctype
[] = { 0x0,65, 0x8,1, 0x18,26, 0x8,6, 0x28,26, 0x8,6,
176 static int result_cp_949_mbctype
[] = { 0x0,66, 0x18,26, 0x8,6, 0x28,26, 0x8,6, 0xc,126,
178 static int result_cp_950_mbctype
[] = { 0x0,65, 0x8,1, 0x18,26, 0x8,6, 0x28,26, 0x8,4,
179 0x0,2, 0x4,32, 0xc,94, 0,1 };
181 static void test_cp_table(int cp
, int *result
)
187 for (i
= 0; i
< 256; i
++)
195 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
);
200 #define test_codepage(num) test_cp_table(num, result_cp_##num##_mbctype);
204 static void test_mbcp(void)
206 int mb_orig_max
= *p__mb_cur_max
;
207 int curr_mbcp
= _getmbcp();
208 unsigned char *mbstring
= (unsigned char *)"\xb0\xb1\xb2 \xb3\xb4 \xb5"; /* incorrect string */
209 unsigned char *mbstring2
= (unsigned char *)"\xb0\xb1\xb2\xb3Q\xb4\xb5"; /* correct string */
210 unsigned char *mbsonlylead
= (unsigned char *)"\xb0\0\xb1\xb2 \xb3";
211 unsigned char buf
[16];
217 /* An SBCS codepage test. The ctype of characters on e.g. CP1252 or CP1250 differs slightly
218 * between versions of Windows. Also Windows 9x seems to ignore the codepage and always uses
219 * CP1252 (or the ACP?) so we test only a few ASCII characters */
221 expect_eq(p_mbctype
[10], 0, char, "%x");
222 expect_eq(p_mbctype
[50], 0, char, "%x");
223 expect_eq(p_mbctype
[66], _SBUP
, char, "%x");
224 expect_eq(p_mbctype
[100], _SBLOW
, char, "%x");
225 expect_eq(p_mbctype
[128], 0, char, "%x");
227 expect_eq(p_mbctype
[10], 0, char, "%x");
228 expect_eq(p_mbctype
[50], 0, char, "%x");
229 expect_eq(p_mbctype
[66], _SBUP
, char, "%x");
230 expect_eq(p_mbctype
[100], _SBLOW
, char, "%x");
231 expect_eq(p_mbctype
[128], 0, char, "%x");
233 /* double byte code pages */
240 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
);
241 ok(_ismbblead('\354'), "\354 should be a lead byte\n");
242 ok(_ismbblead(' ') == FALSE
, "' ' should not be a lead byte\n");
243 ok(_ismbblead(0x1234b0), "0x1234b0 should not be a lead byte\n");
244 ok(_ismbblead(0x123420) == FALSE
, "0x123420 should not be a lead byte\n");
245 ok(_ismbbtrail('\xb0'), "\xa0 should be a trail byte\n");
246 ok(_ismbbtrail(' ') == FALSE
, "' ' should not be a trail byte\n");
249 expect_eq(_ismbslead(mbstring
, &mbstring
[0]), -1, int, "%d");
250 expect_eq(_ismbslead(mbstring
, &mbstring
[1]), FALSE
, int, "%d");
251 expect_eq(_ismbslead(mbstring
, &mbstring
[2]), -1, int, "%d");
252 expect_eq(_ismbslead(mbstring
, &mbstring
[3]), FALSE
, int, "%d");
253 expect_eq(_ismbslead(mbstring
, &mbstring
[4]), -1, int, "%d");
254 expect_eq(_ismbslead(mbstring
, &mbstring
[5]), FALSE
, int, "%d");
255 expect_eq(_ismbslead(mbstring
, &mbstring
[6]), FALSE
, int, "%d");
256 expect_eq(_ismbslead(mbstring
, &mbstring
[7]), -1, int, "%d");
257 expect_eq(_ismbslead(mbstring
, &mbstring
[8]), FALSE
, int, "%d");
259 expect_eq(_ismbslead(mbsonlylead
, &mbsonlylead
[0]), -1, int, "%d");
260 expect_eq(_ismbslead(mbsonlylead
, &mbsonlylead
[1]), FALSE
, int, "%d");
261 expect_eq(_ismbslead(mbsonlylead
, &mbsonlylead
[2]), FALSE
, int, "%d");
262 expect_eq(_ismbslead(mbsonlylead
, &mbsonlylead
[5]), FALSE
, int, "%d");
265 expect_eq(_ismbstrail(mbstring
, &mbstring
[0]), FALSE
, int, "%d");
266 expect_eq(_ismbstrail(mbstring
, &mbstring
[1]), -1, int, "%d");
267 expect_eq(_ismbstrail(mbstring
, &mbstring
[2]), FALSE
, int, "%d");
268 expect_eq(_ismbstrail(mbstring
, &mbstring
[3]), -1, int, "%d");
269 expect_eq(_ismbstrail(mbstring
, &mbstring
[4]), FALSE
, int, "%d");
270 expect_eq(_ismbstrail(mbstring
, &mbstring
[5]), -1, int, "%d");
271 expect_eq(_ismbstrail(mbstring
, &mbstring
[6]), FALSE
, int, "%d");
272 expect_eq(_ismbstrail(mbstring
, &mbstring
[7]), FALSE
, int, "%d");
273 expect_eq(_ismbstrail(mbstring
, &mbstring
[8]), -1, int, "%d");
275 expect_eq(_ismbstrail(mbsonlylead
, &mbsonlylead
[0]), FALSE
, int, "%d");
276 expect_eq(_ismbstrail(mbsonlylead
, &mbsonlylead
[1]), -1, int, "%d");
277 expect_eq(_ismbstrail(mbsonlylead
, &mbsonlylead
[2]), FALSE
, int, "%d");
278 expect_eq(_ismbstrail(mbsonlylead
, &mbsonlylead
[3]), FALSE
, int, "%d");
279 expect_eq(_ismbstrail(mbsonlylead
, &mbsonlylead
[4]), FALSE
, int, "%d");
280 expect_eq(_ismbstrail(mbsonlylead
, &mbsonlylead
[5]), FALSE
, int, "%d");
283 expect_eq(_mbsbtype(mbstring
, 0), _MBC_LEAD
, int, "%d");
284 expect_eq(_mbsbtype(mbstring
, 1), _MBC_TRAIL
, int, "%d");
285 expect_eq(_mbsbtype(mbstring
, 2), _MBC_LEAD
, int, "%d");
286 expect_eq(_mbsbtype(mbstring
, 3), _MBC_ILLEGAL
, int, "%d");
287 expect_eq(_mbsbtype(mbstring
, 4), _MBC_LEAD
, int, "%d");
288 expect_eq(_mbsbtype(mbstring
, 5), _MBC_TRAIL
, int, "%d");
289 expect_eq(_mbsbtype(mbstring
, 6), _MBC_SINGLE
, int, "%d");
290 expect_eq(_mbsbtype(mbstring
, 7), _MBC_LEAD
, int, "%d");
291 expect_eq(_mbsbtype(mbstring
, 8), _MBC_ILLEGAL
, int, "%d");
293 expect_eq(_mbsbtype(mbsonlylead
, 0), _MBC_LEAD
, int, "%d");
294 expect_eq(_mbsbtype(mbsonlylead
, 1), _MBC_ILLEGAL
, int, "%d");
295 expect_eq(_mbsbtype(mbsonlylead
, 2), _MBC_ILLEGAL
, int, "%d");
296 expect_eq(_mbsbtype(mbsonlylead
, 3), _MBC_ILLEGAL
, int, "%d");
297 expect_eq(_mbsbtype(mbsonlylead
, 4), _MBC_ILLEGAL
, int, "%d");
298 expect_eq(_mbsbtype(mbsonlylead
, 5), _MBC_ILLEGAL
, int, "%d");
301 expect_eq(_mbsnextc(mbstring
), 0xb0b1, int, "%x");
302 expect_eq(_mbsnextc(&mbstring
[2]), 0xb220, int, "%x"); /* lead + invalid tail */
303 expect_eq(_mbsnextc(&mbstring
[3]), 0x20, int, "%x"); /* single char */
305 /* _mbclen/_mbslen */
306 expect_eq(_mbclen(mbstring
), 2, int, "%d");
307 expect_eq(_mbclen(&mbstring
[2]), 2, int, "%d");
308 expect_eq(_mbclen(&mbstring
[3]), 1, int, "%d");
309 expect_eq(_mbslen(mbstring2
), 4, int, "%d");
310 expect_eq(_mbslen(mbsonlylead
), 0, int, "%d"); /* lead + NUL not counted as character */
311 expect_eq(_mbslen(mbstring
), 4, int, "%d"); /* lead + invalid trail counted */
314 if(!setlocale(LC_ALL
, ".936") || !p_mbrlen
) {
315 win_skip("mbrlen tests\n");
318 expect_eq(p_mbrlen((const char*)mbstring
, 2, NULL
), 2, int, "%d");
319 expect_eq(p_mbrlen((const char*)&mbstring
[2], 2, NULL
), 2, int, "%d");
320 expect_eq(p_mbrlen((const char*)&mbstring
[3], 2, NULL
), 1, int, "%d");
321 expect_eq(p_mbrlen((const char*)mbstring
, 1, NULL
), -2, int, "%d");
322 expect_eq(p_mbrlen((const char*)mbstring
, 1, &state
), -2, int, "%d");
323 ok(state
== mbstring
[0], "incorrect state value (%x)\n", state
);
324 expect_eq(p_mbrlen((const char*)&mbstring
[1], 1, &state
), 2, int, "%d");
328 if(!setlocale(LC_ALL
, ".936") || !p_mbrtowc
) {
329 win_skip("mbrtowc tests\n");
333 expect_eq(p_mbrtowc(&dst
, (const char*)mbstring
, 2, NULL
), 2, int, "%d");
334 ok(dst
== 0x6c28, "dst = %x, expected 0x6c28\n", dst
);
335 expect_eq(p_mbrtowc(&dst
, (const char*)mbstring
+2, 2, NULL
), 2, int, "%d");
336 ok(dst
== 0x3f, "dst = %x, expected 0x3f\n", dst
);
337 expect_eq(p_mbrtowc(&dst
, (const char*)mbstring
+3, 2, NULL
), 1, int, "%d");
338 ok(dst
== 0x20, "dst = %x, expected 0x20\n", dst
);
339 expect_eq(p_mbrtowc(&dst
, (const char*)mbstring
, 1, NULL
), -2, int, "%d");
340 ok(dst
== 0, "dst = %x, expected 0\n", dst
);
341 expect_eq(p_mbrtowc(&dst
, (const char*)mbstring
, 1, &state
), -2, int, "%d");
342 ok(dst
== 0, "dst = %x, expected 0\n", dst
);
343 ok(state
== mbstring
[0], "incorrect state value (%x)\n", state
);
344 expect_eq(p_mbrtowc(&dst
, (const char*)mbstring
+1, 1, &state
), 2, int, "%d");
345 ok(dst
== 0x6c28, "dst = %x, expected 0x6c28\n", dst
);
346 ok(state
== 0, "incorrect state value (%x)\n", state
);
348 setlocale(LC_ALL
, "C");
350 /* _mbccpy/_mbsncpy */
351 memset(buf
, 0xff, sizeof(buf
));
352 _mbccpy(buf
, mbstring
);
353 expect_bin(buf
, "\xb0\xb1\xff", 3);
355 memset(buf
, 0xff, sizeof(buf
));
356 _mbsncpy(buf
, mbstring
, 1);
357 expect_bin(buf
, "\xb0\xb1\xff", 3);
358 memset(buf
, 0xff, sizeof(buf
));
359 _mbsncpy(buf
, mbstring
, 2);
360 expect_bin(buf
, "\xb0\xb1\xb2 \xff", 5);
361 memset(buf
, 0xff, sizeof(buf
));
362 _mbsncpy(buf
, mbstring
, 3);
363 expect_bin(buf
, "\xb0\xb1\xb2 \xb3\xb4\xff", 7);
364 memset(buf
, 0xff, sizeof(buf
));
365 _mbsncpy(buf
, mbstring
, 4);
366 expect_bin(buf
, "\xb0\xb1\xb2 \xb3\xb4 \xff", 8);
367 memset(buf
, 0xff, sizeof(buf
));
368 _mbsncpy(buf
, mbstring
, 5);
369 expect_bin(buf
, "\xb0\xb1\xb2 \xb3\xb4 \0\0\xff", 10);
370 memset(buf
, 0xff, sizeof(buf
));
371 _mbsncpy(buf
, mbsonlylead
, 6);
372 expect_bin(buf
, "\0\0\0\0\0\0\0\xff", 8);
374 memset(buf
, 0xff, sizeof(buf
));
375 _mbsnbcpy(buf
, mbstring2
, 2);
376 expect_bin(buf
, "\xb0\xb1\xff", 3);
377 _mbsnbcpy(buf
, mbstring2
, 3);
378 expect_bin(buf
, "\xb0\xb1\0\xff", 4);
379 _mbsnbcpy(buf
, mbstring2
, 4);
380 expect_bin(buf
, "\xb0\xb1\xb2\xb3\xff", 5);
381 memset(buf
, 0xff, sizeof(buf
));
382 _mbsnbcpy(buf
, mbsonlylead
, 5);
383 expect_bin(buf
, "\0\0\0\0\0\xff", 6);
386 step
= _mbsinc(mbstring
) - mbstring
;
387 ok(step
== 2, "_mbsinc adds %d (exp. 2)\n", step
);
388 step
= _mbsinc(&mbstring
[2]) - &mbstring
[2]; /* lead + invalid tail */
389 ok(step
== 2, "_mbsinc adds %d (exp. 2)\n", step
);
391 step
= _mbsninc(mbsonlylead
, 1) - mbsonlylead
;
392 ok(step
== 0, "_mbsninc adds %d (exp. 0)\n", step
);
393 step
= _mbsninc(mbsonlylead
, 2) - mbsonlylead
; /* lead + NUL byte + lead + char */
394 ok(step
== 0, "_mbsninc adds %d (exp. 0)\n", step
);
395 step
= _mbsninc(mbstring2
, 0) - mbstring2
;
396 ok(step
== 0, "_mbsninc adds %d (exp. 2)\n", step
);
397 step
= _mbsninc(mbstring2
, 1) - mbstring2
;
398 ok(step
== 2, "_mbsninc adds %d (exp. 2)\n", step
);
399 step
= _mbsninc(mbstring2
, 2) - mbstring2
;
400 ok(step
== 4, "_mbsninc adds %d (exp. 4)\n", step
);
401 step
= _mbsninc(mbstring2
, 3) - mbstring2
;
402 ok(step
== 5, "_mbsninc adds %d (exp. 5)\n", step
);
403 step
= _mbsninc(mbstring2
, 4) - mbstring2
;
404 ok(step
== 7, "_mbsninc adds %d (exp. 7)\n", step
);
405 step
= _mbsninc(mbstring2
, 5) - mbstring2
;
406 ok(step
== 7, "_mbsninc adds %d (exp. 7)\n", step
);
407 step
= _mbsninc(mbstring2
, 17) - mbstring2
;
408 ok(step
== 7, "_mbsninc adds %d (exp. 7)\n", step
);
410 /* functions that depend on locale codepage, not mbcp.
411 * we hope the current locale to be SBCS because setlocale(LC_ALL, ".1252") seems not to work yet
412 * (as of Wine 0.9.43)
414 GetCPInfo(GetACP(), &cp_info
);
415 if (cp_info
.MaxCharSize
== 1)
417 expect_eq(mblen((char *)mbstring
, 3), 1, int, "%x");
418 expect_eq(_mbstrlen((char *)mbstring2
), 7, int, "%d");
421 skip("Current locale has double-byte charset - could lead to false positives\n");
424 expect_eq(_ismbblead(0x80), 0, int, "%d");
426 expect_eq(_ismbblead(0x81), 1, int, "%d");
427 expect_eq(_ismbblead(0x83), 1, int, "%d");
429 expect_eq(_ismbblead(0x84), 1, int, "%d");
430 expect_eq(_ismbblead(0xd3), 1, int, "%d");
431 expect_eq(_ismbblead(0xd7), 0, int, "%d");
432 expect_eq(_ismbblead(0xd8), 1, int, "%d");
433 expect_eq(_ismbblead(0xd9), 1, int, "%d");
435 expect_eq(_ismbbtrail(0x30), 0, int, "%d");
436 expect_eq(_ismbbtrail(0x31), 1, int, "%d");
437 expect_eq(_ismbbtrail(0x7e), 1, int, "%d");
438 expect_eq(_ismbbtrail(0x7f), 0, int, "%d");
439 expect_eq(_ismbbtrail(0x80), 0, int, "%d");
440 expect_eq(_ismbbtrail(0x81), 1, int, "%d");
441 expect_eq(_ismbbtrail(0xfe), 1, int, "%d");
442 expect_eq(_ismbbtrail(0xff), 0, int, "%d");
447 static void test_mbsspn( void)
449 unsigned char str1
[]="cabernet";
450 unsigned char str2
[]="shiraz";
451 unsigned char set
[]="abc";
452 unsigned char empty
[]="";
454 ret
=_mbsspn( str1
, set
);
455 ok( ret
==3, "_mbsspn returns %d should be 3\n", ret
);
456 ret
=_mbsspn( str2
, set
);
457 ok( ret
==0, "_mbsspn returns %d should be 0\n", ret
);
458 ret
=_mbsspn( str1
, empty
);
459 ok( ret
==0, "_mbsspn returns %d should be 0\n", ret
);
462 static void test_mbsspnp( void)
464 unsigned char str1
[]="cabernet";
465 unsigned char str2
[]="shiraz";
466 unsigned char set
[]="abc";
467 unsigned char empty
[]="";
468 unsigned char full
[]="abcenrt";
470 ret
=_mbsspnp( str1
, set
);
471 ok( ret
[0]=='e', "_mbsspnp returns %c should be e\n", ret
[0]);
472 ret
=_mbsspnp( str2
, set
);
473 ok( ret
[0]=='s', "_mbsspnp returns %c should be s\n", ret
[0]);
474 ret
=_mbsspnp( str1
, empty
);
475 ok( ret
[0]=='c', "_mbsspnp returns %c should be c\n", ret
[0]);
476 ret
=_mbsspnp( str1
, full
);
477 ok( ret
==NULL
, "_mbsspnp returns %p should be NULL\n", ret
);
480 static void test_strdup(void)
484 ok( str
== 0, "strdup returns %s should be 0\n", str
);
488 static void test_strcpy_s(void)
491 const char *small
= "small";
492 const char *big
= "atoolongstringforthislittledestination";
497 win_skip("strcpy_s not found\n");
501 memset(dest
, 'X', sizeof(dest
));
502 ret
= pstrcpy_s(dest
, sizeof(dest
), small
);
503 ok(ret
== 0, "Copying a string into a big enough destination returned %d, expected 0\n", ret
);
504 ok(dest
[0] == 's' && dest
[1] == 'm' && dest
[2] == 'a' && dest
[3] == 'l' &&
505 dest
[4] == 'l' && dest
[5] == '\0'&& dest
[6] == 'X' && dest
[7] == 'X',
506 "Unexpected return data from strcpy_s: 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x\n",
507 dest
[0], dest
[1], dest
[2], dest
[3], dest
[4], dest
[5], dest
[6], dest
[7]);
509 memset(dest
, 'X', sizeof(dest
));
510 ret
= pstrcpy_s(dest
, 0, big
);
511 ok(ret
== EINVAL
, "Copying into a destination of size 0 returned %d, expected EINVAL\n", ret
);
512 ok(dest
[0] == 'X' && dest
[1] == 'X' && dest
[2] == 'X' && dest
[3] == 'X' &&
513 dest
[4] == 'X' && dest
[5] == 'X' && dest
[6] == 'X' && dest
[7] == 'X',
514 "Unexpected return data from strcpy_s: 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x\n",
515 dest
[0], dest
[1], dest
[2], dest
[3], dest
[4], dest
[5], dest
[6], dest
[7]);
516 ret
= pstrcpy_s(dest
, 0, NULL
);
517 ok(ret
== EINVAL
, "Copying into a destination of size 0 returned %d, expected EINVAL\n", ret
);
518 ok(dest
[0] == 'X' && dest
[1] == 'X' && dest
[2] == 'X' && dest
[3] == 'X' &&
519 dest
[4] == 'X' && dest
[5] == 'X' && dest
[6] == 'X' && dest
[7] == 'X',
520 "Unexpected return data from strcpy_s: 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x\n",
521 dest
[0], dest
[1], dest
[2], dest
[3], dest
[4], dest
[5], dest
[6], dest
[7]);
523 memset(dest
, 'X', sizeof(dest
));
524 ret
= pstrcpy_s(dest
, sizeof(dest
), big
);
525 ok(ret
== ERANGE
, "Copying a big string in a small location returned %d, expected ERANGE\n", ret
);
526 ok(dest
[0] == '\0'&& dest
[1] == 't' && dest
[2] == 'o' && dest
[3] == 'o' &&
527 dest
[4] == 'l' && dest
[5] == 'o' && dest
[6] == 'n' && dest
[7] == 'g',
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
));
532 ret
= pstrcpy_s(dest
, sizeof(dest
), NULL
);
533 ok(ret
== EINVAL
, "Copying from a NULL source string returned %d, expected EINVAL\n", ret
);
534 ok(dest
[0] == '\0'&& dest
[1] == 'X' && dest
[2] == 'X' && dest
[3] == 'X' &&
535 dest
[4] == 'X' && dest
[5] == 'X' && dest
[6] == 'X' && dest
[7] == 'X',
536 "Unexpected return data from strcpy_s: 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x\n",
537 dest
[0], dest
[1], dest
[2], dest
[3], dest
[4], dest
[5], dest
[6], dest
[7]);
539 ret
= pstrcpy_s(NULL
, sizeof(dest
), small
);
540 ok(ret
== EINVAL
, "Copying a big string a NULL dest returned %d, expected EINVAL\n", ret
);
543 #define NUMELMS(array) (sizeof(array)/sizeof((array)[0]))
545 #define okchars(dst, b0, b1, b2, b3, b4, b5, b6, b7) \
546 ok(dst[0] == b0 && dst[1] == b1 && dst[2] == b2 && dst[3] == b3 && \
547 dst[4] == b4 && dst[5] == b5 && dst[6] == b6 && dst[7] == b7, \
548 "Bad result: 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x\n",\
549 dst[0], dst[1], dst[2], dst[3], dst[4], dst[5], dst[6], dst[7])
551 static void test_memcpy_s(void)
554 static const char tiny
[] = {'T',0,'I','N','Y',0};
555 static const char big
[] = {'a','t','o','o','l','o','n','g','s','t','r','i','n','g',0};
558 win_skip("memcpy_s not found\n");
563 memset(dest
, 'X', sizeof(dest
));
564 ret
= p_memcpy_s(dest
, NUMELMS(dest
), tiny
, NUMELMS(tiny
));
565 ok(ret
== 0, "Copying a buffer into a big enough destination returned %d, expected 0\n", ret
);
566 okchars(dest
, tiny
[0], tiny
[1], tiny
[2], tiny
[3], tiny
[4], tiny
[5], 'X', 'X');
568 /* Vary source size */
570 memset(dest
, 'X', sizeof(dest
));
571 ret
= p_memcpy_s(dest
, NUMELMS(dest
), big
, NUMELMS(big
));
572 ok(ret
== ERANGE
, "Copying a big buffer to a small destination returned %d, expected ERANGE\n", ret
);
573 ok(errno
== ERANGE
, "errno is %d, expected ERANGE\n", errno
);
574 okchars(dest
, 0, 0, 0, 0, 0, 0, 0, 0);
576 /* Replace source with NULL */
578 memset(dest
, 'X', sizeof(dest
));
579 ret
= p_memcpy_s(dest
, NUMELMS(dest
), NULL
, NUMELMS(tiny
));
580 ok(ret
== EINVAL
, "Copying a NULL source buffer returned %d, expected EINVAL\n", ret
);
581 ok(errno
== EINVAL
, "errno is %d, expected EINVAL\n", errno
);
582 okchars(dest
, 0, 0, 0, 0, 0, 0, 0, 0);
586 memset(dest
, 'X', sizeof(dest
));
587 ret
= p_memcpy_s(dest
, 0, tiny
, NUMELMS(tiny
));
588 ok(ret
== ERANGE
, "Copying into a destination of size 0 returned %d, expected ERANGE\n", ret
);
589 ok(errno
== ERANGE
, "errno is %d, expected ERANGE\n", errno
);
590 okchars(dest
, 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X');
592 /* Replace dest with NULL */
594 ret
= p_memcpy_s(NULL
, NUMELMS(dest
), tiny
, NUMELMS(tiny
));
595 ok(ret
== EINVAL
, "Copying a tiny buffer to a big NULL destination returned %d, expected EINVAL\n", ret
);
596 ok(errno
== EINVAL
, "errno is %d, expected EINVAL\n", errno
);
600 memset(dest
, 'X', sizeof(dest
));
601 ret
= p_memcpy_s(dest
, 0, NULL
, NUMELMS(tiny
));
602 ok(ret
== EINVAL
, "Copying a NULL buffer into a destination of size 0 returned %d, expected EINVAL\n", ret
);
603 ok(errno
== EINVAL
, "errno is %d, expected EINVAL\n", errno
);
604 okchars(dest
, 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X');
607 static void test_memmove_s(void)
610 static const char tiny
[] = {'T',0,'I','N','Y',0};
611 static const char big
[] = {'a','t','o','o','l','o','n','g','s','t','r','i','n','g',0};
614 win_skip("memmove_s not found\n");
619 memset(dest
, 'X', sizeof(dest
));
620 ret
= p_memmove_s(dest
, NUMELMS(dest
), tiny
, NUMELMS(tiny
));
621 ok(ret
== 0, "Moving a buffer into a big enough destination returned %d, expected 0\n", ret
);
622 okchars(dest
, tiny
[0], tiny
[1], tiny
[2], tiny
[3], tiny
[4], tiny
[5], 'X', 'X');
625 memcpy(dest
, big
, sizeof(dest
));
626 ret
= p_memmove_s(dest
+1, NUMELMS(dest
)-1, dest
, NUMELMS(dest
)-1);
627 ok(ret
== 0, "Moving a buffer up one char returned %d, expected 0\n", ret
);
628 okchars(dest
, big
[0], big
[0], big
[1], big
[2], big
[3], big
[4], big
[5], big
[6]);
630 /* Vary source size */
632 memset(dest
, 'X', sizeof(dest
));
633 ret
= p_memmove_s(dest
, NUMELMS(dest
), big
, NUMELMS(big
));
634 ok(ret
== ERANGE
, "Moving a big buffer to a small destination returned %d, expected ERANGE\n", ret
);
635 ok(errno
== ERANGE
, "errno is %d, expected ERANGE\n", errno
);
636 okchars(dest
, 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X');
638 /* Replace source with NULL */
640 memset(dest
, 'X', sizeof(dest
));
641 ret
= p_memmove_s(dest
, NUMELMS(dest
), NULL
, NUMELMS(tiny
));
642 ok(ret
== EINVAL
, "Moving a NULL source buffer returned %d, expected EINVAL\n", ret
);
643 ok(errno
== EINVAL
, "errno is %d, expected EINVAL\n", errno
);
644 okchars(dest
, 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X');
648 memset(dest
, 'X', sizeof(dest
));
649 ret
= p_memmove_s(dest
, 0, tiny
, NUMELMS(tiny
));
650 ok(ret
== ERANGE
, "Moving into a destination of size 0 returned %d, expected ERANGE\n", ret
);
651 ok(errno
== ERANGE
, "errno is %d, expected ERANGE\n", errno
);
652 okchars(dest
, 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X');
654 /* Replace dest with NULL */
656 ret
= p_memmove_s(NULL
, NUMELMS(dest
), tiny
, NUMELMS(tiny
));
657 ok(ret
== EINVAL
, "Moving a tiny buffer to a big NULL destination returned %d, expected EINVAL\n", ret
);
658 ok(errno
== EINVAL
, "errno is %d, expected EINVAL\n", errno
);
662 memset(dest
, 'X', sizeof(dest
));
663 ret
= p_memmove_s(dest
, 0, NULL
, NUMELMS(tiny
));
664 ok(ret
== EINVAL
, "Moving a NULL buffer into a destination of size 0 returned %d, expected EINVAL\n", ret
);
665 ok(errno
== EINVAL
, "errno is %d, expected EINVAL\n", errno
);
666 okchars(dest
, 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X');
669 static void test_strcat_s(void)
672 const char *small
= "sma";
677 win_skip("strcat_s not found\n");
681 memset(dest
, 'X', sizeof(dest
));
683 ret
= pstrcat_s(dest
, sizeof(dest
), small
);
684 ok(ret
== 0, "strcat_s: Copying a string into a big enough destination returned %d, expected 0\n", ret
);
685 ok(dest
[0] == 's' && dest
[1] == 'm' && dest
[2] == 'a' && dest
[3] == '\0'&&
686 dest
[4] == 'X' && dest
[5] == 'X' && dest
[6] == 'X' && dest
[7] == 'X',
687 "Unexpected return data from strcpy_s: 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x\n",
688 dest
[0], dest
[1], dest
[2], dest
[3], dest
[4], dest
[5], dest
[6], dest
[7]);
689 ret
= pstrcat_s(dest
, sizeof(dest
), small
);
690 ok(ret
== 0, "strcat_s: Attaching a string to a big enough destination returned %d, expected 0\n", ret
);
691 ok(dest
[0] == 's' && dest
[1] == 'm' && dest
[2] == 'a' && dest
[3] == 's' &&
692 dest
[4] == 'm' && dest
[5] == 'a' && dest
[6] == '\0'&& dest
[7] == 'X',
693 "Unexpected return data from strcpy_s: 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x\n",
694 dest
[0], dest
[1], dest
[2], dest
[3], dest
[4], dest
[5], dest
[6], dest
[7]);
696 ret
= pstrcat_s(dest
, sizeof(dest
), small
);
697 ok(ret
== ERANGE
, "strcat_s: Attaching a string to a filled up destination returned %d, expected ERANGE\n", ret
);
698 ok(dest
[0] == '\0'&& dest
[1] == 'm' && dest
[2] == 'a' && dest
[3] == 's' &&
699 dest
[4] == 'm' && dest
[5] == 'a' && dest
[6] == 's' && dest
[7] == 'm',
700 "Unexpected return data from strcpy_s: 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x\n",
701 dest
[0], dest
[1], dest
[2], dest
[3], dest
[4], dest
[5], dest
[6], dest
[7]);
703 memset(dest
, 'X', sizeof(dest
));
707 ret
= pstrcat_s(dest
, 0, small
);
708 ok(ret
== EINVAL
, "strcat_s: Source len = 0 returned %d, expected EINVAL\n", ret
);
709 ok(dest
[0] == 'a' && dest
[1] == '\0'&& dest
[2] == 'X' && dest
[3] == 'X' &&
710 dest
[4] == 'X' && dest
[5] == 'X' && dest
[6] == 'X' && dest
[7] == 'X',
711 "Unexpected return data from strcpy_s: 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x\n",
712 dest
[0], dest
[1], dest
[2], dest
[3], dest
[4], dest
[5], dest
[6], dest
[7]);
714 ret
= pstrcat_s(dest
, 0, NULL
);
715 ok(ret
== EINVAL
, "strcat_s: len = 0 and src = NULL returned %d, expected EINVAL\n", ret
);
716 ok(dest
[0] == 'a' && dest
[1] == '\0'&& dest
[2] == 'X' && dest
[3] == 'X' &&
717 dest
[4] == 'X' && dest
[5] == 'X' && dest
[6] == 'X' && dest
[7] == 'X',
718 "Unexpected return data from strcpy_s: 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x\n",
719 dest
[0], dest
[1], dest
[2], dest
[3], dest
[4], dest
[5], dest
[6], dest
[7]);
721 ret
= pstrcat_s(dest
, sizeof(dest
), NULL
);
722 ok(ret
== EINVAL
, "strcat_s: Sourcing from NULL returned %d, expected EINVAL\n", ret
);
723 ok(dest
[0] == '\0'&& dest
[1] == '\0'&& dest
[2] == 'X' && dest
[3] == 'X' &&
724 dest
[4] == 'X' && dest
[5] == 'X' && dest
[6] == 'X' && dest
[7] == 'X',
725 "Unexpected return data from strcpy_s: 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x\n",
726 dest
[0], dest
[1], dest
[2], dest
[3], dest
[4], dest
[5], dest
[6], dest
[7]);
728 ret
= pstrcat_s(NULL
, sizeof(dest
), small
);
729 ok(ret
== EINVAL
, "strcat_s: Writing to a NULL string returned %d, expected EINVAL\n", ret
);
732 static void test__mbsnbcpy_s(void)
734 unsigned char dest
[8];
735 const unsigned char big
[] = "atoolongstringforthislittledestination";
736 const unsigned char small
[] = "small";
741 win_skip("_mbsnbcpy_s not found\n");
745 memset(dest
, 'X', sizeof(dest
));
746 ret
= p_mbsnbcpy_s(dest
, sizeof(dest
), small
, sizeof(small
));
747 ok(ret
== 0, "_mbsnbcpy_s: Copying a string into a big enough destination returned %d, expected 0\n", ret
);
748 ok(dest
[0] == 's' && dest
[1] == 'm' && dest
[2] == 'a' && dest
[3] == 'l' &&
749 dest
[4] == 'l' && dest
[5] == '\0'&& dest
[6] == 'X' && dest
[7] == 'X',
750 "Unexpected return data from _mbsnbcpy_s: 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x\n",
751 dest
[0], dest
[1], dest
[2], dest
[3], dest
[4], dest
[5], dest
[6], dest
[7]);
754 memset(dest
, 'X', sizeof(dest
));
755 ret
= p_mbsnbcpy_s(dest
, sizeof(dest
) - 2, big
, sizeof(small
));
756 ok(ret
== ERANGE
, "_mbsnbcpy_s: Copying a too long string returned %d, expected ERANGE\n", ret
);
757 ok(dest
[0] == '\0'&& dest
[1] == 't' && dest
[2] == 'o' && dest
[3] == 'o' &&
758 dest
[4] == 'l' && dest
[5] == 'o' && dest
[6] == 'X' && dest
[7] == 'X',
759 "Unexpected return data from _mbsnbcpy_s: 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x\n",
760 dest
[0], dest
[1], dest
[2], dest
[3], dest
[4], dest
[5], dest
[6], dest
[7]);
762 memset(dest
, 'X', sizeof(dest
));
763 ret
= p_mbsnbcpy_s(dest
, sizeof(dest
) - 2, big
, 4);
764 ok(ret
== 0, "_mbsnbcpy_s: Copying a too long string with a count cap returned %d, expected 0\n", ret
);
765 ok(dest
[0] == 'a' && dest
[1] == 't' && dest
[2] == 'o' && dest
[3] == 'o' &&
766 dest
[4] == '\0'&& dest
[5] == 'X' && dest
[6] == 'X' && dest
[7] == 'X',
767 "Unexpected return data from _mbsnbcpy_s: 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x\n",
768 dest
[0], dest
[1], dest
[2], dest
[3], dest
[4], dest
[5], dest
[6], dest
[7]);
770 memset(dest
, 'X', sizeof(dest
));
771 ret
= p_mbsnbcpy_s(dest
, sizeof(dest
) - 2, small
, sizeof(small
) + 10);
772 ok(ret
== 0, "_mbsnbcpy_s: Copying more data than the source string len returned %d, expected 0\n", ret
);
773 ok(dest
[0] == 's' && dest
[1] == 'm' && dest
[2] == 'a' && dest
[3] == 'l' &&
774 dest
[4] == 'l' && dest
[5] == '\0'&& dest
[6] == 'X' && dest
[7] == 'X',
775 "Unexpected return data from _mbsnbcpy_s: 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x\n",
776 dest
[0], dest
[1], dest
[2], dest
[3], dest
[4], dest
[5], dest
[6], dest
[7]);
779 static void test__mbscpy_s(void)
781 const unsigned char src
[] = "source string";
782 unsigned char dest
[16];
787 win_skip("_mbscpy_s not found\n");
791 ret
= p__mbscpy_s(NULL
, 0, src
);
792 ok(ret
== EINVAL
, "got %d\n", ret
);
793 ret
= p__mbscpy_s(NULL
, sizeof(dest
), src
);
794 ok(ret
== EINVAL
, "got %d\n", ret
);
795 ret
= p__mbscpy_s(dest
, 0, src
);
796 ok(ret
== EINVAL
, "got %d\n", ret
);
798 ret
= p__mbscpy_s(dest
, sizeof(dest
), NULL
);
799 ok(ret
== EINVAL
, "got %d\n", ret
);
800 ok(!dest
[0], "dest buffer was not modified on invalid argument\n");
802 memset(dest
, 'X', sizeof(dest
));
803 ret
= p__mbscpy_s(dest
, sizeof(dest
), src
);
804 ok(!ret
, "got %d\n", ret
);
805 ok(!memcmp(dest
, src
, sizeof(src
)), "dest = %s\n", dest
);
806 ok(dest
[sizeof(src
)] == 'X', "unused part of buffer was modified\n");
808 memset(dest
, 'X', sizeof(dest
));
809 ret
= p__mbscpy_s(dest
, 4, src
);
810 ok(ret
== ERANGE
, "got %d\n", ret
);
811 ok(!dest
[0], "incorrect dest buffer (%d)\n", dest
[0]);
812 ok(dest
[1] == src
[1], "incorrect dest buffer (%d)\n", dest
[1]);
815 static void test_wcscpy_s(void)
817 static const WCHAR szLongText
[] = { 'T','h','i','s','A','L','o','n','g','s','t','r','i','n','g',0 };
818 static WCHAR szDest
[18];
819 static WCHAR szDestShort
[8];
824 win_skip("wcscpy_s not found\n");
830 ret
= p_wcscpy_s(NULL
, 18, szLongText
);
831 ok(ret
== EINVAL
, "p_wcscpy_s expect EINVAL got %d\n", ret
);
832 ok(errno
== EINVAL
, "expected errno EINVAL got %d\n", errno
);
834 /* Test NULL Source */
837 ret
= p_wcscpy_s(szDest
, 18, NULL
);
838 ok(ret
== EINVAL
, "expected EINVAL got %d\n", ret
);
839 ok(errno
== EINVAL
, "expected errno EINVAL got %d\n", errno
);
840 ok(szDest
[0] == 0, "szDest[0] not 0, got %c\n", szDest
[0]);
842 /* Test invalid size */
845 ret
= p_wcscpy_s(szDest
, 0, szLongText
);
846 /* Later versions changed the return value for this case to EINVAL,
847 * and don't modify the result if the dest size is 0.
849 ok(ret
== ERANGE
|| ret
== EINVAL
, "expected ERANGE/EINVAL got %d\n", ret
);
850 ok(errno
== ERANGE
|| errno
== EINVAL
, "expected errno ERANGE/EINVAL got %d\n", errno
);
851 ok(szDest
[0] == 0 || ret
== EINVAL
, "szDest[0] not 0\n");
853 /* Copy same buffer size */
854 ret
= p_wcscpy_s(szDest
, 18, szLongText
);
855 ok(ret
== 0, "expected 0 got %d\n", ret
);
856 ok(lstrcmpW(szDest
, szLongText
) == 0, "szDest != szLongText\n");
858 /* Copy smaller buffer size */
861 ret
= p_wcscpy_s(szDestShort
, 8, szLongText
);
862 ok(ret
== ERANGE
|| ret
== EINVAL
, "expected ERANGE/EINVAL got %d\n", ret
);
863 ok(errno
== ERANGE
|| errno
== EINVAL
, "expected errno ERANGE/EINVAL got %d\n", errno
);
864 ok(szDestShort
[0] == 0, "szDestShort[0] not 0\n");
868 win_skip("wcsncpy_s not found\n");
872 ret
= p_wcsncpy_s(NULL
, 18, szLongText
, sizeof(szLongText
)/sizeof(WCHAR
));
873 ok(ret
== EINVAL
, "p_wcsncpy_s expect EINVAL got %d\n", ret
);
876 ret
= p_wcsncpy_s(szDest
, 18, NULL
, 1);
877 ok(ret
== EINVAL
, "expected EINVAL got %d\n", ret
);
878 ok(szDest
[0] == 0, "szDest[0] not 0\n");
881 ret
= p_wcsncpy_s(szDest
, 18, NULL
, 0);
882 ok(ret
== 0, "expected ERROR_SUCCESS got %d\n", ret
);
883 ok(szDest
[0] == 0, "szDest[0] not 0\n");
886 ret
= p_wcsncpy_s(szDest
, 0, szLongText
, sizeof(szLongText
)/sizeof(WCHAR
));
887 ok(ret
== ERANGE
|| ret
== EINVAL
, "expected ERANGE/EINVAL got %d\n", ret
);
888 ok(szDest
[0] == 0 || ret
== EINVAL
, "szDest[0] not 0\n");
890 ret
= p_wcsncpy_s(szDest
, 18, szLongText
, sizeof(szLongText
)/sizeof(WCHAR
));
891 ok(ret
== 0, "expected 0 got %d\n", ret
);
892 ok(lstrcmpW(szDest
, szLongText
) == 0, "szDest != szLongText\n");
895 ret
= p_wcsncpy_s(szDestShort
, 8, szLongText
, sizeof(szLongText
)/sizeof(WCHAR
));
896 ok(ret
== ERANGE
|| ret
== EINVAL
, "expected ERANGE/EINVAL got %d\n", ret
);
897 ok(szDestShort
[0] == 0, "szDestShort[0] not 0\n");
900 ret
= p_wcsncpy_s(szDest
, 5, szLongText
, -1);
901 ok(ret
== STRUNCATE
, "expected STRUNCATE got %d\n", ret
);
902 ok(szDest
[4] == 0, "szDest[4] not 0\n");
903 ok(!memcmp(szDest
, szLongText
, 4*sizeof(WCHAR
)), "szDest = %s\n", wine_dbgstr_w(szDest
));
905 ret
= p_wcsncpy_s(NULL
, 0, (void*)0xdeadbeef, 0);
906 ok(ret
== 0, "ret = %d\n", ret
);
908 szDestShort
[0] = '1';
910 ret
= p_wcsncpy_s(szDestShort
+1, 4, szDestShort
, -1);
911 ok(ret
== STRUNCATE
, "expected ERROR_SUCCESS got %d\n", ret
);
912 ok(szDestShort
[0]=='1' && szDestShort
[1]=='1' && szDestShort
[2]=='1' && szDestShort
[3]=='1',
913 "szDestShort = %s\n", wine_dbgstr_w(szDestShort
));
916 static void test__wcsupr_s(void)
918 static const WCHAR mixedString
[] = {'M', 'i', 'X', 'e', 'D', 'l', 'o', 'w',
919 'e', 'r', 'U', 'P', 'P', 'E', 'R', 0};
920 static const WCHAR expectedString
[] = {'M', 'I', 'X', 'E', 'D', 'L', 'O',
921 'W', 'E', 'R', 'U', 'P', 'P', 'E',
923 WCHAR testBuffer
[2*sizeof(mixedString
)/sizeof(WCHAR
)];
928 win_skip("_wcsupr_s not found\n");
932 /* Test NULL input string and invalid size. */
934 ret
= p_wcsupr_s(NULL
, 0);
935 ok(ret
== EINVAL
, "Expected _wcsupr_s to fail with EINVAL, got %d\n", ret
);
936 ok(errno
== EINVAL
, "Expected errno to be EINVAL, got %d\n", errno
);
938 /* Test NULL input string and valid size. */
940 ret
= p_wcsupr_s(NULL
, sizeof(testBuffer
)/sizeof(WCHAR
));
941 ok(ret
== EINVAL
, "Expected _wcsupr_s to fail with EINVAL, got %d\n", ret
);
942 ok(errno
== EINVAL
, "Expected errno to be EINVAL, got %d\n", errno
);
944 /* Test empty string with zero size. */
946 testBuffer
[0] = '\0';
947 ret
= p_wcsupr_s(testBuffer
, 0);
948 ok(ret
== EINVAL
, "Expected _wcsupr_s to fail with EINVAL, got %d\n", ret
);
949 ok(errno
== EINVAL
, "Expected errno to be EINVAL, got %d\n", errno
);
950 ok(testBuffer
[0] == '\0', "Expected the buffer to be unchanged\n");
952 /* Test empty string with size of one. */
953 testBuffer
[0] = '\0';
954 ret
= p_wcsupr_s(testBuffer
, 1);
955 ok(ret
== 0, "Expected _wcsupr_s to succeed, got %d\n", ret
);
956 ok(testBuffer
[0] == '\0', "Expected the buffer to be unchanged\n");
958 /* Test one-byte buffer with zero size. */
961 ret
= p_wcsupr_s(testBuffer
, 0);
962 ok(ret
== EINVAL
, "Expected _wcsupr_s to fail with EINVAL, got %d\n", ret
);
963 ok(errno
== EINVAL
, "Expected errno to be EINVAL, got %d\n", errno
);
964 ok(testBuffer
[0] == '\0', "Expected the first buffer character to be null\n");
966 /* Test one-byte buffer with size of one. */
969 ret
= p_wcsupr_s(testBuffer
, 1);
970 ok(ret
== EINVAL
, "Expected _wcsupr_s to fail with EINVAL, got %d\n", ret
);
971 ok(errno
== EINVAL
, "Expected errno to be EINVAL, got %d\n", errno
);
972 ok(testBuffer
[0] == '\0', "Expected the first buffer character to be null\n");
974 /* Test invalid size. */
975 wcscpy(testBuffer
, mixedString
);
977 ret
= p_wcsupr_s(testBuffer
, 0);
978 ok(ret
== EINVAL
, "Expected _wcsupr_s to fail with EINVAL, got %d\n", ret
);
979 ok(errno
== EINVAL
, "Expected errno to be EINVAL, got %d\n", errno
);
980 ok(testBuffer
[0] == '\0', "Expected the first buffer character to be null\n");
982 /* Test normal string uppercasing. */
983 wcscpy(testBuffer
, mixedString
);
984 ret
= p_wcsupr_s(testBuffer
, sizeof(mixedString
)/sizeof(WCHAR
));
985 ok(ret
== 0, "Expected _wcsupr_s to succeed, got %d\n", ret
);
986 ok(!wcscmp(testBuffer
, expectedString
), "Expected the string to be fully upper-case\n");
988 /* Test uppercasing with a shorter buffer size count. */
989 wcscpy(testBuffer
, mixedString
);
991 ret
= p_wcsupr_s(testBuffer
, sizeof(mixedString
)/sizeof(WCHAR
) - 1);
992 ok(ret
== EINVAL
, "Expected _wcsupr_s to fail with EINVAL, got %d\n", ret
);
993 ok(errno
== EINVAL
, "Expected errno to be EINVAL, got %d\n", errno
);
994 ok(testBuffer
[0] == '\0', "Expected the first buffer character to be null\n");
996 /* Test uppercasing with a longer buffer size count. */
997 wcscpy(testBuffer
, mixedString
);
998 ret
= p_wcsupr_s(testBuffer
, sizeof(testBuffer
)/sizeof(WCHAR
));
999 ok(ret
== 0, "Expected _wcsupr_s to succeed, got %d\n", ret
);
1000 ok(!wcscmp(testBuffer
, expectedString
), "Expected the string to be fully upper-case\n");
1003 static void test__wcslwr_s(void)
1005 static const WCHAR mixedString
[] = {'M', 'i', 'X', 'e', 'D', 'l', 'o', 'w',
1006 'e', 'r', 'U', 'P', 'P', 'E', 'R', 0};
1007 static const WCHAR expectedString
[] = {'m', 'i', 'x', 'e', 'd', 'l', 'o',
1008 'w', 'e', 'r', 'u', 'p', 'p', 'e',
1010 WCHAR buffer
[2*sizeof(mixedString
)/sizeof(WCHAR
)];
1015 win_skip("_wcslwr_s not found\n");
1019 /* Test NULL input string and invalid size. */
1021 ret
= p_wcslwr_s(NULL
, 0);
1022 ok(ret
== EINVAL
, "expected EINVAL, got %d\n", ret
);
1023 ok(errno
== EINVAL
, "expected errno EINVAL, got %d\n", errno
);
1025 /* Test NULL input string and valid size. */
1027 ret
= p_wcslwr_s(NULL
, sizeof(buffer
)/sizeof(wchar_t));
1028 ok(ret
== EINVAL
, "expected EINVAL, got %d\n", ret
);
1029 ok(errno
== EINVAL
, "expected errno EINVAL, got %d\n", errno
);
1031 /* Test empty string with zero size. */
1034 ret
= p_wcslwr_s(buffer
, 0);
1035 ok(ret
== EINVAL
, "expected EINVAL, got %d\n", ret
);
1036 ok(errno
== EINVAL
, "expected errno EINVAL, got %d\n", errno
);
1037 ok(buffer
[0] == 0, "expected empty string\n");
1039 /* Test empty string with size of one. */
1041 ret
= p_wcslwr_s(buffer
, 1);
1042 ok(ret
== 0, "got %d\n", ret
);
1043 ok(buffer
[0] == 0, "expected buffer to be unchanged\n");
1045 /* Test one-byte buffer with zero size. */
1048 ret
= p_wcslwr_s(buffer
, 0);
1049 ok(ret
== EINVAL
, "expected EINVAL, got %d\n", ret
);
1050 ok(errno
== EINVAL
, "expected errno to be EINVAL, got %d\n", errno
);
1051 ok(buffer
[0] == '\0', "expected empty string\n");
1053 /* Test one-byte buffer with size of one. */
1056 ret
= p_wcslwr_s(buffer
, 1);
1057 ok(ret
== EINVAL
, "expected EINVAL, got %d\n", ret
);
1058 ok(errno
== EINVAL
, "expected errno to be EINVAL, got %d\n", errno
);
1059 ok(buffer
[0] == '\0', "expected empty string\n");
1061 /* Test invalid size. */
1062 wcscpy(buffer
, mixedString
);
1064 ret
= p_wcslwr_s(buffer
, 0);
1065 ok(ret
== EINVAL
, "Expected EINVAL, got %d\n", ret
);
1066 ok(errno
== EINVAL
, "expected errno to be EINVAL, got %d\n", errno
);
1067 ok(buffer
[0] == '\0', "expected empty string\n");
1069 /* Test normal string uppercasing. */
1070 wcscpy(buffer
, mixedString
);
1071 ret
= p_wcslwr_s(buffer
, sizeof(mixedString
)/sizeof(WCHAR
));
1072 ok(ret
== 0, "expected 0, got %d\n", ret
);
1073 ok(!wcscmp(buffer
, expectedString
), "expected lowercase\n");
1075 /* Test uppercasing with a shorter buffer size count. */
1076 wcscpy(buffer
, mixedString
);
1078 ret
= p_wcslwr_s(buffer
, sizeof(mixedString
)/sizeof(WCHAR
) - 1);
1079 ok(ret
== EINVAL
, "expected EINVAL, got %d\n", ret
);
1080 ok(errno
== EINVAL
, "expected errno to be EINVAL, got %d\n", errno
);
1081 ok(buffer
[0] == '\0', "expected empty string\n");
1083 /* Test uppercasing with a longer buffer size count. */
1084 wcscpy(buffer
, mixedString
);
1085 ret
= p_wcslwr_s(buffer
, sizeof(buffer
)/sizeof(WCHAR
));
1086 ok(ret
== 0, "expected 0, got %d\n", ret
);
1087 ok(!wcscmp(buffer
, expectedString
), "expected lowercase\n");
1090 static void test_mbcjisjms(void)
1092 /* List of value-pairs to test. The test assumes the last pair to be {0, ..} */
1093 unsigned int jisjms
[][2] = { {0x2020, 0}, {0x2021, 0}, {0x2120, 0}, {0x2121, 0x8140},
1094 {0x7f7f, 0}, {0x7f7e, 0}, {0x7e7f, 0}, {0x7e7e, 0xeffc},
1095 {0x255f, 0x837e}, {0x2560, 0x8380}, {0x2561, 0x8381},
1096 {0x2121FFFF, 0}, {0x2223, 0x81a1}, {0x237e, 0x829e}, {0, 0}};
1097 int cp
[] = { 932, 936, 939, 950, 1361, _MB_CP_SBCS
};
1099 int prev_cp
= _getmbcp();
1101 for (i
= 0; i
< sizeof(cp
)/sizeof(cp
[0]); i
++)
1104 for (j
= 0; jisjms
[j
][0] != 0; j
++)
1106 unsigned int ret
, exp
;
1107 ret
= _mbcjistojms(jisjms
[j
][0]);
1108 exp
= (cp
[i
] == 932) ? jisjms
[j
][1] : jisjms
[j
][0];
1109 ok(ret
== exp
, "Expected 0x%x, got 0x%x (0x%x, codepage=%d)\n",
1110 exp
, ret
, jisjms
[j
][0], cp
[i
]);
1116 static void test_mbcjmsjis(void)
1118 /* List of value-pairs to test. The test assumes the last pair to be {0, ..} */
1119 unsigned int jmsjis
[][2] = { {0x80fc, 0}, {0x813f, 0}, {0x8140, 0x2121},
1120 {0x817e, 0x215f}, {0x817f, 0}, {0x8180, 0x2160},
1121 {0x819e, 0x217e}, {0x819f, 0x2221}, {0x81fc, 0x227e},
1122 {0x81fd, 0}, {0x9ffc, 0x5e7e}, {0x9ffd, 0},
1123 {0xa040, 0}, {0xdffc, 0}, {0xe040, 0x5f21},
1124 {0xeffc, 0x7e7e}, {0xf040, 0}, {0x21, 0}, {0, 0}};
1125 int cp
[] = { 932, 936, 939, 950, 1361, _MB_CP_SBCS
};
1127 int prev_cp
= _getmbcp();
1129 for (i
= 0; i
< sizeof(cp
)/sizeof(cp
[0]); i
++)
1132 for (j
= 0; jmsjis
[j
][0] != 0; j
++)
1134 unsigned int ret
, exp
;
1135 ret
= _mbcjmstojis(jmsjis
[j
][0]);
1136 exp
= (cp
[i
] == 932) ? jmsjis
[j
][1] : jmsjis
[j
][0];
1137 ok(ret
== exp
, "Expected 0x%x, got 0x%x (0x%x, codepage=%d)\n",
1138 exp
, ret
, jmsjis
[j
][0], cp
[i
]);
1144 static void test_mbbtombc(void)
1146 static const unsigned int mbbmbc
[][2] = {
1147 {0x1f, 0x1f}, {0x20, 0x8140}, {0x39, 0x8258}, {0x40, 0x8197},
1148 {0x41, 0x8260}, {0x5e, 0x814f}, {0x7e, 0x8150}, {0x7f, 0x7f},
1149 {0x80, 0x80}, {0x81, 0x81}, {0xa0, 0xa0}, {0xa7, 0x8340},
1150 {0xb0, 0x815b}, {0xd1, 0x8380}, {0xff, 0xff}, {0,0}};
1151 int cp
[] = { 932, 936, 939, 950, 1361, _MB_CP_SBCS
};
1153 int prev_cp
= _getmbcp();
1155 for (i
= 0; i
< sizeof(cp
)/sizeof(cp
[0]); i
++)
1158 for (j
= 0; mbbmbc
[j
][0] != 0; j
++)
1160 unsigned int exp
, ret
;
1161 ret
= _mbbtombc(mbbmbc
[j
][0]);
1162 exp
= (cp
[i
] == 932) ? mbbmbc
[j
][1] : mbbmbc
[j
][0];
1163 ok(ret
== exp
, "Expected 0x%x, got 0x%x (0x%x, codepage %d)\n",
1164 exp
, ret
, mbbmbc
[j
][0], cp
[i
]);
1170 static void test_mbctombb(void)
1172 static const unsigned int mbcmbb_932
[][2] = {
1173 {0x829e, 0x829e}, {0x829f, 0xa7}, {0x82f1, 0xdd}, {0x82f2, 0x82f2},
1174 {0x833f, 0x833f}, {0x8340, 0xa7}, {0x837e, 0xd0}, {0x837f, 0x837f},
1175 {0x8380, 0xd1}, {0x8396, 0xb9}, {0x8397, 0x8397}, {0x813f, 0x813f},
1176 {0x8140, 0x20}, {0x814c, 0x814c}, {0x814f, 0x5e}, {0x8197, 0x40},
1177 {0x8198, 0x8198}, {0x8258, 0x39}, {0x8259, 0x8259}, {0x825f, 0x825f},
1178 {0x8260, 0x41}, {0x82f1, 0xdd}, {0x82f2, 0x82f2}, {0,0}};
1179 unsigned int exp
, ret
, i
;
1180 unsigned int prev_cp
= _getmbcp();
1183 for (i
= 0; mbcmbb_932
[i
][0] != 0; i
++)
1185 ret
= _mbctombb(mbcmbb_932
[i
][0]);
1186 exp
= mbcmbb_932
[i
][1];
1187 ok(ret
== exp
, "Expected 0x%x, got 0x%x\n", exp
, ret
);
1192 static void test_ismbclegal(void) {
1193 unsigned int prev_cp
= _getmbcp();
1197 _setmbcp(932); /* Japanese */
1199 for(i
= 0; i
< 0x10000; i
++) {
1200 ret
= _ismbclegal(i
);
1201 exp
= ((HIBYTE(i
) >= 0x81 && HIBYTE(i
) <= 0x9F) ||
1202 (HIBYTE(i
) >= 0xE0 && HIBYTE(i
) <= 0xFC)) &&
1203 ((LOBYTE(i
) >= 0x40 && LOBYTE(i
) <= 0x7E) ||
1204 (LOBYTE(i
) >= 0x80 && LOBYTE(i
) <= 0xFC));
1210 ok(!err
, "_ismbclegal (932) : Expected 0x%x, got 0x%x (0x%x)\n", exp
, ret
, i
);
1211 _setmbcp(936); /* Chinese (GBK) */
1213 for(i
= 0; i
< 0x10000; i
++) {
1214 ret
= _ismbclegal(i
);
1215 exp
= HIBYTE(i
) >= 0x81 && HIBYTE(i
) <= 0xFE &&
1216 LOBYTE(i
) >= 0x40 && LOBYTE(i
) <= 0xFE;
1222 ok(!err
, "_ismbclegal (936) : Expected 0x%x, got 0x%x (0x%x)\n", exp
, ret
, i
);
1223 _setmbcp(949); /* Korean */
1225 for(i
= 0; i
< 0x10000; i
++) {
1226 ret
= _ismbclegal(i
);
1227 exp
= HIBYTE(i
) >= 0x81 && HIBYTE(i
) <= 0xFE &&
1228 LOBYTE(i
) >= 0x41 && LOBYTE(i
) <= 0xFE;
1234 ok(!err
, "_ismbclegal (949) : Expected 0x%x, got 0x%x (0x%x)\n", exp
, ret
, i
);
1235 _setmbcp(950); /* Chinese (Big5) */
1237 for(i
= 0; i
< 0x10000; i
++) {
1238 ret
= _ismbclegal(i
);
1239 exp
= HIBYTE(i
) >= 0x81 && HIBYTE(i
) <= 0xFE &&
1240 ((LOBYTE(i
) >= 0x40 && LOBYTE(i
) <= 0x7E) ||
1241 (LOBYTE(i
) >= 0xA1 && LOBYTE(i
) <= 0xFE));
1247 ok(!err
, "_ismbclegal (950) : Expected 0x%x, got 0x%x (0x%x)\n", exp
, ret
, i
);
1248 _setmbcp(1361); /* Korean (Johab) */
1250 for(i
= 0; i
< 0x10000; i
++) {
1251 ret
= _ismbclegal(i
);
1252 exp
= ((HIBYTE(i
) >= 0x81 && HIBYTE(i
) <= 0xD3) ||
1253 (HIBYTE(i
) >= 0xD8 && HIBYTE(i
) <= 0xF9)) &&
1254 ((LOBYTE(i
) >= 0x31 && LOBYTE(i
) <= 0x7E) ||
1255 (LOBYTE(i
) >= 0x81 && LOBYTE(i
) <= 0xFE)) &&
1262 todo_wine
ok(!err
, "_ismbclegal (1361) : Expected 0x%x, got 0x%x (0x%x)\n", exp
, ret
, i
);
1267 static const struct {
1269 const char* delimiter
;
1270 int exp_offsetret1
; /* returned offset from string after first call to strtok()
1272 int exp_offsetret2
; /* returned offset from string after second call to strtok()
1274 int exp_offsetret3
; /* returned offset from string after third call to strtok()
1276 } testcases_strtok
[] = {
1277 { "red cabernet", " ", 0, 4, -1 },
1278 { "sparkling white riesling", " ", 0, 10, 16 },
1279 { " pale cream sherry", "e ", 1, 6, 9 },
1284 static void test_strtok(void)
1289 for( i
= 0; testcases_strtok
[i
].string
; i
++){
1290 strcpy( teststr
, testcases_strtok
[i
].string
);
1291 strret
= strtok( teststr
, testcases_strtok
[i
].delimiter
);
1292 ok( (int)(strret
- teststr
) == testcases_strtok
[i
].exp_offsetret1
||
1293 (!strret
&& testcases_strtok
[i
].exp_offsetret1
== -1),
1294 "string (%p) \'%s\' return %p\n",
1295 teststr
, testcases_strtok
[i
].string
, strret
);
1296 if( !strret
) continue;
1297 strret
= strtok( NULL
, testcases_strtok
[i
].delimiter
);
1298 ok( (int)(strret
- teststr
) == testcases_strtok
[i
].exp_offsetret2
||
1299 (!strret
&& testcases_strtok
[i
].exp_offsetret2
== -1),
1300 "second call string (%p) \'%s\' return %p\n",
1301 teststr
, testcases_strtok
[i
].string
, strret
);
1302 if( !strret
) continue;
1303 strret
= strtok( NULL
, testcases_strtok
[i
].delimiter
);
1304 ok( (int)(strret
- teststr
) == testcases_strtok
[i
].exp_offsetret3
||
1305 (!strret
&& testcases_strtok
[i
].exp_offsetret3
== -1),
1306 "third call string (%p) \'%s\' return %p\n",
1307 teststr
, testcases_strtok
[i
].string
, strret
);
1311 static void test_strtol(void)
1317 /* errno is only set in case of error, so reset errno to EBADF to check for errno modification */
1318 /* errno is modified on W2K8+ */
1320 l
= strtol("-1234", &e
, 0);
1321 ok(l
==-1234, "wrong value %d\n", l
);
1322 ok(errno
== EBADF
|| broken(errno
== 0), "wrong errno %d\n", errno
);
1324 ul
= strtoul("1234", &e
, 0);
1325 ok(ul
==1234, "wrong value %u\n", ul
);
1326 ok(errno
== EBADF
|| broken(errno
== 0), "wrong errno %d\n", errno
);
1329 l
= strtol("2147483647L", &e
, 0);
1330 ok(l
==2147483647, "wrong value %d\n", l
);
1331 ok(errno
== EBADF
|| broken(errno
== 0), "wrong errno %d\n", errno
);
1333 l
= strtol("-2147483648L", &e
, 0);
1334 ok(l
==-2147483647L - 1, "wrong value %d\n", l
);
1335 ok(errno
== EBADF
|| broken(errno
== 0), "wrong errno %d\n", errno
);
1337 ul
= strtoul("4294967295UL", &e
, 0);
1338 ok(ul
==4294967295ul, "wrong value %u\n", ul
);
1339 ok(errno
== EBADF
|| broken(errno
== 0), "wrong errno %d\n", errno
);
1342 l
= strtol("9223372036854775807L", &e
, 0);
1343 ok(l
==2147483647, "wrong value %d\n", l
);
1344 ok(errno
== ERANGE
, "wrong errno %d\n", errno
);
1346 ul
= strtoul("9223372036854775807L", &e
, 0);
1347 ok(ul
==4294967295ul, "wrong value %u\n", ul
);
1348 ok(errno
== ERANGE
, "wrong errno %d\n", errno
);
1351 ul
= strtoul("-2", NULL
, 0);
1352 ok(ul
== -2, "wrong value %u\n", ul
);
1353 ok(errno
== 0, "wrong errno %d\n", errno
);
1356 ul
= strtoul("-4294967294", NULL
, 0);
1357 ok(ul
== 2, "wrong value %u\n", ul
);
1358 ok(errno
== 0, "wrong errno %d\n", errno
);
1361 ul
= strtoul("-4294967295", NULL
, 0);
1362 ok(ul
==1, "wrong value %u\n", ul
);
1363 ok(errno
== 0, "wrong errno %d\n", errno
);
1366 ul
= strtoul("-4294967296", NULL
, 0);
1367 ok(ul
== 1, "wrong value %u\n", ul
);
1368 ok(errno
== ERANGE
, "wrong errno %d\n", errno
);
1371 static void test_strnlen(void)
1373 static const char str
[] = "string";
1377 win_skip("strnlen not found\n");
1381 res
= p_strnlen(str
, 20);
1382 ok(res
== 6, "Returned length = %d\n", (int)res
);
1384 res
= p_strnlen(str
, 3);
1385 ok(res
== 3, "Returned length = %d\n", (int)res
);
1387 res
= p_strnlen(NULL
, 0);
1388 ok(res
== 0, "Returned length = %d\n", (int)res
);
1391 static void test__strtoi64(void)
1393 static const char no1
[] = "31923";
1394 static const char no2
[] = "-213312";
1395 static const char no3
[] = "12aa";
1396 static const char no4
[] = "abc12";
1397 static const char overflow
[] = "99999999999999999999";
1398 static const char neg_overflow
[] = "-99999999999999999999";
1399 static const char hex
[] = "0x123";
1400 static const char oct
[] = "000123";
1401 static const char blanks
[] = " 12 212.31";
1404 unsigned __int64 ures
;
1407 if(!p_strtoi64
|| !p_strtoui64
) {
1408 win_skip("_strtoi64 or _strtoui64 not found\n");
1413 res
= p_strtoi64(no1
, NULL
, 10);
1414 ok(res
== 31923, "res != 31923\n");
1415 res
= p_strtoi64(no2
, NULL
, 10);
1416 ok(res
== -213312, "res != -213312\n");
1417 res
= p_strtoi64(no3
, NULL
, 10);
1418 ok(res
== 12, "res != 12\n");
1419 res
= p_strtoi64(no4
, &endpos
, 10);
1420 ok(res
== 0, "res != 0\n");
1421 ok(endpos
== no4
, "Scanning was not stopped on first character\n");
1422 res
= p_strtoi64(hex
, &endpos
, 10);
1423 ok(res
== 0, "res != 0\n");
1424 ok(endpos
== hex
+1, "Incorrect endpos (%p-%p)\n", hex
, endpos
);
1425 res
= p_strtoi64(oct
, &endpos
, 10);
1426 ok(res
== 123, "res != 123\n");
1427 ok(endpos
== oct
+strlen(oct
), "Incorrect endpos (%p-%p)\n", oct
, endpos
);
1428 res
= p_strtoi64(blanks
, &endpos
, 10);
1429 ok(res
== 12, "res != 12\n");
1430 ok(endpos
== blanks
+10, "Incorrect endpos (%p-%p)\n", blanks
, endpos
);
1431 ok(errno
== 0xdeadbeef, "errno = %x\n", errno
);
1434 res
= p_strtoi64(overflow
, &endpos
, 10);
1435 ok(res
== _I64_MAX
, "res != _I64_MAX\n");
1436 ok(endpos
== overflow
+strlen(overflow
), "Incorrect endpos (%p-%p)\n", overflow
, endpos
);
1437 ok(errno
== ERANGE
, "errno = %x\n", errno
);
1440 res
= p_strtoi64(neg_overflow
, &endpos
, 10);
1441 ok(res
== _I64_MIN
, "res != _I64_MIN\n");
1442 ok(endpos
== neg_overflow
+strlen(neg_overflow
), "Incorrect endpos (%p-%p)\n", neg_overflow
, endpos
);
1443 ok(errno
== ERANGE
, "errno = %x\n", errno
);
1446 res
= p_strtoi64(no1
, &endpos
, 16);
1447 ok(res
== 203043, "res != 203043\n");
1448 ok(endpos
== no1
+strlen(no1
), "Incorrect endpos (%p-%p)\n", no1
, endpos
);
1449 res
= p_strtoi64(no2
, &endpos
, 16);
1450 ok(res
== -2175762, "res != -2175762\n");
1451 ok(endpos
== no2
+strlen(no2
), "Incorrect endpos (%p-%p)\n", no2
, endpos
);
1452 res
= p_strtoi64(no3
, &endpos
, 16);
1453 ok(res
== 4778, "res != 4778\n");
1454 ok(endpos
== no3
+strlen(no3
), "Incorrect endpos (%p-%p)\n", no3
, endpos
);
1455 res
= p_strtoi64(no4
, &endpos
, 16);
1456 ok(res
== 703506, "res != 703506\n");
1457 ok(endpos
== no4
+strlen(no4
), "Incorrect endpos (%p-%p)\n", no4
, endpos
);
1458 res
= p_strtoi64(hex
, &endpos
, 16);
1459 ok(res
== 291, "res != 291\n");
1460 ok(endpos
== hex
+strlen(hex
), "Incorrect endpos (%p-%p)\n", hex
, endpos
);
1461 res
= p_strtoi64(oct
, &endpos
, 16);
1462 ok(res
== 291, "res != 291\n");
1463 ok(endpos
== oct
+strlen(oct
), "Incorrect endpos (%p-%p)\n", oct
, endpos
);
1464 res
= p_strtoi64(blanks
, &endpos
, 16);
1465 ok(res
== 18, "res != 18\n");
1466 ok(endpos
== blanks
+10, "Incorrect endpos (%p-%p)\n", blanks
, endpos
);
1467 ok(errno
== 0xdeadbeef, "errno = %x\n", errno
);
1470 res
= p_strtoi64(hex
, &endpos
, 36);
1471 ok(res
== 1541019, "res != 1541019\n");
1472 ok(endpos
== hex
+strlen(hex
), "Incorrect endpos (%p-%p)\n", hex
, endpos
);
1473 ok(errno
== 0xdeadbeef, "errno = %x\n", errno
);
1476 res
= p_strtoi64(no1
, &endpos
, 0);
1477 ok(res
== 31923, "res != 31923\n");
1478 ok(endpos
== no1
+strlen(no1
), "Incorrect endpos (%p-%p)\n", no1
, endpos
);
1479 res
= p_strtoi64(no2
, &endpos
, 0);
1480 ok(res
== -213312, "res != -213312\n");
1481 ok(endpos
== no2
+strlen(no2
), "Incorrect endpos (%p-%p)\n", no2
, endpos
);
1482 res
= p_strtoi64(no3
, &endpos
, 10);
1483 ok(res
== 12, "res != 12\n");
1484 ok(endpos
== no3
+2, "Incorrect endpos (%p-%p)\n", no3
, endpos
);
1485 res
= p_strtoi64(no4
, &endpos
, 10);
1486 ok(res
== 0, "res != 0\n");
1487 ok(endpos
== no4
, "Incorrect endpos (%p-%p)\n", no4
, endpos
);
1488 res
= p_strtoi64(hex
, &endpos
, 10);
1489 ok(res
== 0, "res != 0\n");
1490 ok(endpos
== hex
+1, "Incorrect endpos (%p-%p)\n", hex
, endpos
);
1491 res
= p_strtoi64(oct
, &endpos
, 10);
1492 ok(res
== 123, "res != 123\n");
1493 ok(endpos
== oct
+strlen(oct
), "Incorrect endpos (%p-%p)\n", oct
, endpos
);
1494 res
= p_strtoi64(blanks
, &endpos
, 10);
1495 ok(res
== 12, "res != 12\n");
1496 ok(endpos
== blanks
+10, "Incorrect endpos (%p-%p)\n", blanks
, endpos
);
1497 ok(errno
== 0xdeadbeef, "errno = %x\n", errno
);
1500 ures
= p_strtoui64(no1
, &endpos
, 0);
1501 ok(ures
== 31923, "ures != 31923\n");
1502 ok(endpos
== no1
+strlen(no1
), "Incorrect endpos (%p-%p)\n", no1
, endpos
);
1503 ures
= p_strtoui64(no2
, &endpos
, 0);
1504 ok(ures
== -213312, "ures != -213312\n");
1505 ok(endpos
== no2
+strlen(no2
), "Incorrect endpos (%p-%p)\n", no2
, endpos
);
1506 ures
= p_strtoui64(no3
, &endpos
, 10);
1507 ok(ures
== 12, "ures != 12\n");
1508 ok(endpos
== no3
+2, "Incorrect endpos (%p-%p)\n", no3
, endpos
);
1509 ures
= p_strtoui64(no4
, &endpos
, 10);
1510 ok(ures
== 0, "ures != 0\n");
1511 ok(endpos
== no4
, "Incorrect endpos (%p-%p)\n", no4
, endpos
);
1512 ures
= p_strtoui64(hex
, &endpos
, 10);
1513 ok(ures
== 0, "ures != 0\n");
1514 ok(endpos
== hex
+1, "Incorrect endpos (%p-%p)\n", hex
, endpos
);
1515 ures
= p_strtoui64(oct
, &endpos
, 10);
1516 ok(ures
== 123, "ures != 123\n");
1517 ok(endpos
== oct
+strlen(oct
), "Incorrect endpos (%p-%p)\n", oct
, endpos
);
1518 ures
= p_strtoui64(blanks
, &endpos
, 10);
1519 ok(ures
== 12, "ures != 12\n");
1520 ok(endpos
== blanks
+10, "Incorrect endpos (%p-%p)\n", blanks
, endpos
);
1521 ok(errno
== 0xdeadbeef, "errno = %x\n", errno
);
1524 ures
= p_strtoui64(overflow
, &endpos
, 10);
1525 ok(ures
== _UI64_MAX
, "ures != _UI64_MAX\n");
1526 ok(endpos
== overflow
+strlen(overflow
), "Incorrect endpos (%p-%p)\n", overflow
, endpos
);
1527 ok(errno
== ERANGE
, "errno = %x\n", errno
);
1530 ures
= p_strtoui64(neg_overflow
, &endpos
, 10);
1531 ok(ures
== 1, "ures != 1\n");
1532 ok(endpos
== neg_overflow
+strlen(neg_overflow
), "Incorrect endpos (%p-%p)\n", neg_overflow
, endpos
);
1533 ok(errno
== ERANGE
, "errno = %x\n", errno
);
1536 static inline BOOL
almost_equal(double d1
, double d2
) {
1537 if(d1
-d2
>-1e-30 && d1
-d2
<1e-30)
1542 static void test__strtod(void)
1544 const char double1
[] = "12.1";
1545 const char double2
[] = "-13.721";
1546 const char double3
[] = "INF";
1547 const char double4
[] = ".21e12";
1548 const char double5
[] = "214353e-3";
1549 const char overflow
[] = "1d9999999999999999999";
1550 const char white_chars
[] = " d10";
1555 d
= strtod(double1
, &end
);
1556 ok(almost_equal(d
, 12.1), "d = %lf\n", d
);
1557 ok(end
== double1
+4, "incorrect end (%d)\n", (int)(end
-double1
));
1559 d
= strtod(double2
, &end
);
1560 ok(almost_equal(d
, -13.721), "d = %lf\n", d
);
1561 ok(end
== double2
+7, "incorrect end (%d)\n", (int)(end
-double2
));
1563 d
= strtod(double3
, &end
);
1564 ok(almost_equal(d
, 0), "d = %lf\n", d
);
1565 ok(end
== double3
, "incorrect end (%d)\n", (int)(end
-double3
));
1567 d
= strtod(double4
, &end
);
1568 ok(almost_equal(d
, 210000000000.0), "d = %lf\n", d
);
1569 ok(end
== double4
+6, "incorrect end (%d)\n", (int)(end
-double4
));
1571 d
= strtod(double5
, &end
);
1572 ok(almost_equal(d
, 214.353), "d = %lf\n", d
);
1573 ok(end
== double5
+9, "incorrect end (%d)\n", (int)(end
-double5
));
1575 d
= strtod("12.1d2", NULL
);
1576 ok(almost_equal(d
, 12.1e2
), "d = %lf\n", d
);
1578 d
= strtod(white_chars
, &end
);
1579 ok(almost_equal(d
, 0), "d = %lf\n", d
);
1580 ok(end
== white_chars
, "incorrect end (%d)\n", (int)(end
-white_chars
));
1582 /* Set locale with non '.' decimal point (',') */
1583 if(!setlocale(LC_ALL
, "Polish")) {
1584 win_skip("system with limited locales\n");
1588 d
= strtod("12.1", NULL
);
1589 ok(almost_equal(d
, 12.0), "d = %lf\n", d
);
1591 d
= strtod("12,1", NULL
);
1592 ok(almost_equal(d
, 12.1), "d = %lf\n", d
);
1594 setlocale(LC_ALL
, "C");
1596 /* Precision tests */
1597 d
= strtod("0.1", NULL
);
1598 ok(almost_equal(d
, 0.1), "d = %lf\n", d
);
1599 d
= strtod("-0.1", NULL
);
1600 ok(almost_equal(d
, -0.1), "d = %lf\n", d
);
1601 d
= strtod("0.1281832188491894198128921", NULL
);
1602 ok(almost_equal(d
, 0.1281832188491894198128921), "d = %lf\n", d
);
1603 d
= strtod("0.82181281288121", NULL
);
1604 ok(almost_equal(d
, 0.82181281288121), "d = %lf\n", d
);
1605 d
= strtod("21921922352523587651128218821", NULL
);
1606 ok(almost_equal(d
, 21921922352523587651128218821.0), "d = %lf\n", d
);
1607 d
= strtod("0.1d238", NULL
);
1608 ok(almost_equal(d
, 0.1e238L
), "d = %lf\n", d
);
1609 d
= strtod("0.1D-4736", NULL
);
1610 ok(almost_equal(d
, 0.1e-4736L), "d = %lf\n", d
);
1613 strtod(overflow
, &end
);
1614 ok(errno
== ERANGE
, "errno = %x\n", errno
);
1615 ok(end
== overflow
+21, "incorrect end (%d)\n", (int)(end
-overflow
));
1618 strtod("-1d309", NULL
);
1619 ok(errno
== ERANGE
, "errno = %x\n", errno
);
1622 static void test_mbstowcs(void)
1624 static const wchar_t wSimple
[] = { 't','e','x','t',0 };
1625 static const wchar_t wHiragana
[] = { 0x3042,0x3043,0 };
1626 static const char mSimple
[] = "text";
1627 static const char mHiragana
[] = { 0x82,0xa0,0x82,0xa1,0 };
1629 const wchar_t *pwstr
;
1637 wOut
[4] = '!'; wOut
[5] = '\0';
1638 mOut
[4] = '!'; mOut
[5] = '\0';
1641 /* crashes on some systems */
1643 ret
= mbstowcs(wOut
, NULL
, 4);
1644 ok(ret
== -1, "mbstowcs did not return -1\n");
1645 ok(errno
== EINVAL
, "errno = %d\n", errno
);
1648 ret
= mbstowcs(NULL
, mSimple
, 0);
1649 ok(ret
== 4, "mbstowcs did not return 4\n");
1651 ret
= mbstowcs(wOut
, mSimple
, 4);
1652 ok(ret
== 4, "mbstowcs did not return 4\n");
1653 ok(!memcmp(wOut
, wSimple
, 4*sizeof(wchar_t)), "wOut = %s\n", wine_dbgstr_w(wOut
));
1654 ok(wOut
[4] == '!', "wOut[4] != \'!\'\n");
1656 ret
= wcstombs(NULL
, wSimple
, 0);
1657 ok(ret
== 4, "wcstombs did not return 4\n");
1659 ret
= wcstombs(mOut
, wSimple
, 6);
1660 ok(ret
== 4, "wcstombs did not return 4\n");
1661 ok(!memcmp(mOut
, mSimple
, 5*sizeof(char)), "mOut = %s\n", mOut
);
1663 ret
= wcstombs(mOut
, wSimple
, 2);
1664 ok(ret
== 2, "wcstombs did not return 2\n");
1665 ok(!memcmp(mOut
, mSimple
, 5*sizeof(char)), "mOut = %s\n", mOut
);
1667 if(!setlocale(LC_ALL
, "Japanese_Japan.932")) {
1668 win_skip("Japanese_Japan.932 locale not available\n");
1672 ret
= mbstowcs(wOut
, mHiragana
, 6);
1673 ok(ret
== 2, "mbstowcs did not return 2\n");
1674 ok(!memcmp(wOut
, wHiragana
, sizeof(wHiragana
)), "wOut = %s\n", wine_dbgstr_w(wOut
));
1676 ret
= wcstombs(mOut
, wHiragana
, 6);
1677 ok(ret
== 4, "wcstombs did not return 4\n");
1678 ok(!memcmp(mOut
, mHiragana
, sizeof(mHiragana
)), "mOut = %s\n", mOut
);
1680 if(!pmbstowcs_s
|| !pwcstombs_s
) {
1681 setlocale(LC_ALL
, "C");
1682 win_skip("mbstowcs_s or wcstombs_s not available\n");
1686 err
= pmbstowcs_s(&ret
, wOut
, 6, mSimple
, _TRUNCATE
);
1687 ok(err
== 0, "err = %d\n", err
);
1688 ok(ret
== 5, "mbstowcs_s did not return 5\n");
1689 ok(!memcmp(wOut
, wSimple
, sizeof(wSimple
)), "wOut = %s\n", wine_dbgstr_w(wOut
));
1691 err
= pmbstowcs_s(&ret
, wOut
, 6, mHiragana
, _TRUNCATE
);
1692 ok(err
== 0, "err = %d\n", err
);
1693 ok(ret
== 3, "mbstowcs_s did not return 3\n");
1694 ok(!memcmp(wOut
, wHiragana
, sizeof(wHiragana
)), "wOut = %s\n", wine_dbgstr_w(wOut
));
1696 err
= pmbstowcs_s(&ret
, NULL
, 0, mHiragana
, 1);
1697 ok(err
== 0, "err = %d\n", err
);
1698 ok(ret
== 3, "mbstowcs_s did not return 3\n");
1700 err
= pwcstombs_s(&ret
, mOut
, 6, wSimple
, _TRUNCATE
);
1701 ok(err
== 0, "err = %d\n", err
);
1702 ok(ret
== 5, "wcstombs_s did not return 5\n");
1703 ok(!memcmp(mOut
, mSimple
, sizeof(mSimple
)), "mOut = %s\n", mOut
);
1705 err
= pwcstombs_s(&ret
, mOut
, 6, wHiragana
, _TRUNCATE
);
1706 ok(err
== 0, "err = %d\n", err
);
1707 ok(ret
== 5, "wcstombs_s did not return 5\n");
1708 ok(!memcmp(mOut
, mHiragana
, sizeof(mHiragana
)), "mOut = %s\n", mOut
);
1710 err
= pwcstombs_s(&ret
, NULL
, 0, wHiragana
, 1);
1711 ok(err
== 0, "err = %d\n", err
);
1712 ok(ret
== 5, "wcstombs_s did not return 5\n");
1715 setlocale(LC_ALL
, "C");
1716 win_skip("wcsrtombs not available\n");
1722 ret
= pwcsrtombs(mOut
, &pwstr
, 4, &err
);
1723 ok(ret
== 4, "wcsrtombs did not return 4\n");
1724 ok(err
== 0, "err = %d\n", err
);
1725 ok(pwstr
== wSimple
+4, "pwstr = %p (wszSimple = %p)\n", pwstr
, wSimple
);
1726 ok(!memcmp(mOut
, mSimple
, ret
), "mOut = %s\n", mOut
);
1729 ret
= pwcsrtombs(mOut
, &pwstr
, 5, NULL
);
1730 ok(ret
== 4, "wcsrtombs did not return 4\n");
1731 ok(pwstr
== NULL
, "pwstr != NULL\n");
1732 ok(!memcmp(mOut
, mSimple
, sizeof(mSimple
)), "mOut = %s\n", mOut
);
1735 setlocale(LC_ALL
, "C");
1736 win_skip("mbsrtowcs not available\n");
1741 ret
= p_mbsrtowcs(wOut
, &pmbstr
, 6, NULL
);
1742 ok(ret
== 2, "mbsrtowcs did not return 2\n");
1743 ok(!memcmp(wOut
, wHiragana
, sizeof(wHiragana
)), "wOut = %s\n", wine_dbgstr_w(wOut
));
1744 ok(!pmbstr
, "pmbstr != NULL\n");
1746 state
= mHiragana
[0];
1747 pmbstr
= mHiragana
+1;
1748 ret
= p_mbsrtowcs(wOut
, &pmbstr
, 6, &state
);
1749 ok(ret
== 2, "mbsrtowcs did not return 2\n");
1750 ok(wOut
[0] == 0x3042, "wOut[0] = %x\n", wOut
[0]);
1751 ok(wOut
[1] == 0xff61, "wOut[1] = %x\n", wOut
[1]);
1752 ok(wOut
[2] == 0, "wOut[2] = %x\n", wOut
[2]);
1753 ok(!pmbstr
, "pmbstr != NULL\n");
1756 ret
= p_mbsrtowcs(wOut
, NULL
, 6, &state
);
1757 ok(ret
== -1, "mbsrtowcs did not return -1\n");
1758 ok(errno
== EINVAL
, "Expected errno to be EINVAL, got %d\n", errno
);
1760 setlocale(LC_ALL
, "C");
1763 static void test_gcvt(void)
1765 char buf
[1024], *res
;
1769 win_skip("Skipping _gcvt tests\n");
1774 res
= _gcvt(1.2, -1, buf
);
1775 ok(res
== NULL
, "res != NULL\n");
1776 ok(errno
== ERANGE
, "errno = %d\n", errno
);
1779 res
= _gcvt(1.2, 5, NULL
);
1780 ok(res
== NULL
, "res != NULL\n");
1781 ok(errno
== EINVAL
, "errno = %d\n", errno
);
1783 res
= gcvt(1.2, 5, buf
);
1784 ok(res
== buf
, "res != buf\n");
1785 ok(!strcmp(buf
, "1.2"), "buf = %s\n", buf
);
1788 err
= p_gcvt_s(buf
, 5, 1.2, 10);
1789 ok(err
== ERANGE
, "err = %d\n", err
);
1790 ok(buf
[0] == '\0', "buf[0] = %c\n", buf
[0]);
1793 err
= p_gcvt_s(buf
, 4, 123456, 2);
1794 ok(err
== ERANGE
, "err = %d\n", err
);
1795 ok(buf
[0] == '\0', "buf[0] = %c\n", buf
[0]);
1798 static void test__itoa_s(void)
1805 win_skip("Skipping _itoa_s tests\n");
1810 ret
= p_itoa_s(0, NULL
, 0, 0);
1811 ok(ret
== EINVAL
, "Expected _itoa_s to return EINVAL, got %d\n", ret
);
1812 ok(errno
== EINVAL
, "Expected errno to be EINVAL, got %d\n", errno
);
1814 memset(buffer
, 'X', sizeof(buffer
));
1816 ret
= p_itoa_s(0, buffer
, 0, 0);
1817 ok(ret
== EINVAL
, "Expected _itoa_s to return EINVAL, got %d\n", ret
);
1818 ok(errno
== EINVAL
, "Expected errno to be EINVAL, got %d\n", errno
);
1819 ok(buffer
[0] == 'X', "Expected the output buffer to be untouched\n");
1821 memset(buffer
, 'X', sizeof(buffer
));
1823 ret
= p_itoa_s(0, buffer
, sizeof(buffer
), 0);
1824 ok(ret
== EINVAL
, "Expected _itoa_s to return EINVAL, got %d\n", ret
);
1825 ok(errno
== EINVAL
, "Expected errno to be EINVAL, got %d\n", errno
);
1826 ok(buffer
[0] == '\0', "Expected the output buffer to be null terminated\n");
1828 memset(buffer
, 'X', sizeof(buffer
));
1830 ret
= p_itoa_s(0, buffer
, sizeof(buffer
), 64);
1831 ok(ret
== EINVAL
, "Expected _itoa_s to return EINVAL, got %d\n", ret
);
1832 ok(errno
== EINVAL
, "Expected errno to be EINVAL, got %d\n", errno
);
1833 ok(buffer
[0] == '\0', "Expected the output buffer to be null terminated\n");
1835 memset(buffer
, 'X', sizeof(buffer
));
1837 ret
= p_itoa_s(12345678, buffer
, 4, 10);
1838 ok(ret
== ERANGE
, "Expected _itoa_s to return ERANGE, got %d\n", ret
);
1839 ok(errno
== ERANGE
, "Expected errno to be ERANGE, got %d\n", errno
);
1840 ok(!memcmp(buffer
, "\000765", 4),
1841 "Expected the output buffer to be null terminated with truncated output\n");
1843 memset(buffer
, 'X', sizeof(buffer
));
1845 ret
= p_itoa_s(12345678, buffer
, 8, 10);
1846 ok(ret
== ERANGE
, "Expected _itoa_s to return ERANGE, got %d\n", ret
);
1847 ok(errno
== ERANGE
, "Expected errno to be ERANGE, got %d\n", errno
);
1848 ok(!memcmp(buffer
, "\0007654321", 8),
1849 "Expected the output buffer to be null terminated with truncated output\n");
1851 memset(buffer
, 'X', sizeof(buffer
));
1853 ret
= p_itoa_s(-12345678, buffer
, 9, 10);
1854 ok(ret
== ERANGE
, "Expected _itoa_s to return ERANGE, got %d\n", ret
);
1855 ok(errno
== ERANGE
, "Expected errno to be ERANGE, got %d\n", errno
);
1856 ok(!memcmp(buffer
, "\00087654321", 9),
1857 "Expected the output buffer to be null terminated with truncated output\n");
1859 ret
= p_itoa_s(12345678, buffer
, 9, 10);
1860 ok(ret
== 0, "Expected _itoa_s to return 0, got %d\n", ret
);
1861 ok(!strcmp(buffer
, "12345678"),
1862 "Expected output buffer string to be \"12345678\", got \"%s\"\n",
1865 ret
= p_itoa_s(43690, buffer
, sizeof(buffer
), 2);
1866 ok(ret
== 0, "Expected _itoa_s to return 0, got %d\n", ret
);
1867 ok(!strcmp(buffer
, "1010101010101010"),
1868 "Expected output buffer string to be \"1010101010101010\", got \"%s\"\n",
1871 ret
= p_itoa_s(1092009, buffer
, sizeof(buffer
), 36);
1872 ok(ret
== 0, "Expected _itoa_s to return 0, got %d\n", ret
);
1873 ok(!strcmp(buffer
, "nell"),
1874 "Expected output buffer string to be \"nell\", got \"%s\"\n",
1877 ret
= p_itoa_s(5704, buffer
, sizeof(buffer
), 18);
1878 ok(ret
== 0, "Expected _itoa_s to return 0, got %d\n", ret
);
1879 ok(!strcmp(buffer
, "hag"),
1880 "Expected output buffer string to be \"hag\", got \"%s\"\n",
1883 ret
= p_itoa_s(-12345678, buffer
, sizeof(buffer
), 10);
1884 ok(ret
== 0, "Expected _itoa_s to return 0, got %d\n", ret
);
1885 ok(!strcmp(buffer
, "-12345678"),
1886 "Expected output buffer string to be \"-12345678\", got \"%s\"\n",
1889 itoa(100, buffer
, 100);
1890 ok(!strcmp(buffer
, "10"),
1891 "Expected output buffer string to be \"10\", got \"%s\"\n", buffer
);
1894 static void test__strlwr_s(void)
1901 win_skip("Skipping _strlwr_s tests\n");
1906 ret
= p_strlwr_s(NULL
, 0);
1907 ok(ret
== EINVAL
, "Expected _strlwr_s to return EINVAL, got %d\n", ret
);
1908 ok(errno
== EINVAL
, "Expected errno to be EINVAL, got %d\n", errno
);
1911 ret
= p_strlwr_s(NULL
, sizeof(buffer
));
1912 ok(ret
== EINVAL
, "Expected _strlwr_s to return EINVAL, got %d\n", ret
);
1913 ok(errno
== EINVAL
, "Expected errno to be EINVAL, got %d\n", errno
);
1916 ret
= p_strlwr_s(buffer
, 0);
1917 ok(ret
== EINVAL
, "Expected _strlwr_s to return EINVAL, got %d\n", ret
);
1918 ok(errno
== EINVAL
, "Expected errno to be EINVAL, got %d\n", errno
);
1920 strcpy(buffer
, "GoRrIsTeR");
1922 ret
= p_strlwr_s(buffer
, 5);
1923 ok(ret
== EINVAL
, "Expected _strlwr_s to return EINVAL, got %d\n", ret
);
1924 ok(errno
== EINVAL
, "Expected errno to be EINVAL, got %d\n", errno
);
1925 ok(!memcmp(buffer
, "\0oRrIsTeR", sizeof("\0oRrIsTeR")),
1926 "Expected the output buffer to be \"\\0oRrIsTeR\"\n");
1928 strcpy(buffer
, "GoRrIsTeR");
1930 ret
= p_strlwr_s(buffer
, sizeof("GoRrIsTeR") - 1);
1931 ok(ret
== EINVAL
, "Expected _strlwr_s to return EINVAL, got %d\n", ret
);
1932 ok(errno
== EINVAL
, "Expected errno to be EINVAL, got %d\n", errno
);
1933 ok(!memcmp(buffer
, "\0oRrIsTeR", sizeof("\0oRrIsTeR")),
1934 "Expected the output buffer to be \"\\0oRrIsTeR\"\n");
1936 strcpy(buffer
, "GoRrIsTeR");
1937 ret
= p_strlwr_s(buffer
, sizeof("GoRrIsTeR"));
1938 ok(ret
== 0, "Expected _strlwr_s to return 0, got %d\n", ret
);
1939 ok(!strcmp(buffer
, "gorrister"),
1940 "Expected the output buffer to be \"gorrister\", got \"%s\"\n",
1943 memcpy(buffer
, "GoRrIsTeR\0ELLEN", sizeof("GoRrIsTeR\0ELLEN"));
1944 ret
= p_strlwr_s(buffer
, sizeof(buffer
));
1945 ok(ret
== 0, "Expected _strlwr_s to return 0, got %d\n", ret
);
1946 ok(!memcmp(buffer
, "gorrister\0ELLEN", sizeof("gorrister\0ELLEN")),
1947 "Expected the output buffer to be \"gorrister\\0ELLEN\", got \"%s\"\n",
1951 static void test_wcsncat_s(void)
1953 static wchar_t abcW
[] = {'a','b','c',0};
1960 win_skip("skipping wcsncat_s tests\n");
1964 memcpy(src
, abcW
, sizeof(abcW
));
1966 ret
= p_wcsncat_s(NULL
, 4, src
, 4);
1967 ok(ret
== EINVAL
, "err = %d\n", ret
);
1968 ret
= p_wcsncat_s(dst
, 0, src
, 4);
1969 ok(ret
== EINVAL
, "err = %d\n", ret
);
1970 ret
= p_wcsncat_s(dst
, 0, src
, _TRUNCATE
);
1971 ok(ret
== EINVAL
, "err = %d\n", ret
);
1972 ret
= p_wcsncat_s(dst
, 4, NULL
, 0);
1973 ok(ret
== 0, "err = %d\n", ret
);
1976 ret
= p_wcsncat_s(dst
, 2, src
, 4);
1977 ok(ret
== ERANGE
, "err = %d\n", ret
);
1980 ret
= p_wcsncat_s(dst
, 2, src
, _TRUNCATE
);
1981 ok(ret
== STRUNCATE
, "err = %d\n", ret
);
1982 ok(dst
[0] == 'a' && dst
[1] == 0, "dst is %s\n", wine_dbgstr_w(dst
));
1984 memcpy(dst
, abcW
, sizeof(abcW
));
1986 ret
= p_wcsncat_s(dst
, 4, src
, 4);
1987 ok(ret
== EINVAL
, "err = %d\n", ret
);
1990 static void test__mbsnbcat_s(void)
1992 unsigned char dest
[16];
1993 const unsigned char first
[] = "dinosaur";
1994 const unsigned char second
[] = "duck";
1999 win_skip("Skipping _mbsnbcat_s tests\n");
2003 /* Test invalid arguments. */
2004 ret
= p_mbsnbcat_s(NULL
, 0, NULL
, 0);
2005 ok(ret
== 0, "Expected _mbsnbcat_s to return 0, got %d\n", ret
);
2008 ret
= p_mbsnbcat_s(NULL
, 10, NULL
, 0);
2009 ok(ret
== EINVAL
, "Expected _mbsnbcat_s to return EINVAL, got %d\n", ret
);
2010 ok(errno
== EINVAL
, "Expected errno to be EINVAL, got %d\n", errno
);
2013 ret
= p_mbsnbcat_s(NULL
, 0, NULL
, 10);
2014 ok(ret
== EINVAL
, "Expected _mbsnbcat_s to return EINVAL, got %d\n", ret
);
2015 ok(errno
== EINVAL
, "Expected errno to be EINVAL, got %d\n", errno
);
2017 memset(dest
, 'X', sizeof(dest
));
2019 ret
= p_mbsnbcat_s(dest
, 0, NULL
, 0);
2020 ok(ret
== EINVAL
, "Expected _mbsnbcat_s to return EINVAL, got %d\n", ret
);
2021 ok(errno
== EINVAL
, "Expected errno to be EINVAL, got %d\n", errno
);
2022 ok(dest
[0] == 'X', "Expected the output buffer to be untouched\n");
2024 memset(dest
, 'X', sizeof(dest
));
2026 ret
= p_mbsnbcat_s(dest
, 0, second
, 0);
2027 ok(ret
== EINVAL
, "Expected _mbsnbcat_s to return EINVAL, got %d\n", ret
);
2028 ok(errno
== EINVAL
, "Expected errno to be EINVAL, got %d\n", errno
);
2029 ok(dest
[0] == 'X', "Expected the output buffer to be untouched\n");
2031 memset(dest
, 'X', sizeof(dest
));
2033 ret
= p_mbsnbcat_s(dest
, sizeof(dest
), NULL
, 0);
2034 ok(ret
== EINVAL
, "Expected _mbsnbcat_s to return EINVAL, got %d\n", ret
);
2035 ok(errno
== EINVAL
, "Expected errno to be EINVAL, got %d\n", errno
);
2036 ok(dest
[0] == '\0', "Expected the output buffer to be null terminated\n");
2038 memset(dest
, 'X', sizeof(dest
));
2040 ret
= p_mbsnbcat_s(dest
, sizeof(dest
), NULL
, 10);
2041 ok(ret
== EINVAL
, "Expected _mbsnbcat_s to return EINVAL, got %d\n", ret
);
2042 ok(errno
== EINVAL
, "Expected errno to be EINVAL, got %d\n", errno
);
2043 ok(dest
[0] == '\0', "Expected the output buffer to be null terminated\n");
2045 memset(dest
, 'X', sizeof(dest
));
2047 ret
= p_mbsnbcat_s(dest
, sizeof(dest
), second
, sizeof(second
));
2048 ok(ret
== 0, "Expected _mbsnbcat_s to return 0, got %d\n", ret
);
2049 ok(!memcmp(dest
, second
, sizeof(second
)),
2050 "Expected the output buffer string to be \"duck\"\n");
2052 /* Test source truncation behavior. */
2053 memset(dest
, 'X', sizeof(dest
));
2054 memcpy(dest
, first
, sizeof(first
));
2055 ret
= p_mbsnbcat_s(dest
, sizeof(dest
), second
, 0);
2056 ok(ret
== 0, "Expected _mbsnbcat_s to return 0, got %d\n", ret
);
2057 ok(!memcmp(dest
, first
, sizeof(first
)),
2058 "Expected the output buffer string to be \"dinosaur\"\n");
2060 memset(dest
, 'X', sizeof(dest
));
2061 memcpy(dest
, first
, sizeof(first
));
2062 ret
= p_mbsnbcat_s(dest
, sizeof(dest
), second
, sizeof(second
));
2063 ok(ret
== 0, "Expected _mbsnbcat_s to return 0, got %d\n", ret
);
2064 ok(!memcmp(dest
, "dinosaurduck", sizeof("dinosaurduck")),
2065 "Expected the output buffer string to be \"dinosaurduck\"\n");
2067 memset(dest
, 'X', sizeof(dest
));
2068 memcpy(dest
, first
, sizeof(first
));
2069 ret
= p_mbsnbcat_s(dest
, sizeof(dest
), second
, sizeof(second
) + 1);
2070 ok(ret
== 0, "Expected _mbsnbcat_s to return 0, got %d\n", ret
);
2071 ok(!memcmp(dest
, "dinosaurduck", sizeof("dinosaurduck")),
2072 "Expected the output buffer string to be \"dinosaurduck\"\n");
2074 memset(dest
, 'X', sizeof(dest
));
2075 memcpy(dest
, first
, sizeof(first
));
2076 ret
= p_mbsnbcat_s(dest
, sizeof(dest
), second
, sizeof(second
) - 1);
2077 ok(ret
== 0, "Expected _mbsnbcat_s to return 0, got %d\n", ret
);
2078 ok(!memcmp(dest
, "dinosaurduck", sizeof("dinosaurduck")),
2079 "Expected the output buffer string to be \"dinosaurduck\"\n");
2081 memset(dest
, 'X', sizeof(dest
));
2082 memcpy(dest
, first
, sizeof(first
));
2083 ret
= p_mbsnbcat_s(dest
, sizeof(dest
), second
, sizeof(second
) - 2);
2084 ok(ret
== 0, "Expected _mbsnbcat_s to return 0, got %d\n", ret
);
2085 ok(!memcmp(dest
, "dinosaurduc", sizeof("dinosaurduc")),
2086 "Expected the output buffer string to be \"dinosaurduc\"\n");
2088 /* Test destination truncation behavior. */
2089 memset(dest
, 'X', sizeof(dest
));
2090 memcpy(dest
, first
, sizeof(first
));
2092 ret
= p_mbsnbcat_s(dest
, sizeof(first
) - 1, second
, sizeof(second
));
2093 ok(ret
== EINVAL
, "Expected _mbsnbcat_s to return EINVAL, got %d\n", ret
);
2094 ok(errno
== EINVAL
, "Expected errno to be EINVAL, got %d\n", errno
);
2095 ok(!memcmp(dest
, "\0inosaur", sizeof("\0inosaur") - 1),
2096 "Expected the output buffer string to be \"\\0inosaur\" without ending null terminator\n");
2098 memset(dest
, 'X', sizeof(dest
));
2099 memcpy(dest
, first
, sizeof(first
));
2101 ret
= p_mbsnbcat_s(dest
, sizeof(first
), second
, sizeof(second
));
2102 ok(ret
== ERANGE
, "Expected _mbsnbcat_s to return ERANGE, got %d\n", ret
);
2103 ok(errno
== ERANGE
, "Expected errno to be ERANGE, got %d\n", errno
);
2104 ok(!memcmp(dest
, "\0inosaurd", sizeof("\0inosaurd") - 1),
2105 "Expected the output buffer string to be \"\\0inosaurd\" without ending null terminator\n");
2107 memset(dest
, 'X', sizeof(dest
));
2108 memcpy(dest
, first
, sizeof(first
));
2110 ret
= p_mbsnbcat_s(dest
, sizeof(first
) + 1, second
, sizeof(second
));
2111 ok(ret
== ERANGE
, "Expected _mbsnbcat_s to return ERANGE, got %d\n", ret
);
2112 ok(errno
== ERANGE
, "Expected errno to be ERANGE, got %d\n", errno
);
2113 ok(!memcmp(dest
, "\0inosaurdu", sizeof("\0inosaurdu") - 1),
2114 "Expected the output buffer string to be \"\\0inosaurdu\" without ending null terminator\n");
2117 static void test__mbsupr_s(void)
2120 unsigned char buffer
[20];
2124 win_skip("Skipping _mbsupr_s tests\n");
2129 ret
= p_mbsupr_s(NULL
, 0);
2130 ok(ret
== 0, "Expected _mbsupr_s to return 0, got %d\n", ret
);
2133 ret
= p_mbsupr_s(NULL
, sizeof(buffer
));
2134 ok(ret
== EINVAL
, "Expected _mbsupr_s to return EINVAL, got %d\n", ret
);
2135 ok(errno
== EINVAL
, "Expected errno to be EINVAL, got %d\n", errno
);
2138 ret
= p_mbsupr_s(buffer
, 0);
2139 ok(ret
== EINVAL
, "Expected _mbsupr_s to return EINVAL, got %d\n", ret
);
2140 ok(errno
== EINVAL
, "Expected errno to be EINVAL, got %d\n", errno
);
2142 memcpy(buffer
, "abcdefgh", sizeof("abcdefgh"));
2144 ret
= p_mbsupr_s(buffer
, sizeof("abcdefgh"));
2145 ok(ret
== 0, "Expected _mbsupr_s to return 0, got %d\n", ret
);
2146 ok(!memcmp(buffer
, "ABCDEFGH", sizeof("ABCDEFGH")),
2147 "Expected the output buffer to be \"ABCDEFGH\", got \"%s\"\n",
2150 memcpy(buffer
, "abcdefgh", sizeof("abcdefgh"));
2152 ret
= p_mbsupr_s(buffer
, sizeof(buffer
));
2153 ok(ret
== 0, "Expected _mbsupr_s to return 0, got %d\n", ret
);
2154 ok(!memcmp(buffer
, "ABCDEFGH", sizeof("ABCDEFGH")),
2155 "Expected the output buffer to be \"ABCDEFGH\", got \"%s\"\n",
2158 memcpy(buffer
, "abcdefgh", sizeof("abcdefgh"));
2160 ret
= p_mbsupr_s(buffer
, 4);
2161 ok(ret
== EINVAL
, "Expected _mbsupr_s to return EINVAL, got %d\n", ret
);
2162 ok(errno
== EINVAL
, "Expected errno to be EINVAL, got %d\n", errno
);
2164 memcpy(buffer
, "abcdefgh\0ijklmnop", sizeof("abcdefgh\0ijklmnop"));
2166 ret
= p_mbsupr_s(buffer
, sizeof(buffer
));
2167 ok(ret
== 0, "Expected _mbsupr_s to return 0, got %d\n", ret
);
2168 ok(!memcmp(buffer
, "ABCDEFGH\0ijklmnop", sizeof("ABCDEFGH\0ijklmnop")),
2169 "Expected the output buffer to be \"ABCDEFGH\\0ijklmnop\", got \"%s\"\n",
2174 static void test__mbslwr_s(void)
2177 unsigned char buffer
[20];
2181 win_skip("Skipping _mbslwr_s tests\n");
2186 ret
= p_mbslwr_s(NULL
, 0);
2187 ok(ret
== 0, "Expected _mbslwr_s to return 0, got %d\n", ret
);
2190 ret
= p_mbslwr_s(NULL
, sizeof(buffer
));
2191 ok(ret
== EINVAL
, "Expected _mbslwr_s to return EINVAL, got %d\n", ret
);
2192 ok(errno
== EINVAL
, "Expected errno to be EINVAL, got %d\n", errno
);
2195 ret
= p_mbslwr_s(buffer
, 0);
2196 ok(ret
== EINVAL
, "Expected _mbslwr_s to return EINVAL, got %d\n", ret
);
2197 ok(errno
== EINVAL
, "Expected errno to be EINVAL, got %d\n", errno
);
2199 memcpy(buffer
, "ABCDEFGH", sizeof("ABCDEFGH"));
2201 ret
= p_mbslwr_s(buffer
, sizeof("ABCDEFGH"));
2202 ok(ret
== 0, "Expected _mbslwr_s to return 0, got %d\n", ret
);
2203 ok(!memcmp(buffer
, "abcdefgh", sizeof("abcdefgh")),
2204 "Expected the output buffer to be \"abcdefgh\", got \"%s\"\n",
2207 memcpy(buffer
, "ABCDEFGH", sizeof("ABCDEFGH"));
2209 ret
= p_mbslwr_s(buffer
, sizeof(buffer
));
2210 ok(ret
== 0, "Expected _mbslwr_s to return 0, got %d\n", ret
);
2211 ok(!memcmp(buffer
, "abcdefgh", sizeof("abcdefgh")),
2212 "Expected the output buffer to be \"abcdefgh\", got \"%s\"\n",
2215 memcpy(buffer
, "ABCDEFGH", sizeof("ABCDEFGH"));
2217 ret
= p_mbslwr_s(buffer
, 4);
2218 ok(ret
== EINVAL
, "Expected _mbslwr_s to return EINVAL, got %d\n", ret
);
2219 ok(errno
== EINVAL
, "Expected errno to be EINVAL, got %d\n", errno
);
2221 memcpy(buffer
, "ABCDEFGH\0IJKLMNOP", sizeof("ABCDEFGH\0IJKLMNOP"));
2223 ret
= p_mbslwr_s(buffer
, sizeof(buffer
));
2224 ok(ret
== 0, "Expected _mbslwr_s to return 0, got %d\n", ret
);
2225 ok(!memcmp(buffer
, "abcdefgh\0IJKLMNOP", sizeof("abcdefgh\0IJKLMNOP")),
2226 "Expected the output buffer to be \"abcdefgh\\0IJKLMNOP\", got \"%s\"\n",
2230 static void test__mbstok(void)
2232 const unsigned char delim
[] = "t";
2234 char str
[] = "!.!test";
2239 ret
= _mbstok(NULL
, delim
);
2240 /* most versions of msvcrt use the same buffer for strtok and _mbstok */
2241 ok(!ret
|| broken((char*)ret
==str
+4),
2242 "_mbstok(NULL, \"t\") = %p, expected NULL (%p)\n", ret
, str
);
2244 ret
= _mbstok(NULL
, delim
);
2245 ok(!ret
, "_mbstok(NULL, \"t\") = %p, expected NULL\n", ret
);
2248 static void test__ultoa_s(void)
2255 win_skip("Skipping _ultoa_s tests\n");
2260 ret
= p_ultoa_s(0, NULL
, 0, 0);
2261 ok(ret
== EINVAL
, "Expected _ultoa_s to return EINVAL, got %d\n", ret
);
2262 ok(errno
== EINVAL
, "Expected errno to be EINVAL, got %d\n", errno
);
2264 memset(buffer
, 'X', sizeof(buffer
));
2266 ret
= p_ultoa_s(0, buffer
, 0, 0);
2267 ok(ret
== EINVAL
, "Expected _ultoa_s to return EINVAL, got %d\n", ret
);
2268 ok(errno
== EINVAL
, "Expected errno to be EINVAL, got %d\n", errno
);
2269 ok(buffer
[0] == 'X', "Expected the output buffer to be untouched\n");
2271 memset(buffer
, 'X', sizeof(buffer
));
2273 ret
= p_ultoa_s(0, buffer
, sizeof(buffer
), 0);
2274 ok(ret
== EINVAL
, "Expected _ultoa_s to return EINVAL, got %d\n", ret
);
2275 ok(errno
== EINVAL
, "Expected errno to be EINVAL, got %d\n", errno
);
2276 ok(buffer
[0] == '\0', "Expected the output buffer to be null terminated\n");
2278 memset(buffer
, 'X', sizeof(buffer
));
2280 ret
= p_ultoa_s(0, buffer
, sizeof(buffer
), 64);
2281 ok(ret
== EINVAL
, "Expected _ultoa_s to return EINVAL, got %d\n", ret
);
2282 ok(errno
== EINVAL
, "Expected errno to be EINVAL, got %d\n", errno
);
2283 ok(buffer
[0] == '\0', "Expected the output buffer to be null terminated\n");
2285 memset(buffer
, 'X', sizeof(buffer
));
2287 ret
= p_ultoa_s(12345678, buffer
, 4, 10);
2288 ok(ret
== ERANGE
, "Expected _ultoa_s to return ERANGE, got %d\n", ret
);
2289 ok(errno
== ERANGE
, "Expected errno to be ERANGE, got %d\n", errno
);
2290 ok(!memcmp(buffer
, "\000765", 4),
2291 "Expected the output buffer to be null terminated with truncated output\n");
2293 memset(buffer
, 'X', sizeof(buffer
));
2295 ret
= p_ultoa_s(12345678, buffer
, 8, 10);
2296 ok(ret
== ERANGE
, "Expected _ultoa_s to return ERANGE, got %d\n", ret
);
2297 ok(errno
== ERANGE
, "Expected errno to be ERANGE, got %d\n", errno
);
2298 ok(!memcmp(buffer
, "\0007654321", 8),
2299 "Expected the output buffer to be null terminated with truncated output\n");
2301 ret
= p_ultoa_s(12345678, buffer
, 9, 10);
2302 ok(ret
== 0, "Expected _ultoa_s to return 0, got %d\n", ret
);
2303 ok(!strcmp(buffer
, "12345678"),
2304 "Expected output buffer string to be \"12345678\", got \"%s\"\n",
2307 ret
= p_ultoa_s(43690, buffer
, sizeof(buffer
), 2);
2308 ok(ret
== 0, "Expected _ultoa_s to return 0, got %d\n", ret
);
2309 ok(!strcmp(buffer
, "1010101010101010"),
2310 "Expected output buffer string to be \"1010101010101010\", got \"%s\"\n",
2313 ret
= p_ultoa_s(1092009, buffer
, sizeof(buffer
), 36);
2314 ok(ret
== 0, "Expected _ultoa_s to return 0, got %d\n", ret
);
2315 ok(!strcmp(buffer
, "nell"),
2316 "Expected output buffer string to be \"nell\", got \"%s\"\n",
2319 ret
= p_ultoa_s(5704, buffer
, sizeof(buffer
), 18);
2320 ok(ret
== 0, "Expected _ultoa_s to return 0, got %d\n", ret
);
2321 ok(!strcmp(buffer
, "hag"),
2322 "Expected output buffer string to be \"hag\", got \"%s\"\n",
2326 static void test_wctob(void)
2330 if(!p_wctob
|| !setlocale(LC_ALL
, "chinese-traditional")) {
2331 win_skip("Skipping wctob tests\n");
2335 ret
= p_wctob(0x8141);
2336 ok(ret
== EOF
, "ret = %x\n", ret
);
2338 ret
= p_wctob(0x81);
2339 ok(ret
== EOF
, "ret = %x\n", ret
);
2341 ret
= p_wctob(0xe0);
2342 ok(ret
== 0x61, "ret = %x\n", ret
);
2345 ret
= p_wctob(0x81);
2346 ok(ret
== EOF
, "ret = %x\n", ret
);
2348 setlocale(LC_ALL
, "C");
2349 ret
= p_wctob(0x8141);
2350 ok(ret
== EOF
, "ret = %x\n", ret
);
2352 ret
= p_wctob(0x81);
2353 ok(ret
== (int)(char)0x81, "ret = %x\n", ret
);
2355 ret
= p_wctob(0x9f);
2356 ok(ret
== (int)(char)0x9f, "ret = %x\n", ret
);
2358 ret
= p_wctob(0xe0);
2359 ok(ret
== (int)(char)0xe0, "ret = %x\n", ret
);
2361 static void test_wctomb(void)
2364 unsigned char dst
[10];
2367 if(!p_wcrtomb
|| !setlocale(LC_ALL
, "Japanese_Japan.932")) {
2368 win_skip("wcrtomb tests\n");
2372 ret
= p_wcrtomb(NULL
, 0x3042, NULL
);
2373 ok(ret
== 2, "wcrtomb did not return 2\n");
2377 ret
= p_wcrtomb((char*)dst
, 0x3042, &state
);
2378 ok(ret
== 2, "wcrtomb did not return 2\n");
2379 ok(state
== 0, "state != 0\n");
2380 ok(dst
[0] == 0x82, "dst[0] = %x, expected 0x82\n", dst
[0]);
2381 ok(dst
[1] == 0xa0, "dst[1] = %x, expected 0xa0\n", dst
[1]);
2382 ok(dst
[2] == 'a', "dst[2] != 'a'\n");
2384 ret
= p_wcrtomb((char*)dst
, 0x3043, NULL
);
2385 ok(ret
== 2, "wcrtomb did not return 2\n");
2386 ok(dst
[0] == 0x82, "dst[0] = %x, expected 0x82\n", dst
[0]);
2387 ok(dst
[1] == 0xa1, "dst[1] = %x, expected 0xa1\n", dst
[1]);
2389 ret
= p_wcrtomb((char*)dst
, 0x20, NULL
);
2390 ok(ret
== 1, "wcrtomb did not return 1\n");
2391 ok(dst
[0] == 0x20, "dst[0] = %x, expected 0x20\n", dst
[0]);
2393 ret
= p_wcrtomb((char*)dst
, 0xffff, NULL
);
2394 ok(ret
== -1, "wcrtomb did not return -1\n");
2395 ok(dst
[0] == 0x3f, "dst[0] = %x, expected 0x3f\n", dst
[0]);
2397 setlocale(LC_ALL
, "C");
2400 static void test_tolower(void)
2405 /* test C locale when locale was never changed */
2406 ret
= p_tolower(0x41);
2407 ok(ret
== 0x61, "ret = %x\n", ret
);
2409 ret
= p_tolower(0xF4);
2410 ok(ret
== 0xF4, "ret = %x\n", ret
);
2413 ret
= p_tolower((char)0xF4);
2414 todo_wine
ok(ret
== (char)0xF4, "ret = %x\n", ret
);
2415 todo_wine
ok(errno
== 0xdeadbeef, "errno = %d\n", errno
);
2418 ret
= p_tolower((char)0xD0);
2419 todo_wine
ok(ret
== (char)0xD0, "ret = %x\n", ret
);
2420 todo_wine
ok(errno
== 0xdeadbeef, "errno = %d\n", errno
);
2422 /* test C locale after setting locale */
2423 if(!setlocale(LC_ALL
, "us")) {
2424 win_skip("skipping tolower tests that depends on locale\n");
2427 setlocale(LC_ALL
, "C");
2431 ret
= p_tolower(ch
);
2432 len
= LCMapStringA(0, LCMAP_LOWERCASE
, &ch
, 1, &lch
, 1);
2434 ok(ret
==(unsigned char)lch
|| broken(ret
==ch
)/*WinXP-*/, "ret = %x\n", ret
);
2436 ok(ret
== ch
, "ret = %x\n", ret
);
2437 if(!len
|| ret
==(unsigned char)lch
)
2438 ok(errno
== EILSEQ
, "errno = %d\n", errno
);
2442 ret
= p_tolower(ch
);
2443 len
= LCMapStringA(0, LCMAP_LOWERCASE
, &ch
, 1, &lch
, 1);
2445 ok(ret
==(unsigned char)lch
|| broken(ret
==ch
)/*WinXP-*/, "ret = %x\n", ret
);
2447 ok(ret
== ch
, "ret = %x\n", ret
);
2448 if(!len
|| ret
==(unsigned char)lch
)
2449 ok(errno
== EILSEQ
, "errno = %d\n", errno
);
2451 ret
= p_tolower(0xD0);
2452 ok(ret
== 0xD0, "ret = %x\n", ret
);
2454 ok(setlocale(LC_ALL
, "us") != NULL
, "setlocale failed\n");
2456 ret
= p_tolower((char)0xD0);
2457 ok(ret
== 0xF0, "ret = %x\n", ret
);
2459 ret
= p_tolower(0xD0);
2460 ok(ret
== 0xF0, "ret = %x\n", ret
);
2462 setlocale(LC_ALL
, "C");
2465 static void test__atodbl(void)
2472 /* Old versions of msvcrt use different values for _OVERFLOW and _UNDERFLOW
2473 * Because of this lets skip _atodbl tests when _atodbl_l is not available */
2474 win_skip("_atodbl_l is not available\n");
2479 ret
= p__atodbl_l(&d
, num
, NULL
);
2480 ok(ret
== 0, "_atodbl_l(&d, \"\", NULL) returned %d, expected 0\n", ret
);
2481 ok(d
.x
== 0, "d.x = %lf, expected 0\n", d
.x
);
2482 ret
= _atodbl(&d
, num
);
2483 ok(ret
== 0, "_atodbl(&d, \"\") returned %d, expected 0\n", ret
);
2484 ok(d
.x
== 0, "d.x = %lf, expected 0\n", d
.x
);
2487 ret
= p__atodbl_l(&d
, num
, NULL
);
2488 ok(ret
== 0, "_atodbl_l(&d, \"t\", NULL) returned %d, expected 0\n", ret
);
2489 ok(d
.x
== 0, "d.x = %lf, expected 0\n", d
.x
);
2490 ret
= _atodbl(&d
, num
);
2491 ok(ret
== 0, "_atodbl(&d, \"t\") returned %d, expected 0\n", ret
);
2492 ok(d
.x
== 0, "d.x = %lf, expected 0\n", d
.x
);
2495 ret
= p__atodbl_l(&d
, num
, NULL
);
2496 ok(ret
== 0, "_atodbl_l(&d, \"0\", NULL) returned %d, expected 0\n", ret
);
2497 ok(d
.x
== 0, "d.x = %lf, expected 0\n", d
.x
);
2498 ret
= _atodbl(&d
, num
);
2499 ok(ret
== 0, "_atodbl(&d, \"0\") returned %d, expected 0\n", ret
);
2500 ok(d
.x
== 0, "d.x = %lf, expected 0\n", d
.x
);
2503 ret
= p__atodbl_l(&d
, num
, NULL
);
2504 ok(ret
== 0, "_atodbl_l(&d, \"123\", NULL) returned %d, expected 0\n", ret
);
2505 ok(d
.x
== 123, "d.x = %lf, expected 123\n", d
.x
);
2506 ret
= _atodbl(&d
, num
);
2507 ok(ret
== 0, "_atodbl(&d, \"123\") returned %d, expected 0\n", ret
);
2508 ok(d
.x
== 123, "d.x = %lf, expected 123\n", d
.x
);
2510 strcpy(num
, "1e-309");
2511 ret
= p__atodbl_l(&d
, num
, NULL
);
2512 ok(ret
== _UNDERFLOW
, "_atodbl_l(&d, \"1e-309\", NULL) returned %d, expected _UNDERFLOW\n", ret
);
2513 ok(d
.x
!=0 && almost_equal(d
.x
, 0), "d.x = %le, expected 0\n", d
.x
);
2514 ret
= _atodbl(&d
, num
);
2515 ok(ret
== _UNDERFLOW
, "_atodbl(&d, \"1e-309\") returned %d, expected _UNDERFLOW\n", ret
);
2516 ok(d
.x
!=0 && almost_equal(d
.x
, 0), "d.x = %le, expected 0\n", d
.x
);
2518 strcpy(num
, "1e309");
2519 ret
= p__atodbl_l(&d
, num
, NULL
);
2520 ok(ret
== _OVERFLOW
, "_atodbl_l(&d, \"1e309\", NULL) returned %d, expected _OVERFLOW\n", ret
);
2521 ret
= _atodbl(&d
, num
);
2522 ok(ret
== _OVERFLOW
, "_atodbl(&d, \"1e309\") returned %d, expected _OVERFLOW\n", ret
);
2525 static void test__stricmp(void)
2529 ret
= _stricmp("test", "test");
2530 ok(ret
== 0, "_stricmp returned %d\n", ret
);
2531 ret
= _stricmp("a", "z");
2532 ok(ret
< 0, "_stricmp returned %d\n", ret
);
2533 ret
= _stricmp("z", "a");
2534 ok(ret
> 0, "_stricmp returned %d\n", ret
);
2535 ret
= _stricmp("\xa5", "\xb9");
2536 ok(ret
< 0, "_stricmp returned %d\n", ret
);
2538 if(!setlocale(LC_ALL
, "polish")) {
2539 win_skip("stricmp tests\n");
2543 ret
= _stricmp("test", "test");
2544 ok(ret
== 0, "_stricmp returned %d\n", ret
);
2545 ret
= _stricmp("a", "z");
2546 ok(ret
< 0, "_stricmp returned %d\n", ret
);
2547 ret
= _stricmp("z", "a");
2548 ok(ret
> 0, "_stricmp returned %d\n", ret
);
2549 ret
= _stricmp("\xa5", "\xb9");
2550 ok(ret
== 0, "_stricmp returned %d\n", ret
);
2552 setlocale(LC_ALL
, "C");
2555 static void test__wcstoi64(void)
2557 static const WCHAR digit
[] = { '9', 0 };
2558 static const WCHAR stock
[] = { 0x3231, 0 }; /* PARENTHESIZED IDEOGRAPH STOCK */
2559 static const WCHAR tamil
[] = { 0x0bef, 0 }; /* TAMIL DIGIT NINE */
2560 static const WCHAR thai
[] = { 0x0e59, 0 }; /* THAI DIGIT NINE */
2561 static const WCHAR fullwidth
[] = { 0xff19, 0 }; /* FULLWIDTH DIGIT NINE */
2562 static const WCHAR hex
[] = { 0xff19, 'f', 0x0e59, 0xff46, 0 };
2565 unsigned __int64 ures
;
2568 if (!p_wcstoi64
|| !p_wcstoui64
) {
2569 win_skip("_wcstoi64 or _wcstoui64 not found\n");
2573 res
= p_wcstoi64(digit
, NULL
, 10);
2574 ok(res
== 9, "res != 9\n");
2575 res
= p_wcstoi64(stock
, &endpos
, 10);
2576 ok(res
== 0, "res != 0\n");
2577 ok(endpos
== stock
, "Incorrect endpos (%p-%p)\n", stock
, endpos
);
2578 res
= p_wcstoi64(tamil
, &endpos
, 10);
2579 ok(res
== 0, "res != 0\n");
2580 ok(endpos
== tamil
, "Incorrect endpos (%p-%p)\n", tamil
, endpos
);
2581 res
= p_wcstoi64(thai
, NULL
, 10);
2582 todo_wine
ok(res
== 9, "res != 9\n");
2583 res
= p_wcstoi64(fullwidth
, NULL
, 10);
2584 todo_wine
ok(res
== 9, "res != 9\n");
2585 res
= p_wcstoi64(hex
, NULL
, 16);
2586 todo_wine
ok(res
== 0x9f9, "res != 0x9f9\n");
2588 ures
= p_wcstoui64(digit
, NULL
, 10);
2589 ok(ures
== 9, "ures != 9\n");
2590 ures
= p_wcstoui64(stock
, &endpos
, 10);
2591 ok(ures
== 0, "ures != 0\n");
2592 ok(endpos
== stock
, "Incorrect endpos (%p-%p)\n", stock
, endpos
);
2593 ures
= p_wcstoui64(tamil
, &endpos
, 10);
2594 ok(ures
== 0, "ures != 0\n");
2595 ok(endpos
== tamil
, "Incorrect endpos (%p-%p)\n", tamil
, endpos
);
2596 ures
= p_wcstoui64(thai
, NULL
, 10);
2597 todo_wine
ok(ures
== 9, "ures != 9\n");
2598 ures
= p_wcstoui64(fullwidth
, NULL
, 10);
2599 todo_wine
ok(ures
== 9, "ures != 9\n");
2600 ures
= p_wcstoui64(hex
, NULL
, 16);
2601 todo_wine
ok(ures
== 0x9f9, "ures != 0x9f9\n");
2606 static void test_atoi(void)
2611 ok(r
== 0, "atoi(0) = %d\n", r
);
2614 ok(r
== -1, "atoi(-1) = %d\n", r
);
2617 ok(r
== 1, "atoi(1) = %d\n", r
);
2619 r
= atoi("4294967296");
2620 ok(r
== 0, "atoi(4294967296) = %d\n", r
);
2623 static void test_strncpy(void)
2625 #define TEST_STRNCPY_LEN 10
2627 char dst
[TEST_STRNCPY_LEN
+ 1];
2628 char not_null_terminated
[] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '0'};
2630 /* strlen(src) > TEST_STRNCPY_LEN */
2631 ret
= strncpy(dst
, "01234567890123456789", TEST_STRNCPY_LEN
);
2632 ok(ret
== dst
, "ret != dst\n");
2633 ok(!strncmp(dst
, "0123456789", TEST_STRNCPY_LEN
), "dst != 0123456789\n");
2635 /* without null-terminated */
2636 ret
= strncpy(dst
, not_null_terminated
, TEST_STRNCPY_LEN
);
2637 ok(ret
== dst
, "ret != dst\n");
2638 ok(!strncmp(dst
, "0123456789", TEST_STRNCPY_LEN
), "dst != 0123456789\n");
2640 /* strlen(src) < TEST_STRNCPY_LEN */
2641 strcpy(dst
, "0123456789");
2642 ret
= strncpy(dst
, "012345", TEST_STRNCPY_LEN
);
2643 ok(ret
== dst
, "ret != dst\n");
2644 ok(!strcmp(dst
, "012345"), "dst != 012345\n");
2645 ok(dst
[TEST_STRNCPY_LEN
- 1] == '\0', "dst[TEST_STRNCPY_LEN - 1] != 0\n");
2647 /* strlen(src) == TEST_STRNCPY_LEN */
2648 ret
= strncpy(dst
, "0123456789", TEST_STRNCPY_LEN
);
2649 ok(ret
== dst
, "ret != dst\n");
2650 ok(!strncmp(dst
, "0123456789", TEST_STRNCPY_LEN
), "dst != 0123456789\n");
2653 static void test_strxfrm(void)
2658 /* crashes on old version of msvcrt */
2661 ret
= strxfrm(NULL
, "src", 1);
2662 ok(ret
== INT_MAX
, "ret = %d\n", (int)ret
);
2663 ok(errno
== EINVAL
, "errno = %d\n", errno
);
2666 ret
= strxfrm(dest
, NULL
, 100);
2667 ok(ret
== INT_MAX
, "ret = %d\n", (int)ret
);
2668 ok(errno
== EINVAL
, "errno = %d\n", errno
);
2671 ret
= strxfrm(NULL
, "src", 0);
2672 ok(ret
== 3, "ret = %d\n", (int)ret
);
2674 ret
= strxfrm(dest
, "src", 0);
2675 ok(ret
== 3, "ret = %d\n", (int)ret
);
2676 ok(dest
[0] == 'a', "dest[0] = %d\n", dest
[0]);
2679 ret
= strxfrm(dest
, "src", 5);
2680 ok(ret
== 3, "ret = %d\n", (int)ret
);
2681 ok(!strcmp(dest
, "src"), "dest = %s\n", dest
);
2685 ret
= strxfrm(dest
, "src", 1);
2686 ok(ret
== 3, "ret = %d\n", (int)ret
);
2687 ok(dest
[0] == 's', "dest[0] = %d\n", dest
[0]);
2688 ok(dest
[1] == 'a', "dest[1] = %d\n", dest
[1]);
2689 ok(errno
== 0xdeadbeef, "errno = %d\n", errno
);
2691 ret
= strxfrm(dest
, "", 5);
2692 ok(ret
== 0, "ret = %d\n", (int)ret
);
2693 ok(!dest
[0], "dest[0] = %d\n", dest
[0]);
2695 if(!setlocale(LC_ALL
, "polish")) {
2696 win_skip("stxfrm tests\n");
2700 ret
= strxfrm(NULL
, "src", 0);
2701 ok(ret
< sizeof(dest
)-1, "ret = %d\n", (int)ret
);
2703 ret
= strxfrm(dest
, "src", 0);
2704 ok(ret
< sizeof(dest
)-1, "ret = %d\n", (int)ret
);
2705 ok(dest
[0] == 'a', "dest[0] = %d\n", dest
[0]);
2707 ret
= strxfrm(dest
, "src", ret
+1);
2708 ok(ret
< sizeof(dest
)-1, "ret = %d\n", (int)ret
);
2709 ok(dest
[0], "dest[0] = 0\n");
2713 ret
= strxfrm(dest
, "src", 5);
2714 ok(ret
>5 && ret
<sizeof(dest
)-1, "ret = %d\n", (int)ret
);
2715 ok(!dest
[0] || broken(!p__atodbl_l
&& dest
[0]=='a'), "dest[0] = %d\n", dest
[0]);
2717 setlocale(LC_ALL
, "C");
2720 static void test__strnset_s(void)
2726 win_skip("_strnset_s not available\n");
2730 r
= p__strnset_s(NULL
, 0, 'a', 0);
2731 ok(r
== 0, "r = %d\n", r
);
2733 buf
[0] = buf
[1] = buf
[2] = 'b';
2734 r
= p__strnset_s(buf
, sizeof(buf
), 'a', 2);
2735 ok(r
== 0, "r = %d\n", r
);
2736 ok(!strcmp(buf
, "aab"), "buf = %s\n", buf
);
2738 r
= p__strnset_s(buf
, 0, 'a', 0);
2739 ok(r
== EINVAL
, "r = %d\n", r
);
2741 r
= p__strnset_s(NULL
, 0, 'a', 1);
2742 ok(r
== EINVAL
, "r = %d\n", r
);
2745 r
= p__strnset_s(buf
, sizeof(buf
)-1, 'c', 2);
2746 ok(r
== EINVAL
, "r = %d\n", r
);
2747 ok(!buf
[0] && buf
[1]=='c' && buf
[2]=='b', "buf = %s\n", buf
);
2753 static const char xilstring
[]="c:/xilinx";
2756 hMsvcrt
= GetModuleHandleA("msvcrt.dll");
2758 hMsvcrt
= GetModuleHandleA("msvcrtd.dll");
2759 ok(hMsvcrt
!= 0, "GetModuleHandleA failed\n");
2760 SET(pmemcpy
,"memcpy");
2761 p_memcpy_s
= (void*)GetProcAddress( hMsvcrt
, "memcpy_s" );
2762 p_memmove_s
= (void*)GetProcAddress( hMsvcrt
, "memmove_s" );
2763 SET(pmemcmp
,"memcmp");
2764 SET(p_mbctype
,"_mbctype");
2765 SET(p__mb_cur_max
,"__mb_cur_max");
2766 pstrcpy_s
= (void *)GetProcAddress( hMsvcrt
,"strcpy_s" );
2767 pstrcat_s
= (void *)GetProcAddress( hMsvcrt
,"strcat_s" );
2768 p_mbsnbcat_s
= (void *)GetProcAddress( hMsvcrt
,"_mbsnbcat_s" );
2769 p_mbsnbcpy_s
= (void *)GetProcAddress( hMsvcrt
,"_mbsnbcpy_s" );
2770 p__mbscpy_s
= (void *)GetProcAddress( hMsvcrt
,"_mbscpy_s" );
2771 p_wcscpy_s
= (void *)GetProcAddress( hMsvcrt
,"wcscpy_s" );
2772 p_wcsncpy_s
= (void *)GetProcAddress( hMsvcrt
,"wcsncpy_s" );
2773 p_wcsncat_s
= (void *)GetProcAddress( hMsvcrt
,"wcsncat_s" );
2774 p_wcsupr_s
= (void *)GetProcAddress( hMsvcrt
,"_wcsupr_s" );
2775 p_strnlen
= (void *)GetProcAddress( hMsvcrt
,"strnlen" );
2776 p_strtoi64
= (void *)GetProcAddress(hMsvcrt
, "_strtoi64");
2777 p_strtoui64
= (void *)GetProcAddress(hMsvcrt
, "_strtoui64");
2778 p_wcstoi64
= (void *)GetProcAddress(hMsvcrt
, "_wcstoi64");
2779 p_wcstoui64
= (void *)GetProcAddress(hMsvcrt
, "_wcstoui64");
2780 pmbstowcs_s
= (void *)GetProcAddress(hMsvcrt
, "mbstowcs_s");
2781 pwcstombs_s
= (void *)GetProcAddress(hMsvcrt
, "wcstombs_s");
2782 pwcsrtombs
= (void *)GetProcAddress(hMsvcrt
, "wcsrtombs");
2783 p_gcvt_s
= (void *)GetProcAddress(hMsvcrt
, "_gcvt_s");
2784 p_itoa_s
= (void *)GetProcAddress(hMsvcrt
, "_itoa_s");
2785 p_strlwr_s
= (void *)GetProcAddress(hMsvcrt
, "_strlwr_s");
2786 p_ultoa_s
= (void *)GetProcAddress(hMsvcrt
, "_ultoa_s");
2787 p_wcslwr_s
= (void*)GetProcAddress(hMsvcrt
, "_wcslwr_s");
2788 p_mbsupr_s
= (void*)GetProcAddress(hMsvcrt
, "_mbsupr_s");
2789 p_mbslwr_s
= (void*)GetProcAddress(hMsvcrt
, "_mbslwr_s");
2790 p_wctob
= (void*)GetProcAddress(hMsvcrt
, "wctob");
2791 p_wcrtomb
= (void*)GetProcAddress(hMsvcrt
, "wcrtomb");
2792 p_tolower
= (void*)GetProcAddress(hMsvcrt
, "tolower");
2793 p_mbrlen
= (void*)GetProcAddress(hMsvcrt
, "mbrlen");
2794 p_mbrtowc
= (void*)GetProcAddress(hMsvcrt
, "mbrtowc");
2795 p_mbsrtowcs
= (void*)GetProcAddress(hMsvcrt
, "mbsrtowcs");
2796 p__atodbl_l
= (void*)GetProcAddress(hMsvcrt
, "_atodbl_l");
2797 p__strnset_s
= (void*)GetProcAddress(hMsvcrt
, "_strnset_s");
2799 /* MSVCRT memcpy behaves like memmove for overlapping moves,
2800 MFC42 CString::Insert seems to rely on that behaviour */
2801 strcpy(mem
,xilstring
);
2802 nLen
=strlen(xilstring
);
2803 pmemcpy(mem
+5, mem
,nLen
+1);
2804 ok(pmemcmp(mem
+5,xilstring
, nLen
) == 0,
2805 "Got result %s\n",mem
+5);
2807 /* run tolower tests first */