ReactOS 0.4.17-dev-116-ga4b6fe9
string.c
Go to the documentation of this file.
1/* Unit test suite for string functions and some wcstring functions
2 *
3 * Copyright 2003 Thomas Mertes
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
18 *
19 * NOTES
20 * We use function pointers here as there is no import library for NTDLL on
21 * windows.
22 */
23
24#include <stdlib.h>
25#include <limits.h>
26#include <stdarg.h>
27
28#include "ntstatus.h"
29#define WIN32_NO_STATUS
30#include "windef.h"
31#include "winbase.h"
32#include "winternl.h"
33#include "winnls.h"
34#include "wine/test.h"
35
36
37/* Function ptrs for ntdll calls */
38static HMODULE hntdll = 0;
39static NTSTATUS (WINAPI *pRtlUnicodeStringToAnsiString)(STRING *, const UNICODE_STRING *, BOOLEAN);
40static VOID (WINAPI *pRtlFreeAnsiString)(PSTRING);
41static BOOLEAN (WINAPI *pRtlCreateUnicodeStringFromAsciiz)(PUNICODE_STRING,LPCSTR);
42static VOID (WINAPI *pRtlFreeUnicodeString)(PUNICODE_STRING);
43static WCHAR (WINAPI *pRtlUpcaseUnicodeChar)(WCHAR);
44
45static int (__cdecl *patoi)(const char *);
46static LONG (__cdecl *patol)(const char *);
47static LONGLONG (__cdecl *p_atoi64)(const char *);
48static LPSTR (__cdecl *p_itoa)(int, LPSTR, INT);
49static LPSTR (__cdecl *p_ltoa)(LONG, LPSTR, INT);
50static LPSTR (__cdecl *p_ultoa)(ULONG, LPSTR, INT);
51static LPSTR (__cdecl *p_i64toa)(LONGLONG, LPSTR, INT);
52static LPSTR (__cdecl *p_ui64toa)(ULONGLONG, LPSTR, INT);
53
54static int (__cdecl *p_wtoi)(LPCWSTR);
55static LONG (__cdecl *p_wtol)(LPCWSTR);
56static LONGLONG (__cdecl *p_wtoi64)(LPCWSTR);
57static LONG (__cdecl *pwcstol)(LPCWSTR,LPWSTR*,INT);
58static ULONG (__cdecl *pwcstoul)(LPCWSTR,LPWSTR*,INT);
59static LPWSTR (__cdecl *p_itow)(int, LPWSTR, int);
60static LPWSTR (__cdecl *p_ltow)(LONG, LPWSTR, INT);
61static LPWSTR (__cdecl *p_ultow)(ULONG, LPWSTR, INT);
62static LPWSTR (__cdecl *p_i64tow)(LONGLONG, LPWSTR, INT);
63static LPWSTR (__cdecl *p_ui64tow)(ULONGLONG, LPWSTR, INT);
64
65static LPWSTR (__cdecl *p_wcslwr)(LPWSTR);
66static LPWSTR (__cdecl *p_wcsupr)(LPWSTR);
67static WCHAR (__cdecl *ptowlower)(WCHAR);
68static WCHAR (__cdecl *ptowupper)(WCHAR);
71
72static LPWSTR (__cdecl *pwcschr)(LPCWSTR, WCHAR);
73static LPWSTR (__cdecl *pwcsrchr)(LPCWSTR, WCHAR);
74static void* (__cdecl *pmemchr)(const void*, int, size_t);
75
76static void (__cdecl *pqsort)(void *,size_t,size_t, int(__cdecl *compar)(const void *, const void *) );
77static void* (__cdecl *pbsearch)(void *,void*,size_t,size_t, int(__cdecl *compar)(const void *, const void *) );
78static int (WINAPIV *p_snprintf)(char *, size_t, const char *, ...);
79static int (WINAPIV *p_snprintf_s)(char *, size_t, size_t, const char *, ...);
80static int (WINAPIV *p_snwprintf)(WCHAR *, size_t, const WCHAR *, ...);
81static int (WINAPIV *p_snwprintf_s)(WCHAR *, size_t, size_t, const WCHAR *, ...);
82
83static int (__cdecl *ptolower)(int);
84static int (__cdecl *ptoupper)(int);
86
87static int (WINAPIV *psscanf)(const char *, const char *, ...);
88
89static int (__cdecl *piswctype)(WCHAR,unsigned short);
90static int (__cdecl *piswalpha)(WCHAR);
91static int (__cdecl *piswdigit)(WCHAR);
92static int (__cdecl *piswlower)(WCHAR);
93static int (__cdecl *piswspace)(WCHAR);
94static int (__cdecl *piswxdigit)(WCHAR);
95
96static int (__cdecl *pisalnum)(int);
97static int (__cdecl *pisalpha)(int);
98static int (__cdecl *piscntrl)(int);
99static int (__cdecl *pisdigit)(int);
100static int (__cdecl *pisgraph)(int);
101static int (__cdecl *pislower)(int);
102static int (__cdecl *pisprint)(int);
103static int (__cdecl *pispunct)(int);
104static int (__cdecl *pisspace)(int);
105static int (__cdecl *pisupper)(int);
106static int (__cdecl *pisxdigit)(int);
107
108static void InitFunctionPtrs(void)
109{
110 hntdll = LoadLibraryA("ntdll.dll");
111 ok(hntdll != 0, "LoadLibrary failed\n");
112#define X(name) p##name = (void *)GetProcAddress( hntdll, #name );
118 X(atoi);
119 X(atol);
120 X(_atoi64);
121 X(_itoa);
122 X(_ltoa);
123 X(_ultoa);
124 X(_i64toa);
125 X(_ui64toa);
126 X(_wtoi);
127 X(_wtol);
128 X(_wtoi64);
129 X(wcstol);
130 X(wcstoul);
131 X(_itow);
132 X(_ltow);
133 X(_ultow);
134 X(_i64tow);
135 X(_ui64tow);
136 X(_wcslwr);
137 X(_wcsupr);
138 X(towlower);
139 X(towupper);
140 X(_wcsicmp);
141 X(_wcsnicmp);
142 X(wcschr);
143 X(wcsrchr);
144 X(memchr);
145 X(qsort);
146 X(bsearch);
147 X(_snprintf);
148 X(_snprintf_s);
149 X(_snwprintf);
151 X(tolower);
152 X(toupper);
153 X(_strnicmp);
154 X(sscanf);
155 X(iswctype);
156 X(iswalpha);
157 X(iswdigit);
158 X(iswlower);
159 X(iswspace);
160 X(iswxdigit);
161 X(isalnum);
162 X(isalpha);
163 X(iscntrl);
164 X(isdigit);
165 X(isgraph);
166 X(islower);
167 X(isprint);
168 X(ispunct);
169 X(isspace);
170 X(isupper);
171 X(isxdigit);
172#undef X
173}
174
175
176#define LARGE_STRI_BUFFER_LENGTH 67
177
178typedef struct {
179 int base;
181 const char *Buffer;
182 int mask; /* ntdll/msvcrt: 0x01=itoa, 0x02=ltoa, 0x04=ultoa */
183 /* 0x10=itow, 0x20=ltow, 0x40=ultow */
185
186static const ulong2str_t ulong2str[] = {
187 {10, 123, "123\0---------------------------------------------------------------", 0x77},
188
189 { 2, 0x80000000U, "10000000000000000000000000000000\0----------------------------------", 0x67},
190 { 2, -2147483647, "10000000000000000000000000000001\0----------------------------------", 0x67},
191 { 2, -65537, "11111111111111101111111111111111\0----------------------------------", 0x67},
192 { 2, -65536, "11111111111111110000000000000000\0----------------------------------", 0x67},
193 { 2, -65535, "11111111111111110000000000000001\0----------------------------------", 0x67},
194 { 2, -32768, "11111111111111111000000000000000\0----------------------------------", 0x67},
195 { 2, -32767, "11111111111111111000000000000001\0----------------------------------", 0x67},
196 { 2, -2, "11111111111111111111111111111110\0----------------------------------", 0x67},
197 { 2, -1, "11111111111111111111111111111111\0----------------------------------", 0x67},
198 { 2, 0, "0\0-----------------------------------------------------------------", 0x77},
199 { 2, 1, "1\0-----------------------------------------------------------------", 0x77},
200 { 2, 10, "1010\0--------------------------------------------------------------", 0x77},
201 { 2, 100, "1100100\0-----------------------------------------------------------", 0x77},
202 { 2, 1000, "1111101000\0--------------------------------------------------------", 0x77},
203 { 2, 10000, "10011100010000\0----------------------------------------------------", 0x77},
204 { 2, 32767, "111111111111111\0---------------------------------------------------", 0x77},
205 { 2, 32768, "1000000000000000\0--------------------------------------------------", 0x77},
206 { 2, 65535, "1111111111111111\0--------------------------------------------------", 0x77},
207 { 2, 100000, "11000011010100000\0-------------------------------------------------", 0x77},
208 { 2, 234567, "111001010001000111\0------------------------------------------------", 0x77},
209 { 2, 300000, "1001001001111100000\0-----------------------------------------------", 0x77},
210 { 2, 524287, "1111111111111111111\0-----------------------------------------------", 0x77},
211 { 2, 524288, "10000000000000000000\0----------------------------------------------", 0x67},
212 { 2, 1000000, "11110100001001000000\0----------------------------------------------", 0x67},
213 { 2, 10000000, "100110001001011010000000\0------------------------------------------", 0x67},
214 { 2, 100000000, "101111101011110000100000000\0---------------------------------------", 0x67},
215 { 2, 1000000000, "111011100110101100101000000000\0------------------------------------", 0x67},
216 { 2, 1073741823, "111111111111111111111111111111\0------------------------------------", 0x67},
217 { 2, 2147483646, "1111111111111111111111111111110\0-----------------------------------", 0x67},
218 { 2, 2147483647, "1111111111111111111111111111111\0-----------------------------------", 0x67},
219 { 2, 2147483648U, "10000000000000000000000000000000\0----------------------------------", 0x67},
220 { 2, 2147483649U, "10000000000000000000000000000001\0----------------------------------", 0x67},
221 { 2, 4294967294U, "11111111111111111111111111111110\0----------------------------------", 0x67},
222 { 2, 0xFFFFFFFF, "11111111111111111111111111111111\0----------------------------------", 0x67},
223
224 { 8, 0x80000000U, "20000000000\0-------------------------------------------------------", 0x77},
225 { 8, -2147483647, "20000000001\0-------------------------------------------------------", 0x77},
226 { 8, -2, "37777777776\0-------------------------------------------------------", 0x77},
227 { 8, -1, "37777777777\0-------------------------------------------------------", 0x77},
228 { 8, 0, "0\0-----------------------------------------------------------------", 0x77},
229 { 8, 1, "1\0-----------------------------------------------------------------", 0x77},
230 { 8, 2147483646, "17777777776\0-------------------------------------------------------", 0x77},
231 { 8, 2147483647, "17777777777\0-------------------------------------------------------", 0x77},
232 { 8, 2147483648U, "20000000000\0-------------------------------------------------------", 0x77},
233 { 8, 2147483649U, "20000000001\0-------------------------------------------------------", 0x77},
234 { 8, 4294967294U, "37777777776\0-------------------------------------------------------", 0x77},
235 { 8, 4294967295U, "37777777777\0-------------------------------------------------------", 0x77},
236
237 {10, 0x80000000U, "-2147483648\0-------------------------------------------------------", 0x33},
238 {10, 0x80000000U, "2147483648\0--------------------------------------------------------", 0x44},
239 {10, -2147483647, "-2147483647\0-------------------------------------------------------", 0x33},
240 {10, -2147483647, "2147483649\0--------------------------------------------------------", 0x44},
241 {10, -2, "-2\0----------------------------------------------------------------", 0x33},
242 {10, -2, "4294967294\0--------------------------------------------------------", 0x44},
243 {10, -1, "-1\0----------------------------------------------------------------", 0x33},
244 {10, -1, "4294967295\0--------------------------------------------------------", 0x44},
245 {10, 0, "0\0-----------------------------------------------------------------", 0x77},
246 {10, 1, "1\0-----------------------------------------------------------------", 0x77},
247 {10, 12, "12\0----------------------------------------------------------------", 0x77},
248 {10, 123, "123\0---------------------------------------------------------------", 0x77},
249 {10, 1234, "1234\0--------------------------------------------------------------", 0x77},
250 {10, 12345, "12345\0-------------------------------------------------------------", 0x77},
251 {10, 123456, "123456\0------------------------------------------------------------", 0x77},
252 {10, 1234567, "1234567\0-----------------------------------------------------------", 0x77},
253 {10, 12345678, "12345678\0----------------------------------------------------------", 0x77},
254 {10, 123456789, "123456789\0---------------------------------------------------------", 0x77},
255 {10, 2147483646, "2147483646\0--------------------------------------------------------", 0x77},
256 {10, 2147483647, "2147483647\0--------------------------------------------------------", 0x77},
257 {10, 2147483648U, "-2147483648\0-------------------------------------------------------", 0x33},
258 {10, 2147483648U, "2147483648\0--------------------------------------------------------", 0x44},
259 {10, 2147483649U, "-2147483647\0-------------------------------------------------------", 0x33},
260 {10, 2147483649U, "2147483649\0--------------------------------------------------------", 0x44},
261 {10, 4294967294U, "-2\0----------------------------------------------------------------", 0x33},
262 {10, 4294967294U, "4294967294\0--------------------------------------------------------", 0x44},
263 {10, 4294967295U, "-1\0----------------------------------------------------------------", 0x33},
264 {10, 4294967295U, "4294967295\0--------------------------------------------------------", 0x44},
265
266 {16, 0, "0\0-----------------------------------------------------------------", 0x77},
267 {16, 1, "1\0-----------------------------------------------------------------", 0x77},
268 {16, 2147483646, "7ffffffe\0----------------------------------------------------------", 0x77},
269 {16, 2147483647, "7fffffff\0----------------------------------------------------------", 0x77},
270 {16, 0x80000000, "80000000\0----------------------------------------------------------", 0x77},
271 {16, 0x80000001, "80000001\0----------------------------------------------------------", 0x77},
272 {16, 0xFFFFFFFE, "fffffffe\0----------------------------------------------------------", 0x77},
273 {16, 0xFFFFFFFF, "ffffffff\0----------------------------------------------------------", 0x77},
274
275 { 2, 32768, "1000000000000000\0--------------------------------------------------", 0x77},
276 { 2, 65536, "10000000000000000\0-------------------------------------------------", 0x77},
277 { 2, 131072, "100000000000000000\0------------------------------------------------", 0x77},
278 {16, 0xffffffff, "ffffffff\0----------------------------------------------------------", 0x77},
279 {16, 0xa, "a\0-----------------------------------------------------------------", 0x77},
280 {16, 0, "0\0-----------------------------------------------------------------", 0x77},
281 {20, 3368421, "111111\0------------------------------------------------------------", 0x77},
282 {36, 62193781, "111111\0------------------------------------------------------------", 0x77},
283 {37, 71270178, "111111\0------------------------------------------------------------", 0x77},
284};
285
286
287static void one_itoa_test(int test_num, const ulong2str_t *ulong2str)
288{
289 char dest_str[LARGE_STRI_BUFFER_LENGTH + 1];
290 int value;
292
293 memset(dest_str, '-', LARGE_STRI_BUFFER_LENGTH);
294 dest_str[LARGE_STRI_BUFFER_LENGTH] = '\0';
296 result = p_itoa(value, dest_str, ulong2str->base);
297 ok(result == dest_str,
298 "(test %d): _itoa(%d, [out], %d) has result %p, expected: %p\n",
299 test_num, value, ulong2str->base, result, dest_str);
301 "(test %d): _itoa(%d, [out], %d) assigns string \"%s\", expected: \"%s\"\n",
302 test_num, value, ulong2str->base, dest_str, ulong2str->Buffer);
303}
304
305
306static void one_ltoa_test(int test_num, const ulong2str_t *ulong2str)
307{
308 char dest_str[LARGE_STRI_BUFFER_LENGTH + 1];
309 LONG value;
311
312 memset(dest_str, '-', LARGE_STRI_BUFFER_LENGTH);
313 dest_str[LARGE_STRI_BUFFER_LENGTH] = '\0';
315 result = p_ltoa(ulong2str->value, dest_str, ulong2str->base);
316 ok(result == dest_str,
317 "(test %d): _ltoa(%ld, [out], %d) has result %p, expected: %p\n",
318 test_num, value, ulong2str->base, result, dest_str);
320 "(test %d): _ltoa(%ld, [out], %d) assigns string \"%s\", expected: \"%s\"\n",
321 test_num, value, ulong2str->base, dest_str, ulong2str->Buffer);
322}
323
324
325static void one_ultoa_test(int test_num, const ulong2str_t *ulong2str)
326{
327 char dest_str[LARGE_STRI_BUFFER_LENGTH + 1];
328 ULONG value;
330
331 memset(dest_str, '-', LARGE_STRI_BUFFER_LENGTH);
332 dest_str[LARGE_STRI_BUFFER_LENGTH] = '\0';
334 result = p_ultoa(ulong2str->value, dest_str, ulong2str->base);
335 ok(result == dest_str,
336 "(test %d): _ultoa(%lu, [out], %d) has result %p, expected: %p\n",
337 test_num, value, ulong2str->base, result, dest_str);
339 "(test %d): _ultoa(%lu, [out], %d) assigns string \"%s\", expected: \"%s\"\n",
340 test_num, value, ulong2str->base, dest_str, ulong2str->Buffer);
341}
342
343
344static void test_ulongtoa(void)
345{
346 int test_num;
347
348 for (test_num = 0; test_num < ARRAY_SIZE(ulong2str); test_num++) {
349 if (ulong2str[test_num].mask & 0x01) {
350 one_itoa_test(test_num, &ulong2str[test_num]);
351 } /* if */
352 if (ulong2str[test_num].mask & 0x02) {
353 one_ltoa_test(test_num, &ulong2str[test_num]);
354 } /* if */
355 if (ulong2str[test_num].mask & 0x04) {
356 one_ultoa_test(test_num, &ulong2str[test_num]);
357 } /* if */
358 } /* for */
359}
360
361
362static void one_itow_test(int test_num, const ulong2str_t *ulong2str)
363{
364 int pos;
365 WCHAR expected_wstr[LARGE_STRI_BUFFER_LENGTH + 1];
366 WCHAR dest_wstr[LARGE_STRI_BUFFER_LENGTH + 1];
367 UNICODE_STRING unicode_string;
368 STRING ansi_str;
369 int value;
371
372 for (pos = 0; pos < LARGE_STRI_BUFFER_LENGTH; pos++) {
373 expected_wstr[pos] = ulong2str->Buffer[pos];
374 } /* for */
375 expected_wstr[LARGE_STRI_BUFFER_LENGTH] = '\0';
376
377 for (pos = 0; pos < LARGE_STRI_BUFFER_LENGTH; pos++) {
378 dest_wstr[pos] = '-';
379 } /* for */
380 dest_wstr[LARGE_STRI_BUFFER_LENGTH] = '\0';
381 unicode_string.Length = LARGE_STRI_BUFFER_LENGTH * sizeof(WCHAR);
382 unicode_string.MaximumLength = unicode_string.Length + sizeof(WCHAR);
383 unicode_string.Buffer = dest_wstr;
385 result = p_itow(value, dest_wstr, ulong2str->base);
386 pRtlUnicodeStringToAnsiString(&ansi_str, &unicode_string, 1);
387 ok(result == dest_wstr,
388 "(test %d): _itow(%d, [out], %d) has result %p, expected: %p\n",
389 test_num, value, ulong2str->base, result, dest_wstr);
390 ok(memcmp(dest_wstr, expected_wstr, LARGE_STRI_BUFFER_LENGTH * sizeof(WCHAR)) == 0,
391 "(test %d): _itow(%d, [out], %d) assigns string \"%s\", expected: \"%s\"\n",
392 test_num, value, ulong2str->base, ansi_str.Buffer, ulong2str->Buffer);
393 pRtlFreeAnsiString(&ansi_str);
394}
395
396
397static void one_ltow_test(int test_num, const ulong2str_t *ulong2str)
398{
399 int pos;
400 WCHAR expected_wstr[LARGE_STRI_BUFFER_LENGTH + 1];
401 WCHAR dest_wstr[LARGE_STRI_BUFFER_LENGTH + 1];
402 UNICODE_STRING unicode_string;
403 STRING ansi_str;
404 LONG value;
406
407 for (pos = 0; pos < LARGE_STRI_BUFFER_LENGTH; pos++) {
408 expected_wstr[pos] = ulong2str->Buffer[pos];
409 } /* for */
410 expected_wstr[LARGE_STRI_BUFFER_LENGTH] = '\0';
411
412 for (pos = 0; pos < LARGE_STRI_BUFFER_LENGTH; pos++) {
413 dest_wstr[pos] = '-';
414 } /* for */
415 dest_wstr[LARGE_STRI_BUFFER_LENGTH] = '\0';
416 unicode_string.Length = LARGE_STRI_BUFFER_LENGTH * sizeof(WCHAR);
417 unicode_string.MaximumLength = unicode_string.Length + sizeof(WCHAR);
418 unicode_string.Buffer = dest_wstr;
419
421 result = p_ltow(value, dest_wstr, ulong2str->base);
422 pRtlUnicodeStringToAnsiString(&ansi_str, &unicode_string, 1);
423 ok(result == dest_wstr,
424 "(test %d): _ltow(%ld, [out], %d) has result %p, expected: %p\n",
425 test_num, value, ulong2str->base, result, dest_wstr);
426 ok(memcmp(dest_wstr, expected_wstr, LARGE_STRI_BUFFER_LENGTH * sizeof(WCHAR)) == 0,
427 "(test %d): _ltow(%ld, [out], %d) assigns string \"%s\", expected: \"%s\"\n",
428 test_num, value, ulong2str->base, ansi_str.Buffer, ulong2str->Buffer);
429 pRtlFreeAnsiString(&ansi_str);
430}
431
432
433static void one_ultow_test(int test_num, const ulong2str_t *ulong2str)
434{
435 int pos;
436 WCHAR expected_wstr[LARGE_STRI_BUFFER_LENGTH + 1];
437 WCHAR dest_wstr[LARGE_STRI_BUFFER_LENGTH + 1];
438 UNICODE_STRING unicode_string;
439 STRING ansi_str;
440 ULONG value;
442
443 for (pos = 0; pos < LARGE_STRI_BUFFER_LENGTH; pos++) {
444 expected_wstr[pos] = ulong2str->Buffer[pos];
445 } /* for */
446 expected_wstr[LARGE_STRI_BUFFER_LENGTH] = '\0';
447
448 for (pos = 0; pos < LARGE_STRI_BUFFER_LENGTH; pos++) {
449 dest_wstr[pos] = '-';
450 } /* for */
451 dest_wstr[LARGE_STRI_BUFFER_LENGTH] = '\0';
452 unicode_string.Length = LARGE_STRI_BUFFER_LENGTH * sizeof(WCHAR);
453 unicode_string.MaximumLength = unicode_string.Length + sizeof(WCHAR);
454 unicode_string.Buffer = dest_wstr;
455
457 result = p_ultow(value, dest_wstr, ulong2str->base);
458 pRtlUnicodeStringToAnsiString(&ansi_str, &unicode_string, 1);
459 ok(result == dest_wstr,
460 "(test %d): _ultow(%lu, [out], %d) has result %p, expected: %p\n",
461 test_num, value, ulong2str->base, result, dest_wstr);
462 ok(memcmp(dest_wstr, expected_wstr, LARGE_STRI_BUFFER_LENGTH * sizeof(WCHAR)) == 0,
463 "(test %d): _ultow(%lu, [out], %d) assigns string \"%s\", expected: \"%s\"\n",
464 test_num, value, ulong2str->base, ansi_str.Buffer, ulong2str->Buffer);
465 pRtlFreeAnsiString(&ansi_str);
466}
467
468
469static void test_ulongtow(void)
470{
471 int test_num;
473
474 for (test_num = 0; test_num < ARRAY_SIZE(ulong2str); test_num++) {
475 if (ulong2str[test_num].mask & 0x10) {
476 one_itow_test(test_num, &ulong2str[test_num]);
477 } /* if */
478 if (ulong2str[test_num].mask & 0x20) {
479 one_ltow_test(test_num, &ulong2str[test_num]);
480 } /* if */
481 if (ulong2str[test_num].mask & 0x40) {
482 one_ultow_test(test_num, &ulong2str[test_num]);
483 } /* if */
484 } /* for */
485
486 if (0) {
487 /* Crashes on XP and W2K3 */
488 result = p_itow(ulong2str[0].value, NULL, 10);
489 ok(result == NULL,
490 "(test a): _itow(%ld, NULL, 10) has result %p, expected: NULL\n",
492 }
493
494 if (0) {
495 /* Crashes on XP and W2K3 */
496 result = p_ltow(ulong2str[0].value, NULL, 10);
497 ok(result == NULL,
498 "(test b): _ltow(%ld, NULL, 10) has result %p, expected: NULL\n",
500 }
501
502 if (0) {
503 /* Crashes on XP and W2K3 */
504 result = p_ultow(ulong2str[0].value, NULL, 10);
505 ok(result == NULL,
506 "(test c): _ultow(%ld, NULL, 10) has result %p, expected: NULL\n",
508 }
509}
510
511#define ULL(a,b) (((ULONGLONG)(a) << 32) | (b))
512
513typedef struct {
514 int base;
516 const char *Buffer;
517 int mask; /* ntdll/msvcrt: 0x01=i64toa, 0x02=ui64toa, 0x04=wrong _i64toa try next example */
518 /* 0x10=i64tow, 0x20=ui64tow, 0x40=wrong _i64tow try next example */
520
522 {10, 123, "123\0---------------------------------------------------------------", 0x33},
523
524 { 2, 0x80000000U, "10000000000000000000000000000000\0----------------------------------", 0x33},
525 { 2, -2147483647, "1111111111111111111111111111111110000000000000000000000000000001\0--", 0x33},
526 { 2, -65537, "1111111111111111111111111111111111111111111111101111111111111111\0--", 0x33},
527 { 2, -65536, "1111111111111111111111111111111111111111111111110000000000000000\0--", 0x33},
528 { 2, -65535, "1111111111111111111111111111111111111111111111110000000000000001\0--", 0x33},
529 { 2, -32768, "1111111111111111111111111111111111111111111111111000000000000000\0--", 0x33},
530 { 2, -32767, "1111111111111111111111111111111111111111111111111000000000000001\0--", 0x33},
531 { 2, -2, "1111111111111111111111111111111111111111111111111111111111111110\0--", 0x33},
532 { 2, -1, "1111111111111111111111111111111111111111111111111111111111111111\0--", 0x33},
533 { 2, 0, "0\0-----------------------------------------------------------------", 0x33},
534 { 2, 1, "1\0-----------------------------------------------------------------", 0x33},
535 { 2, 10, "1010\0--------------------------------------------------------------", 0x33},
536 { 2, 100, "1100100\0-----------------------------------------------------------", 0x33},
537 { 2, 1000, "1111101000\0--------------------------------------------------------", 0x33},
538 { 2, 10000, "10011100010000\0----------------------------------------------------", 0x33},
539 { 2, 32767, "111111111111111\0---------------------------------------------------", 0x33},
540 { 2, 32768, "1000000000000000\0--------------------------------------------------", 0x33},
541 { 2, 65535, "1111111111111111\0--------------------------------------------------", 0x33},
542 { 2, 100000, "11000011010100000\0-------------------------------------------------", 0x33},
543 { 2, 234567, "111001010001000111\0------------------------------------------------", 0x33},
544 { 2, 300000, "1001001001111100000\0-----------------------------------------------", 0x33},
545 { 2, 524287, "1111111111111111111\0-----------------------------------------------", 0x33},
546 { 2, 524288, "10000000000000000000\0----------------------------------------------", 0x33},
547 { 2, 1000000, "11110100001001000000\0----------------------------------------------", 0x33},
548 { 2, 10000000, "100110001001011010000000\0------------------------------------------", 0x33},
549 { 2, 100000000, "101111101011110000100000000\0---------------------------------------", 0x33},
550 { 2, 1000000000, "111011100110101100101000000000\0------------------------------------", 0x33},
551 { 2, 1073741823, "111111111111111111111111111111\0------------------------------------", 0x33},
552 { 2, 2147483646, "1111111111111111111111111111110\0-----------------------------------", 0x33},
553 { 2, 2147483647, "1111111111111111111111111111111\0-----------------------------------", 0x33},
554 { 2, 2147483648U, "10000000000000000000000000000000\0----------------------------------", 0x33},
555 { 2, 2147483649U, "10000000000000000000000000000001\0----------------------------------", 0x33},
556 { 2, 4294967294U, "11111111111111111111111111111110\0----------------------------------", 0x33},
557 { 2, 0xFFFFFFFF, "11111111111111111111111111111111\0----------------------------------", 0x33},
558 { 2, ULL(0x1,0xffffffff), "111111111111111111111111111111111\0---------------------------------", 0x33},
559 { 2, ((ULONGLONG)100000)*100000, "1001010100000010111110010000000000\0--------------------------------", 0x33},
560 { 2, ULL(0x3,0xffffffff), "1111111111111111111111111111111111\0--------------------------------", 0x33},
561 { 2, ULL(0x7,0xffffffff), "11111111111111111111111111111111111\0-------------------------------", 0x33},
562 { 2, ULL(0xf,0xffffffff), "111111111111111111111111111111111111\0------------------------------", 0x33},
563 { 2, ((ULONGLONG)100000)*1000000, "1011101001000011101101110100000000000\0-----------------------------", 0x33},
564 { 2, ULL(0x1f,0xffffffff), "1111111111111111111111111111111111111\0-----------------------------", 0x33},
565 { 2, ULL(0x3f,0xffffffff), "11111111111111111111111111111111111111\0----------------------------", 0x33},
566 { 2, ULL(0x7f,0xffffffff), "111111111111111111111111111111111111111\0---------------------------", 0x33},
567 { 2, ULL(0xff,0xffffffff), "1111111111111111111111111111111111111111\0--------------------------", 0x33},
568
569 { 8, 0x80000000U, "20000000000\0-------------------------------------------------------", 0x33},
570 { 8, -2147483647, "1777777777760000000001\0--------------------------------------------", 0x33},
571 { 8, -2, "1777777777777777777776\0--------------------------------------------", 0x33},
572 { 8, -1, "1777777777777777777777\0--------------------------------------------", 0x33},
573 { 8, 0, "0\0-----------------------------------------------------------------", 0x33},
574 { 8, 1, "1\0-----------------------------------------------------------------", 0x33},
575 { 8, 2147483646, "17777777776\0-------------------------------------------------------", 0x33},
576 { 8, 2147483647, "17777777777\0-------------------------------------------------------", 0x33},
577 { 8, 2147483648U, "20000000000\0-------------------------------------------------------", 0x33},
578 { 8, 2147483649U, "20000000001\0-------------------------------------------------------", 0x33},
579 { 8, 4294967294U, "37777777776\0-------------------------------------------------------", 0x33},
580 { 8, 4294967295U, "37777777777\0-------------------------------------------------------", 0x33},
581
582 {10, 0x80000000U, "2147483648\0--------------------------------------------------------", 0x33},
583 {10, -2147483647, "-2147483647\0-------------------------------------------------------", 0x55},
584 {10, -2147483647, "-18446744071562067969\0---------------------------------------------", 0x00},
585 {10, -2147483647, "18446744071562067969\0----------------------------------------------", 0x22},
586 {10, -2, "-2\0----------------------------------------------------------------", 0x55},
587 {10, -2, "-18446744073709551614\0---------------------------------------------", 0x00},
588 {10, -2, "18446744073709551614\0----------------------------------------------", 0x22},
589 {10, -1, "-1\0----------------------------------------------------------------", 0x55},
590 {10, -1, "-18446744073709551615\0---------------------------------------------", 0x00},
591 {10, -1, "18446744073709551615\0----------------------------------------------", 0x22},
592 {10, 0, "0\0-----------------------------------------------------------------", 0x33},
593 {10, 1, "1\0-----------------------------------------------------------------", 0x33},
594 {10, 12, "12\0----------------------------------------------------------------", 0x33},
595 {10, 123, "123\0---------------------------------------------------------------", 0x33},
596 {10, 1234, "1234\0--------------------------------------------------------------", 0x33},
597 {10, 12345, "12345\0-------------------------------------------------------------", 0x33},
598 {10, 123456, "123456\0------------------------------------------------------------", 0x33},
599 {10, 1234567, "1234567\0-----------------------------------------------------------", 0x33},
600 {10, 12345678, "12345678\0----------------------------------------------------------", 0x33},
601 {10, 123456789, "123456789\0---------------------------------------------------------", 0x33},
602 {10, 2147483646, "2147483646\0--------------------------------------------------------", 0x33},
603 {10, 2147483647, "2147483647\0--------------------------------------------------------", 0x33},
604 {10, 2147483648U, "2147483648\0--------------------------------------------------------", 0x33},
605 {10, 2147483649U, "2147483649\0--------------------------------------------------------", 0x33},
606 {10, 4294967294U, "4294967294\0--------------------------------------------------------", 0x33},
607 {10, 4294967295U, "4294967295\0--------------------------------------------------------", 0x33},
608 {10, ULL(0x2,0xdfdc1c35), "12345678901\0-------------------------------------------------------", 0x33},
609 {10, ULL(0xe5,0xf4c8f374), "987654321012\0------------------------------------------------------", 0x33},
610 {10, ULL(0x1c0,0xfc161e3e), "1928374656574\0-----------------------------------------------------", 0x33},
611 {10, ULL(0xbad,0xcafeface), "12841062955726\0----------------------------------------------------", 0x33},
612 {10, ULL(0x5bad,0xcafeface), "100801993177806\0---------------------------------------------------", 0x33},
613 {10, ULL(0xaface,0xbeefcafe), "3090515640699646\0--------------------------------------------------", 0x33},
614 {10, ULL(0xa5beef,0xabcdcafe), "46653307746110206\0-------------------------------------------------", 0x33},
615 {10, ULL(0x1f8cf9b,0xf2df3af1), "142091656963767025\0------------------------------------------------", 0x33},
616 {10, ULL(0x0fffffff,0xffffffff), "1152921504606846975\0-----------------------------------------------", 0x33},
617 {10, ULL(0x7fffffff,0xffffffff), "9223372036854775807\0-----------------------------------------------", 0x33},
618 {10, ULL(0x80000000,0x00000000), "-9223372036854775808\0----------------------------------------------", 0x11},
619 {10, ULL(0x80000000,0x00000000), "9223372036854775808\0-----------------------------------------------", 0x22},
620 {10, ULL(0x80000000,0x00000001), "-9223372036854775807\0----------------------------------------------", 0x55},
621 {10, ULL(0x80000000,0x00000001), "-9223372036854775809\0----------------------------------------------", 0x00},
622 {10, ULL(0x80000000,0x00000001), "9223372036854775809\0-----------------------------------------------", 0x22},
623 {10, ULL(0x80000000,0x00000002), "-9223372036854775806\0----------------------------------------------", 0x55},
624 {10, ULL(0x80000000,0x00000002), "-9223372036854775810\0----------------------------------------------", 0x00},
625 {10, ULL(0x80000000,0x00000002), "9223372036854775810\0-----------------------------------------------", 0x22},
626 {10, ULL(0xffffffff,0xfffffffe), "-2\0----------------------------------------------------------------", 0x55},
627 {10, ULL(0xffffffff,0xfffffffe), "-18446744073709551614\0---------------------------------------------", 0x00},
628 {10, ULL(0xffffffff,0xfffffffe), "18446744073709551614\0----------------------------------------------", 0x22},
629 {10, ULL(0xffffffff,0xffffffff), "-1\0----------------------------------------------------------------", 0x55},
630 {10, ULL(0xffffffff,0xffffffff), "-18446744073709551615\0---------------------------------------------", 0x00},
631 {10, ULL(0xffffffff,0xffffffff), "18446744073709551615\0----------------------------------------------", 0x22},
632
633 {16, 0, "0\0-----------------------------------------------------------------", 0x33},
634 {16, 1, "1\0-----------------------------------------------------------------", 0x33},
635 {16, 2147483646, "7ffffffe\0----------------------------------------------------------", 0x33},
636 {16, 2147483647, "7fffffff\0----------------------------------------------------------", 0x33},
637 {16, 0x80000000, "80000000\0----------------------------------------------------------", 0x33},
638 {16, 0x80000001, "80000001\0----------------------------------------------------------", 0x33},
639 {16, 0xFFFFFFFE, "fffffffe\0----------------------------------------------------------", 0x33},
640 {16, 0xFFFFFFFF, "ffffffff\0----------------------------------------------------------", 0x33},
641 {16, ULL(0x1,0x00000000), "100000000\0---------------------------------------------------------", 0x33},
642 {16, ULL(0xbad,0xdeadbeef), "baddeadbeef\0-------------------------------------------------------", 0x33},
643 {16, ULL(0x80000000,0x00000000), "8000000000000000\0--------------------------------------------------", 0x33},
644 {16, ULL(0xfedcba98,0x76543210), "fedcba9876543210\0--------------------------------------------------", 0x33},
645 {16, ULL(0xffffffff,0x80000001), "ffffffff80000001\0--------------------------------------------------", 0x33},
646 {16, ULL(0xffffffff,0xfffffffe), "fffffffffffffffe\0--------------------------------------------------", 0x33},
647 {16, ULL(0xffffffff,0xffffffff), "ffffffffffffffff\0--------------------------------------------------", 0x33},
648
649 { 2, 32768, "1000000000000000\0--------------------------------------------------", 0x33},
650 { 2, 65536, "10000000000000000\0-------------------------------------------------", 0x33},
651 { 2, 131072, "100000000000000000\0------------------------------------------------", 0x33},
652 {16, 0xffffffff, "ffffffff\0----------------------------------------------------------", 0x33},
653 {16, 0xa, "a\0-----------------------------------------------------------------", 0x33},
654 {16, 0, "0\0-----------------------------------------------------------------", 0x33},
655 {20, 3368421, "111111\0------------------------------------------------------------", 0x33},
656 {36, 62193781, "111111\0------------------------------------------------------------", 0x33},
657 {37, 71270178, "111111\0------------------------------------------------------------", 0x33},
658 {99, ULL(0x2,0x3c9e468c), "111111\0------------------------------------------------------------", 0x33},
659};
660
661
662static void one_i64toa_test(int test_num, const ulonglong2str_t *ulonglong2str)
663{
665 char dest_str[LARGE_STRI_BUFFER_LENGTH + 1];
666
667 memset(dest_str, '-', LARGE_STRI_BUFFER_LENGTH);
668 dest_str[LARGE_STRI_BUFFER_LENGTH] = '\0';
669 result = p_i64toa(ulonglong2str->value, dest_str, ulonglong2str->base);
670 ok(result == dest_str,
671 "(test %d): _i64toa(%s, [out], %d) has result %p, expected: %p\n",
673 if (ulonglong2str->mask & 0x04) {
674 if (memcmp(dest_str, ulonglong2str->Buffer, LARGE_STRI_BUFFER_LENGTH) != 0) {
675 if (memcmp(dest_str, ulonglong2str[1].Buffer, LARGE_STRI_BUFFER_LENGTH) != 0) {
677 "(test %d): _i64toa(%s, [out], %d) assigns string \"%s\", expected: \"%s\"\n",
680 } /* if */
681 } /* if */
682 } else {
684 "(test %d): _i64toa(%s, [out], %d) assigns string \"%s\", expected: \"%s\"\n",
687 } /* if */
688}
689
690
691static void one_ui64toa_test(int test_num, const ulonglong2str_t *ulonglong2str)
692{
694 char dest_str[LARGE_STRI_BUFFER_LENGTH + 1];
695
696 memset(dest_str, '-', LARGE_STRI_BUFFER_LENGTH);
697 dest_str[LARGE_STRI_BUFFER_LENGTH] = '\0';
698 result = p_ui64toa(ulonglong2str->value, dest_str, ulonglong2str->base);
699 ok(result == dest_str,
700 "(test %d): _ui64toa(%s, [out], %d) has result %p, expected: %p\n",
703 "(test %d): _ui64toa(%s, [out], %d) assigns string \"%s\", expected: \"%s\"\n",
706}
707
708
709static void test_ulonglongtoa(void)
710{
711 int test_num;
712
713 for (test_num = 0; test_num < ARRAY_SIZE(ulonglong2str); test_num++) {
714 if (ulonglong2str[test_num].mask & 0x01) {
715 one_i64toa_test(test_num, &ulonglong2str[test_num]);
716 } /* if */
717 if (p_ui64toa != NULL) {
718 if (ulonglong2str[test_num].mask & 0x02) {
719 one_ui64toa_test(test_num, &ulonglong2str[test_num]);
720 } /* if */
721 } /* if */
722 } /* for */
723}
724
725
726static void one_i64tow_test(int test_num, const ulonglong2str_t *ulonglong2str)
727{
728 int pos;
729 WCHAR expected_wstr[LARGE_STRI_BUFFER_LENGTH + 1];
730 WCHAR dest_wstr[LARGE_STRI_BUFFER_LENGTH + 1];
731 UNICODE_STRING unicode_string;
732 STRING ansi_str;
734
735 for (pos = 0; pos < LARGE_STRI_BUFFER_LENGTH; pos++) {
736 expected_wstr[pos] = ulonglong2str->Buffer[pos];
737 } /* for */
738 expected_wstr[LARGE_STRI_BUFFER_LENGTH] = '\0';
739
740 for (pos = 0; pos < LARGE_STRI_BUFFER_LENGTH; pos++) {
741 dest_wstr[pos] = '-';
742 } /* for */
743 dest_wstr[LARGE_STRI_BUFFER_LENGTH] = '\0';
744 unicode_string.Length = LARGE_STRI_BUFFER_LENGTH * sizeof(WCHAR);
745 unicode_string.MaximumLength = unicode_string.Length + sizeof(WCHAR);
746 unicode_string.Buffer = dest_wstr;
747
748 result = p_i64tow(ulonglong2str->value, dest_wstr, ulonglong2str->base);
749 pRtlUnicodeStringToAnsiString(&ansi_str, &unicode_string, 1);
750 ok(result == dest_wstr,
751 "(test %d): _i64tow(0x%s, [out], %d) has result %p, expected: %p\n",
753 if (ulonglong2str->mask & 0x04) {
754 if (memcmp(dest_wstr, expected_wstr, LARGE_STRI_BUFFER_LENGTH * sizeof(WCHAR)) != 0) {
755 for (pos = 0; pos < LARGE_STRI_BUFFER_LENGTH; pos++) {
756 expected_wstr[pos] = ulonglong2str[1].Buffer[pos];
757 } /* for */
758 expected_wstr[LARGE_STRI_BUFFER_LENGTH] = '\0';
759 if (memcmp(dest_wstr, expected_wstr, LARGE_STRI_BUFFER_LENGTH * sizeof(WCHAR)) != 0) {
760 ok(memcmp(dest_wstr, expected_wstr, LARGE_STRI_BUFFER_LENGTH * sizeof(WCHAR)) == 0,
761 "(test %d): _i64tow(0x%s, [out], %d) assigns string \"%s\", expected: \"%s\"\n",
763 ulonglong2str->base, ansi_str.Buffer, ulonglong2str->Buffer);
764 } /* if */
765 } /* if */
766 } else {
767 ok(memcmp(dest_wstr, expected_wstr, LARGE_STRI_BUFFER_LENGTH * sizeof(WCHAR)) == 0,
768 "(test %d): _i64tow(0x%s, [out], %d) assigns string \"%s\", expected: \"%s\"\n",
770 ulonglong2str->base, ansi_str.Buffer, ulonglong2str->Buffer);
771 } /* if */
772 pRtlFreeAnsiString(&ansi_str);
773}
774
775
776static void one_ui64tow_test(int test_num, const ulonglong2str_t *ulonglong2str)
777{
778 int pos;
779 WCHAR expected_wstr[LARGE_STRI_BUFFER_LENGTH + 1];
780 WCHAR dest_wstr[LARGE_STRI_BUFFER_LENGTH + 1];
781 UNICODE_STRING unicode_string;
782 STRING ansi_str;
784
785 for (pos = 0; pos < LARGE_STRI_BUFFER_LENGTH; pos++) {
786 expected_wstr[pos] = ulonglong2str->Buffer[pos];
787 } /* for */
788 expected_wstr[LARGE_STRI_BUFFER_LENGTH] = '\0';
789
790 for (pos = 0; pos < LARGE_STRI_BUFFER_LENGTH; pos++) {
791 dest_wstr[pos] = '-';
792 } /* for */
793 dest_wstr[LARGE_STRI_BUFFER_LENGTH] = '\0';
794 unicode_string.Length = LARGE_STRI_BUFFER_LENGTH * sizeof(WCHAR);
795 unicode_string.MaximumLength = unicode_string.Length + sizeof(WCHAR);
796 unicode_string.Buffer = dest_wstr;
797
798 result = p_ui64tow(ulonglong2str->value, dest_wstr, ulonglong2str->base);
799 pRtlUnicodeStringToAnsiString(&ansi_str, &unicode_string, 1);
800 ok(result == dest_wstr,
801 "(test %d): _ui64tow(0x%s, [out], %d) has result %p, expected: %p\n",
803 ulonglong2str->base, result, dest_wstr);
804 ok(memcmp(dest_wstr, expected_wstr, LARGE_STRI_BUFFER_LENGTH * sizeof(WCHAR)) == 0,
805 "(test %d): _ui64tow(0x%s, [out], %d) assigns string \"%s\", expected: \"%s\"\n",
807 ulonglong2str->base, ansi_str.Buffer, ulonglong2str->Buffer);
808 pRtlFreeAnsiString(&ansi_str);
809}
810
811
812static void test_ulonglongtow(void)
813{
814 int test_num;
816
817 for (test_num = 0; test_num < ARRAY_SIZE(ulonglong2str); test_num++) {
818 if (ulonglong2str[test_num].mask & 0x10) {
819 one_i64tow_test(test_num, &ulonglong2str[test_num]);
820 } /* if */
821 if (p_ui64tow) {
822 if (ulonglong2str[test_num].mask & 0x20) {
823 one_ui64tow_test(test_num, &ulonglong2str[test_num]);
824 } /* if */
825 } /* if */
826 } /* for */
827
828 if (0) {
829 /* Crashes on XP and W2K3 */
830 result = p_i64tow(ulonglong2str[0].value, NULL, 10);
831 ok(result == NULL,
832 "(test d): _i64tow(0x%s, NULL, 10) has result %p, expected: NULL\n",
834 }
835
836 if (p_ui64tow) {
837 if (0) {
838 /* Crashes on XP and W2K3 */
839 result = p_ui64tow(ulonglong2str[0].value, NULL, 10);
840 ok(result == NULL,
841 "(test e): _ui64tow(0x%s, NULL, 10) has result %p, expected: NULL\n",
843 }
844 } /* if */
845}
846
847
848typedef struct {
849 const char *str;
851} str2long_t;
852
853static const str2long_t str2long[] = {
854 { "1011101100", 1011101100 },
855 { "1234567", 1234567 },
856 { "-214", -214 },
857 { "+214", 214 }, /* The + sign is allowed also */
858 { "--214", 0 }, /* Do not accept more than one sign */
859 { "-+214", 0 },
860 { "++214", 0 },
861 { "+-214", 0 },
862 { "\00141", 0 }, /* not whitespace char 1 */
863 { "\00242", 0 }, /* not whitespace char 2 */
864 { "\00343", 0 }, /* not whitespace char 3 */
865 { "\00444", 0 }, /* not whitespace char 4 */
866 { "\00545", 0 }, /* not whitespace char 5 */
867 { "\00646", 0 }, /* not whitespace char 6 */
868 { "\00747", 0 }, /* not whitespace char 7 */
869 { "\01050", 0 }, /* not whitespace char 8 */
870 { "\01151", 51 }, /* is whitespace char 9 (tab) */
871 { "\01252", 52 }, /* is whitespace char 10 (lf) */
872 { "\01353", 53 }, /* is whitespace char 11 (vt) */
873 { "\01454", 54 }, /* is whitespace char 12 (ff) */
874 { "\01555", 55 }, /* is whitespace char 13 (cr) */
875 { "\01656", 0 }, /* not whitespace char 14 */
876 { "\01757", 0 }, /* not whitespace char 15 */
877 { "\02060", 0 }, /* not whitespace char 16 */
878 { "\02161", 0 }, /* not whitespace char 17 */
879 { "\02262", 0 }, /* not whitespace char 18 */
880 { "\02363", 0 }, /* not whitespace char 19 */
881 { "\02464", 0 }, /* not whitespace char 20 */
882 { "\02565", 0 }, /* not whitespace char 21 */
883 { "\02666", 0 }, /* not whitespace char 22 */
884 { "\02767", 0 }, /* not whitespace char 23 */
885 { "\03070", 0 }, /* not whitespace char 24 */
886 { "\03171", 0 }, /* not whitespace char 25 */
887 { "\03272", 0 }, /* not whitespace char 26 */
888 { "\03373", 0 }, /* not whitespace char 27 */
889 { "\03474", 0 }, /* not whitespace char 28 */
890 { "\03575", 0 }, /* not whitespace char 29 */
891 { "\03676", 0 }, /* not whitespace char 30 */
892 { "\03777", 0 }, /* not whitespace char 31 */
893 { "\04080", 80 }, /* is whitespace char 32 (space) */
894 { " \n \r \t214", 214 },
895 { " \n \r \t+214", 214 }, /* Signs can be used after whitespace */
896 { " \n \r \t-214", -214 },
897 { "+214 0", 214 }, /* Space terminates the number */
898 { " 214.01", 214 }, /* Decimal point not accepted */
899 { " 214,01", 214 }, /* Decimal comma not accepted */
900 { "f81", 0 },
901 { "0x12345", 0 }, /* Hex not accepted */
902 { "00x12345", 0 },
903 { "0xx12345", 0 },
904 { "1x34", 1 },
905 { "-9999999999", -1410065407 }, /* Big negative integer */
906 { "-2147483649", 2147483647 }, /* Too small to fit in 32 Bits */
907 { "-2147483648", 0x80000000 }, /* Smallest negative integer */
908 { "-2147483647", -2147483647 },
909 { "-1", -1 },
910 { "0", 0 },
911 { "1", 1 },
912 { "2147483646", 2147483646 },
913 { "2147483647", 2147483647 }, /* Largest signed positive integer */
914 { "2147483648", 2147483648UL }, /* Positive int equal to smallest negative int */
915 { "2147483649", 2147483649UL },
916 { "4294967294", 4294967294UL },
917 { "4294967295", 4294967295UL }, /* Largest unsigned integer */
918 { "4294967296", 0 }, /* Too big to fit in 32 Bits */
919 { "9999999999", 1410065407 }, /* Big positive integer */
920 { "056789", 56789 }, /* Leading zero and still decimal */
921 { "b1011101100", 0 }, /* Binary (b-notation) */
922 { "-b1011101100", 0 }, /* Negative Binary (b-notation) */
923 { "b10123456789", 0 }, /* Binary with nonbinary digits (2-9) */
924 { "0b1011101100", 0 }, /* Binary (0b-notation) */
925 { "-0b1011101100", 0 }, /* Negative binary (0b-notation) */
926 { "0b10123456789", 0 }, /* Binary with nonbinary digits (2-9) */
927 { "-0b10123456789", 0 }, /* Negative binary with nonbinary digits (2-9) */
928 { "0b1", 0 }, /* one digit binary */
929 { "0b2", 0 }, /* empty binary */
930 { "0b", 0 }, /* empty binary */
931 { "o1234567", 0 }, /* Octal (o-notation) */
932 { "-o1234567", 0 }, /* Negative Octal (o-notation) */
933 { "o56789", 0 }, /* Octal with nonoctal digits (8 and 9) */
934 { "0o1234567", 0 }, /* Octal (0o-notation) */
935 { "-0o1234567", 0 }, /* Negative octal (0o-notation) */
936 { "0o56789", 0 }, /* Octal with nonoctal digits (8 and 9) */
937 { "-0o56789", 0 }, /* Negative octal with nonoctal digits (8 and 9) */
938 { "0o7", 0 }, /* one digit octal */
939 { "0o8", 0 }, /* empty octal */
940 { "0o", 0 }, /* empty octal */
941 { "0d1011101100", 0 }, /* explicit decimal with 0d */
942 { "x89abcdef", 0 }, /* Hex with lower case digits a-f (x-notation) */
943 { "xFEDCBA00", 0 }, /* Hex with upper case digits A-F (x-notation) */
944 { "-xFEDCBA00", 0 }, /* Negative Hexadecimal (x-notation) */
945 { "0x89abcdef", 0 }, /* Hex with lower case digits a-f (0x-notation) */
946 { "0xFEDCBA00", 0 }, /* Hex with upper case digits A-F (0x-notation) */
947 { "-0xFEDCBA00", 0 }, /* Negative Hexadecimal (0x-notation) */
948 { "0xabcdefgh", 0 }, /* Hex with illegal lower case digits (g-z) */
949 { "0xABCDEFGH", 0 }, /* Hex with illegal upper case digits (G-Z) */
950 { "0xF", 0 }, /* one digit hexadecimal */
951 { "0xG", 0 }, /* empty hexadecimal */
952 { "0x", 0 }, /* empty hexadecimal */
953 { "", 0 }, /* empty string */
954/* { NULL, 0 }, */ /* NULL as string */
955};
956
957
958static void test_wtoi(void)
959{
960 int test_num;
961 UNICODE_STRING uni;
962 int result;
963
964 for (test_num = 0; test_num < ARRAY_SIZE(str2long); test_num++) {
965 pRtlCreateUnicodeStringFromAsciiz(&uni, str2long[test_num].str);
966 result = p_wtoi(uni.Buffer);
967 ok(result == str2long[test_num].value,
968 "(test %d): call failed: _wtoi(\"%s\") has result %d, expected: %ld\n",
969 test_num, str2long[test_num].str, result, str2long[test_num].value);
970 pRtlFreeUnicodeString(&uni);
971 } /* for */
972}
973
974static void test_atoi(void)
975{
976 int test_num;
977 int result;
978
979 for (test_num = 0; test_num < ARRAY_SIZE(str2long); test_num++) {
980 result = patoi(str2long[test_num].str);
981 ok(result == str2long[test_num].value,
982 "(test %d): call failed: _atoi(\"%s\") has result %d, expected: %ld\n",
983 test_num, str2long[test_num].str, result, str2long[test_num].value);
984 }
985}
986
987static void test_atol(void)
988{
989 int test_num;
990 int result;
991
992 for (test_num = 0; test_num < ARRAY_SIZE(str2long); test_num++) {
993 result = patol(str2long[test_num].str);
994 ok(result == str2long[test_num].value,
995 "(test %d): call failed: _atol(\"%s\") has result %d, expected: %ld\n",
996 test_num, str2long[test_num].str, result, str2long[test_num].value);
997 }
998}
999
1000static void test_wtol(void)
1001{
1002 int test_num;
1003 UNICODE_STRING uni;
1004 LONG result;
1005
1006 for (test_num = 0; test_num < ARRAY_SIZE(str2long); test_num++) {
1007 pRtlCreateUnicodeStringFromAsciiz(&uni, str2long[test_num].str);
1008 result = p_wtol(uni.Buffer);
1009 ok(result == str2long[test_num].value,
1010 "(test %d): call failed: _wtol(\"%s\") has result %ld, expected: %ld\n",
1011 test_num, str2long[test_num].str, result, str2long[test_num].value);
1012 pRtlFreeUnicodeString(&uni);
1013 }
1014 result = p_wtol( L"\t\xa0\n 12" );
1015 ok( result == 12, "got %ld\n", result );
1016 result = p_wtol( L"\x3000 12" );
1017 ok( result == 0, "got %ld\n", result );
1018}
1019
1020
1021typedef struct {
1022 const char *str;
1026
1028 { "1011101100", 1011101100 },
1029 { "1234567", 1234567 },
1030 { "-214", -214 },
1031 { "+214", 214 }, /* The + sign is allowed also */
1032 { "--214", 0 }, /* Do not accept more than one sign */
1033 { "-+214", 0 },
1034 { "++214", 0 },
1035 { "+-214", 0 },
1036 { "\00141", 0 }, /* not whitespace char 1 */
1037 { "\00242", 0 }, /* not whitespace char 2 */
1038 { "\00343", 0 }, /* not whitespace char 3 */
1039 { "\00444", 0 }, /* not whitespace char 4 */
1040 { "\00545", 0 }, /* not whitespace char 5 */
1041 { "\00646", 0 }, /* not whitespace char 6 */
1042 { "\00747", 0 }, /* not whitespace char 7 */
1043 { "\01050", 0 }, /* not whitespace char 8 */
1044 { "\01151", 51 }, /* is whitespace char 9 (tab) */
1045 { "\01252", 52 }, /* is whitespace char 10 (lf) */
1046 { "\01353", 53 }, /* is whitespace char 11 (vt) */
1047 { "\01454", 54 }, /* is whitespace char 12 (ff) */
1048 { "\01555", 55 }, /* is whitespace char 13 (cr) */
1049 { "\01656", 0 }, /* not whitespace char 14 */
1050 { "\01757", 0 }, /* not whitespace char 15 */
1051 { "\02060", 0 }, /* not whitespace char 16 */
1052 { "\02161", 0 }, /* not whitespace char 17 */
1053 { "\02262", 0 }, /* not whitespace char 18 */
1054 { "\02363", 0 }, /* not whitespace char 19 */
1055 { "\02464", 0 }, /* not whitespace char 20 */
1056 { "\02565", 0 }, /* not whitespace char 21 */
1057 { "\02666", 0 }, /* not whitespace char 22 */
1058 { "\02767", 0 }, /* not whitespace char 23 */
1059 { "\03070", 0 }, /* not whitespace char 24 */
1060 { "\03171", 0 }, /* not whitespace char 25 */
1061 { "\03272", 0 }, /* not whitespace char 26 */
1062 { "\03373", 0 }, /* not whitespace char 27 */
1063 { "\03474", 0 }, /* not whitespace char 28 */
1064 { "\03575", 0 }, /* not whitespace char 29 */
1065 { "\03676", 0 }, /* not whitespace char 30 */
1066 { "\03777", 0 }, /* not whitespace char 31 */
1067 { "\04080", 80 }, /* is whitespace char 32 (space) */
1068 { " \n \r \t214", 214 },
1069 { " \n \r \t+214", 214 }, /* Signs can be used after whitespace */
1070 { " \n \r \t-214", -214 },
1071 { "+214 0", 214 }, /* Space terminates the number */
1072 { " 214.01", 214 }, /* Decimal point not accepted */
1073 { " 214,01", 214 }, /* Decimal comma not accepted */
1074 { "f81", 0 },
1075 { "0x12345", 0 }, /* Hex not accepted */
1076 { "00x12345", 0 },
1077 { "0xx12345", 0 },
1078 { "1x34", 1 },
1079 { "-99999999999999999999", -ULL(0x6bc75e2d,0x630fffff), -1 }, /* Big negative integer */
1080 { "-9223372036854775809", ULL(0x7fffffff,0xffffffff), -1 }, /* Too small to fit in 64 bits */
1081 { "-9223372036854775808", ULL(0x80000000,0x00000000) }, /* Smallest negative 64 bit integer */
1082 { "-9223372036854775807", -ULL(0x7fffffff,0xffffffff) },
1083 { "-9999999999", -ULL(0x00000002,0x540be3ff) },
1084 { "-2147483649", -ULL(0x00000000,0x80000001) }, /* Too small to fit in 32 bits */
1085 { "-2147483648", -ULL(0x00000000,0x80000000) }, /* Smallest 32 bits negative integer */
1086 { "-2147483647", -2147483647 },
1087 { "-1", -1 },
1088 { "0", 0 },
1089 { "1", 1 },
1090 { "2147483646", 2147483646 },
1091 { "2147483647", 2147483647 }, /* Largest signed positive 32 bit integer */
1092 { "2147483648", ULL(0x00000000,0x80000000) }, /* Pos int equal to smallest neg 32 bit int */
1093 { "2147483649", ULL(0x00000000,0x80000001) },
1094 { "4294967294", ULL(0x00000000,0xfffffffe) },
1095 { "4294967295", ULL(0x00000000,0xffffffff) }, /* Largest unsigned 32 bit integer */
1096 { "4294967296", ULL(0x00000001,0x00000000) }, /* Too big to fit in 32 Bits */
1097 { "9999999999", ULL(0x00000002,0x540be3ff) },
1098 { "9223372036854775806", ULL(0x7fffffff,0xfffffffe) },
1099 { "9223372036854775807", ULL(0x7fffffff,0xffffffff) }, /* Largest signed positive 64 bit integer */
1100 { "9223372036854775808", ULL(0x80000000,0x00000000), 1 }, /* Pos int equal to smallest neg 64 bit int */
1101 { "9223372036854775809", ULL(0x80000000,0x00000001), 1 },
1102 { "18446744073709551614", ULL(0xffffffff,0xfffffffe), 1 },
1103 { "18446744073709551615", ULL(0xffffffff,0xffffffff), 1 }, /* Largest unsigned 64 bit integer */
1104 { "18446744073709551616", 0, 1 }, /* Too big to fit in 64 bits */
1105 { "99999999999999999999", ULL(0x6bc75e2d,0x630fffff), 1 }, /* Big positive integer */
1106 { "056789", 56789 }, /* Leading zero and still decimal */
1107 { "b1011101100", 0 }, /* Binary (b-notation) */
1108 { "-b1011101100", 0 }, /* Negative Binary (b-notation) */
1109 { "b10123456789", 0 }, /* Binary with nonbinary digits (2-9) */
1110 { "0b1011101100", 0 }, /* Binary (0b-notation) */
1111 { "-0b1011101100", 0 }, /* Negative binary (0b-notation) */
1112 { "0b10123456789", 0 }, /* Binary with nonbinary digits (2-9) */
1113 { "-0b10123456789", 0 }, /* Negative binary with nonbinary digits (2-9) */
1114 { "0b1", 0 }, /* one digit binary */
1115 { "0b2", 0 }, /* empty binary */
1116 { "0b", 0 }, /* empty binary */
1117 { "o1234567", 0 }, /* Octal (o-notation) */
1118 { "-o1234567", 0 }, /* Negative Octal (o-notation) */
1119 { "o56789", 0 }, /* Octal with nonoctal digits (8 and 9) */
1120 { "0o1234567", 0 }, /* Octal (0o-notation) */
1121 { "-0o1234567", 0 }, /* Negative octal (0o-notation) */
1122 { "0o56789", 0 }, /* Octal with nonoctal digits (8 and 9) */
1123 { "-0o56789", 0 }, /* Negative octal with nonoctal digits (8 and 9) */
1124 { "0o7", 0 }, /* one digit octal */
1125 { "0o8", 0 }, /* empty octal */
1126 { "0o", 0 }, /* empty octal */
1127 { "0d1011101100", 0 }, /* explicit decimal with 0d */
1128 { "x89abcdef", 0 }, /* Hex with lower case digits a-f (x-notation) */
1129 { "xFEDCBA00", 0 }, /* Hex with upper case digits A-F (x-notation) */
1130 { "-xFEDCBA00", 0 }, /* Negative Hexadecimal (x-notation) */
1131 { "0x89abcdef", 0 }, /* Hex with lower case digits a-f (0x-notation) */
1132 { "0xFEDCBA00", 0 }, /* Hex with upper case digits A-F (0x-notation) */
1133 { "-0xFEDCBA00", 0 }, /* Negative Hexadecimal (0x-notation) */
1134 { "0xabcdefgh", 0 }, /* Hex with illegal lower case digits (g-z) */
1135 { "0xABCDEFGH", 0 }, /* Hex with illegal upper case digits (G-Z) */
1136 { "0xF", 0 }, /* one digit hexadecimal */
1137 { "0xG", 0 }, /* empty hexadecimal */
1138 { "0x", 0 }, /* empty hexadecimal */
1139 { "", 0 }, /* empty string */
1140/* { NULL, 0 }, */ /* NULL as string */
1141};
1142
1143
1144static void test_atoi64(void)
1145{
1146 int test_num;
1148
1149 for (test_num = 0; test_num < ARRAY_SIZE(str2longlong); test_num++) {
1150 result = p_atoi64(str2longlong[test_num].str);
1151 if (str2longlong[test_num].overflow)
1152 ok(result == str2longlong[test_num].value ||
1153 (result == ((str2longlong[test_num].overflow == -1) ?
1154 ULL(0x80000000,0x00000000) : ULL(0x7fffffff,0xffffffff))),
1155 "(test %d): call failed: _atoi64(\"%s\") has result 0x%s, expected: 0x%s\n",
1156 test_num, str2longlong[test_num].str, wine_dbgstr_longlong(result),
1158 else
1159 ok(result == str2longlong[test_num].value,
1160 "(test %d): call failed: _atoi64(\"%s\") has result 0x%s, expected: 0x%s\n",
1161 test_num, str2longlong[test_num].str, wine_dbgstr_longlong(result),
1163 }
1164}
1165
1166
1167static void test_wtoi64(void)
1168{
1169 int test_num;
1170 UNICODE_STRING uni;
1172
1173 for (test_num = 0; test_num < ARRAY_SIZE(str2longlong); test_num++) {
1174 pRtlCreateUnicodeStringFromAsciiz(&uni, str2longlong[test_num].str);
1175 result = p_wtoi64(uni.Buffer);
1176 if (str2longlong[test_num].overflow)
1177 ok(result == str2longlong[test_num].value ||
1178 (result == ((str2longlong[test_num].overflow == -1) ?
1179 ULL(0x80000000,0x00000000) : ULL(0x7fffffff,0xffffffff))),
1180 "(test %d): call failed: _atoi64(\"%s\") has result 0x%s, expected: 0x%s\n",
1181 test_num, str2longlong[test_num].str, wine_dbgstr_longlong(result),
1183 else
1184 ok(result == str2longlong[test_num].value,
1185 "(test %d): call failed: _atoi64(\"%s\") has result 0x%s, expected: 0x%s\n",
1186 test_num, str2longlong[test_num].str, wine_dbgstr_longlong(result),
1188 pRtlFreeUnicodeString(&uni);
1189 }
1190 result = p_wtoi64( L"\t\xa0\n 12" );
1191 ok( result == 12, "got %s\n", wine_dbgstr_longlong(result) );
1192 result = p_wtoi64( L"\x2002\x2003 12" );
1193 ok( result == 0, "got %s\n", wine_dbgstr_longlong(result) );
1194}
1195
1196static void test_wcstol(void)
1197{
1198 static const struct { WCHAR str[24]; LONG res; ULONG ures; int base; } tests[] =
1199 {
1200 { L"9", 9, 9, 10 },
1201 { L" ", 0, 0 },
1202 { L"-1234", -1234, -1234 },
1203 { L"\x09\x0a\x0b\x0c\x0d -123", -123, -123 },
1204 { L"\xa0 +44", 44, 44 },
1205 { L"\x2002\x2003 +55", 0, 0 },
1206 { L"\x3000 +66", 0, 0 },
1207 { { 0x3231 }, 0, 0 }, /* PARENTHESIZED IDEOGRAPH STOCK */
1208 { { 0x4e00 }, 0, 0 }, /* CJK Ideograph, First */
1209 { { 0x0bef }, 0, 0 }, /* TAMIL DIGIT NINE */
1210 { { 0x0e59 }, 9, 9 }, /* THAI DIGIT NINE */
1211 { { 0xff19 }, 9, 9 }, /* FULLWIDTH DIGIT NINE */
1212 { { 0x00b9 }, 0, 0 }, /* SUPERSCRIPT ONE */
1213 { { '-',0x0e50,'x',0xff19,'1' }, -0x91, -0x91 },
1214 { { '+',0x0e50,0xff17,'1' }, 071, 071 },
1215 { { 0xff19,'f',0x0e59,0xff46 }, 0x9f9, 0x9f9, 16 },
1216 { L"2147483647", 2147483647, 2147483647 },
1217 { L"2147483648", LONG_MAX, 2147483648 },
1218 { L"4294967295", LONG_MAX, 4294967295 },
1219 { L"4294967296", LONG_MAX, ULONG_MAX },
1220 { L"9223372036854775807", LONG_MAX, ULONG_MAX },
1221 { L"-2147483647", -2147483647, -2147483647 },
1222 { L"-2147483648", LONG_MIN, LONG_MIN },
1223 { L"-4294967295", LONG_MIN, 1 },
1224 { L"-4294967296", LONG_MIN, 1 },
1225 { L"-9223372036854775807", LONG_MIN, 1 },
1226 };
1227 static const WCHAR zeros[] =
1228 {
1229 0x0660, 0x06f0, 0x0966, 0x09e6, 0x0a66, 0x0ae6, 0x0b66, 0x0c66, 0x0ce6,
1230 0x0d66, 0x0e50, 0x0ed0, 0x0f20, 0x1040, 0x17e0, 0x1810, 0xff10
1231 };
1232 unsigned int i;
1233 LONG res;
1234 ULONG ures;
1235 WCHAR *endpos;
1236
1237 for (i = 0; i < ARRAY_SIZE(tests); i++)
1238 {
1239 res = pwcstol( tests[i].str, &endpos, tests[i].base );
1240 ok( res == tests[i].res, "%u: %s res %08lx\n", i, wine_dbgstr_w(tests[i].str), res );
1241 if (!res) ok( endpos == tests[i].str, "%u: wrong endpos %p/%p\n", i, endpos, tests[i].str );
1242 ures = pwcstoul( tests[i].str, &endpos, tests[i].base );
1243 ok( ures == tests[i].ures, "%u: %s res %08lx\n", i, wine_dbgstr_w(tests[i].str), ures );
1244 }
1245
1246 /* Test various unicode digits */
1247 for (i = 0; i < ARRAY_SIZE(zeros); ++i)
1248 {
1249 WCHAR tmp[] = { zeros[i] + 4, zeros[i], zeros[i] + 5, 0 };
1250 res = pwcstol(tmp, NULL, 0);
1251 ok(res == 405, "with zero = U+%04X: got %ld, expected 405\n", zeros[i], res);
1252 ures = pwcstoul(tmp, NULL, 0);
1253 ok(ures == 405, "with zero = U+%04X: got %lu, expected 405\n", zeros[i], ures);
1254 tmp[1] = zeros[i] + 10;
1255 res = pwcstol(tmp, NULL, 16);
1256 ok(res == 4, "with zero = U+%04X: got %ld, expected 4\n", zeros[i], res);
1257 ures = pwcstoul(tmp, NULL, 16);
1258 ok(ures == 4, "with zero = U+%04X: got %lu, expected 4\n", zeros[i], ures);
1259 }
1260}
1261
1262static void test_wcschr(void)
1263{
1264 static const WCHAR teststringW[] = {'a','b','r','a','c','a','d','a','b','r','a',0};
1265
1266 ok(pwcschr(teststringW, 'a') == teststringW + 0,
1267 "wcschr should have returned a pointer to the first 'a' character\n");
1268 ok(pwcschr(teststringW, 0) == teststringW + 11,
1269 "wcschr should have returned a pointer to the null terminator\n");
1270 ok(pwcschr(teststringW, 'x') == NULL,
1271 "wcschr should have returned NULL\n");
1272}
1273
1274static void test_wcsrchr(void)
1275{
1276 static const WCHAR teststringW[] = {'a','b','r','a','c','a','d','a','b','r','a',0};
1277
1278 ok(pwcsrchr(teststringW, 'a') == teststringW + 10,
1279 "wcsrchr should have returned a pointer to the last 'a' character\n");
1280 ok(pwcsrchr(teststringW, 0) == teststringW + 11,
1281 "wcsrchr should have returned a pointer to the null terminator\n");
1282 ok(pwcsrchr(teststringW, 'x') == NULL,
1283 "wcsrchr should have returned NULL\n");
1284}
1285
1286static void test_wcslwrupr(void)
1287{
1288 static WCHAR teststringW[] = {'a','b','r','a','c','a','d','a','b','r','a',0};
1289 static WCHAR emptyW[] = {0};
1290 static const WCHAR constemptyW[] = {0};
1291 WCHAR buffer[65536];
1292 int i;
1293
1294 if (0) /* crashes on native */
1295 {
1296 static const WCHAR conststringW[] = {'a','b','r','a','c','a','d','a','b','r','a',0};
1297 ok(p_wcslwr((LPWSTR)conststringW) == conststringW, "p_wcslwr returned different string\n");
1298 ok(p_wcsupr((LPWSTR)conststringW) == conststringW, "p_wcsupr returned different string\n");
1299 ok(p_wcslwr(NULL) == NULL, "p_wcslwr didn't returned NULL\n");
1300 ok(p_wcsupr(NULL) == NULL, "p_wcsupr didn't returned NULL\n");
1301 }
1302 ok(p_wcslwr(teststringW) == teststringW, "p_wcslwr returned different string\n");
1303 ok(p_wcsupr(teststringW) == teststringW, "p_wcsupr returned different string\n");
1304 ok(p_wcslwr(emptyW) == emptyW, "p_wcslwr returned different string\n");
1305 ok(p_wcsupr(emptyW) == emptyW, "p_wcsupr returned different string\n");
1306 ok(p_wcslwr((LPWSTR)constemptyW) == constemptyW, "p_wcslwr returned different string\n");
1307 ok(p_wcsupr((LPWSTR)constemptyW) == constemptyW, "p_wcsupr returned different string\n");
1308
1309 for (i = 0; i < 65536; i++)
1310 {
1311 WCHAR lwr = ((i >= 'A' && i <= 'Z') || (i >= 0xc0 && i <= 0xd6) || (i >= 0xd8 && i <= 0xde)) ? i + 32 : i;
1312 WCHAR upr = pRtlUpcaseUnicodeChar( i );
1313 ok( ptowlower( i ) == lwr, "%04x: towlower got %04x expected %04x\n", i, ptowlower( i ), lwr );
1314 ok( ptowupper( i ) == upr, "%04x: towupper got %04x expected %04x\n", i, ptowupper( i ), upr );
1315 }
1316
1317 for (i = 1; i < 65536; i++) buffer[i - 1] = i;
1318 buffer[65535] = 0;
1319 p_wcslwr( buffer );
1320 for (i = 1; i < 65536; i++)
1321 ok( buffer[i - 1] == (i >= 'A' && i <= 'Z' ? i + 32 : i), "%04x: got %04x\n", i, buffer[i-1] );
1322
1323 for (i = 1; i < 65536; i++) buffer[i - 1] = i;
1324 buffer[65535] = 0;
1325 p_wcsupr( buffer );
1326 for (i = 1; i < 65536; i++)
1327 ok( buffer[i - 1] == (i >= 'a' && i <= 'z' ? i - 32 : i), "%04x: got %04x\n", i, buffer[i-1] );
1328}
1329
1330static void test_wcsicmp(void)
1331{
1332 WCHAR buf_a[2], buf_b[2];
1333 int i, j, ret;
1334
1335 buf_a[1] = buf_b[1] = 0;
1336 for (i = 0; i < 0x300; i++)
1337 {
1338 int lwr_a = (i >= 'A' && i <= 'Z') ? i + 32 : i;
1339 buf_a[0] = i;
1340 for (j = 0; j < 0x300; j++)
1341 {
1342 int lwr_b = (j >= 'A' && j <= 'Z') ? j + 32 : j;
1343 buf_b[0] = j;
1344 ret = p_wcsicmp( buf_a, buf_b );
1345 ok( ret == lwr_a - lwr_b, "%04x:%04x: strings differ %d\n", i, j, ret );
1346 ret = p_wcsnicmp( buf_a, buf_b, 2 );
1347 ok( ret == lwr_a - lwr_b, "%04x:%04x: strings differ %d\n", i, j, ret );
1348 }
1349 }
1350}
1351
1352static int __cdecl intcomparefunc(const void *a, const void *b)
1353{
1354 const int *p = a, *q = b;
1355
1356 ok (a != b, "must never get the same pointer\n");
1357
1358 return *p - *q;
1359}
1360
1361static int __cdecl charcomparefunc(const void *a, const void *b)
1362{
1363 const char *p = a, *q = b;
1364
1365 ok (a != b, "must never get the same pointer\n");
1366
1367 return *p - *q;
1368}
1369
1370static int __cdecl strcomparefunc(const void *a, const void *b)
1371{
1372 const char * const *p = a;
1373 const char * const *q = b;
1374
1375 ok (a != b, "must never get the same pointer\n");
1376
1377 return lstrcmpA(*p, *q);
1378}
1379
1380static int __cdecl istrcomparefunc(const void *a, const void *b)
1381{
1382 const char * const *p = a;
1383 const char * const *q = b;
1384
1385 ok (a != b, "must never get the same pointer\n");
1386
1387 return lstrcmpiA(*p, *q);
1388}
1389
1390static void test_qsort(void)
1391{
1392 int arr[5] = { 23, 42, 8, 4, 16 };
1393 char carr[5] = { 42, 23, 4, 8, 16 };
1394 const char *strarr[7] = {
1395 "Hello",
1396 "Wine",
1397 "World",
1398 "!",
1399 "Hopefully",
1400 "Sorted",
1401 "."
1402 };
1403 const char *strarr2[7] = {
1404 "Hello",
1405 "Wine",
1406 "World",
1407 "!",
1408 "wine",
1409 "Sorted",
1410 "WINE"
1411 };
1412
1413 pqsort ((void*)arr, 0, sizeof(int), intcomparefunc);
1414 ok(arr[0] == 23, "badly sorted, nmemb=0, arr[0] is %d\n", arr[0]);
1415 ok(arr[1] == 42, "badly sorted, nmemb=0, arr[1] is %d\n", arr[1]);
1416 ok(arr[2] == 8, "badly sorted, nmemb=0, arr[2] is %d\n", arr[2]);
1417 ok(arr[3] == 4, "badly sorted, nmemb=0, arr[3] is %d\n", arr[3]);
1418 ok(arr[4] == 16, "badly sorted, nmemb=0, arr[4] is %d\n", arr[4]);
1419
1420 pqsort ((void*)arr, 1, sizeof(int), intcomparefunc);
1421 ok(arr[0] == 23, "badly sorted, nmemb=1, arr[0] is %d\n", arr[0]);
1422 ok(arr[1] == 42, "badly sorted, nmemb=1, arr[1] is %d\n", arr[1]);
1423 ok(arr[2] == 8, "badly sorted, nmemb=1, arr[2] is %d\n", arr[2]);
1424 ok(arr[3] == 4, "badly sorted, nmemb=1, arr[3] is %d\n", arr[3]);
1425 ok(arr[4] == 16, "badly sorted, nmemb=1, arr[4] is %d\n", arr[4]);
1426
1427 pqsort ((void*)arr, 5, 0, intcomparefunc);
1428 ok(arr[0] == 23, "badly sorted, size=0, arr[0] is %d\n", arr[0]);
1429 ok(arr[1] == 42, "badly sorted, size=0, arr[1] is %d\n", arr[1]);
1430 ok(arr[2] == 8, "badly sorted, size=0, arr[2] is %d\n", arr[2]);
1431 ok(arr[3] == 4, "badly sorted, size=0, arr[3] is %d\n", arr[3]);
1432 ok(arr[4] == 16, "badly sorted, size=0, arr[4] is %d\n", arr[4]);
1433
1434 pqsort ((void*)arr, 5, sizeof(int), intcomparefunc);
1435 ok(arr[0] == 4, "badly sorted, arr[0] is %d\n", arr[0]);
1436 ok(arr[1] == 8, "badly sorted, arr[1] is %d\n", arr[1]);
1437 ok(arr[2] == 16, "badly sorted, arr[2] is %d\n", arr[2]);
1438 ok(arr[3] == 23, "badly sorted, arr[3] is %d\n", arr[3]);
1439 ok(arr[4] == 42, "badly sorted, arr[4] is %d\n", arr[4]);
1440
1441 pqsort ((void*)carr, 5, sizeof(char), charcomparefunc);
1442 ok(carr[0] == 4, "badly sorted, carr[0] is %d\n", carr[0]);
1443 ok(carr[1] == 8, "badly sorted, carr[1] is %d\n", carr[1]);
1444 ok(carr[2] == 16, "badly sorted, carr[2] is %d\n", carr[2]);
1445 ok(carr[3] == 23, "badly sorted, carr[3] is %d\n", carr[3]);
1446 ok(carr[4] == 42, "badly sorted, carr[4] is %d\n", carr[4]);
1447
1448 pqsort ((void*)strarr, 7, sizeof(char*), strcomparefunc);
1449 ok(!strcmp(strarr[0],"!"), "badly sorted, strarr[0] is %s\n", strarr[0]);
1450 ok(!strcmp(strarr[1],"."), "badly sorted, strarr[1] is %s\n", strarr[1]);
1451 ok(!strcmp(strarr[2],"Hello"), "badly sorted, strarr[2] is %s\n", strarr[2]);
1452 ok(!strcmp(strarr[3],"Hopefully"), "badly sorted, strarr[3] is %s\n", strarr[3]);
1453 ok(!strcmp(strarr[4],"Sorted"), "badly sorted, strarr[4] is %s\n", strarr[4]);
1454 ok(!strcmp(strarr[5],"Wine"), "badly sorted, strarr[5] is %s\n", strarr[5]);
1455 ok(!strcmp(strarr[6],"World"), "badly sorted, strarr[6] is %s\n", strarr[6]);
1456
1457 pqsort ((void*)strarr2, 7, sizeof(char*), istrcomparefunc);
1458 ok(!strcmp(strarr2[0], "!"), "badly sorted, strar2r[0] is %s\n", strarr2[0]);
1459 ok(!strcmp(strarr2[1], "Hello"), "badly sorted, strarr2[1] is %s\n", strarr2[1]);
1460 ok(!strcmp(strarr2[2], "Sorted"), "badly sorted, strarr2[2] is %s\n", strarr2[2]);
1461 ok(!strcmp(strarr2[3], "wine"), "badly sorted, strarr2[3] is %s\n", strarr2[3]);
1462 ok(!strcmp(strarr2[4], "WINE"), "badly sorted, strarr2[4] is %s\n", strarr2[4]);
1463 ok(!strcmp(strarr2[5], "Wine"), "badly sorted, strarr2[5] is %s\n", strarr2[5]);
1464 ok(!strcmp(strarr2[6], "World"), "badly sorted, strarr2[6] is %s\n", strarr2[6]);
1465}
1466
1467static void test_bsearch(void)
1468{
1469 int arr[7] = { 1, 3, 4, 8, 16, 23, 42 };
1470 int *x, l, i, j;
1471
1472 /* just try all array sizes */
1473 for (j=1;j<ARRAY_SIZE(arr);j++) {
1474 for (i=0;i<j;i++) {
1475 l = arr[i];
1476 x = pbsearch (&l, arr, j, sizeof(arr[0]), intcomparefunc);
1477 ok (x == &arr[i], "bsearch did not find %d entry in loopsize %d.\n", i, j);
1478 }
1479 l = 4242;
1480 x = pbsearch (&l, arr, j, sizeof(arr[0]), intcomparefunc);
1481 ok (x == NULL, "bsearch did find 4242 entry in loopsize %d.\n", j);
1482 }
1483}
1484
1485static void test__snprintf(void)
1486{
1487 const char *origstring = "XXXXXXXXXXXX";
1488 const char *teststring = "hello world";
1489 char buffer[32];
1490 int res;
1491
1492 res = p_snprintf(NULL, 0, teststring);
1493 ok(res == lstrlenA(teststring), "_snprintf returned %d, expected %d.\n", res, lstrlenA(teststring));
1494
1495 if (res != -1)
1496 {
1497 res = p_snprintf(NULL, 1, teststring);
1498 ok(res == lstrlenA(teststring) /* WinXP */ || res < 0 /* Vista and greater */,
1499 "_snprintf returned %d, expected %d or < 0.\n", res, lstrlenA(teststring));
1500 }
1501 res = p_snprintf(buffer, strlen(teststring) - 1, teststring);
1502 ok(res < 0, "_snprintf returned %d, expected < 0.\n", res);
1503
1504 strcpy(buffer, origstring);
1505 res = p_snprintf(buffer, strlen(teststring), teststring);
1506 ok(res == lstrlenA(teststring), "_snprintf returned %d, expected %d.\n", res, lstrlenA(teststring));
1507 ok(!strcmp(buffer, "hello worldX"), "_snprintf returned buffer '%s', expected 'hello worldX'.\n", buffer);
1508
1509 strcpy(buffer, origstring);
1510 res = p_snprintf(buffer, strlen(teststring) + 1, teststring);
1511 ok(res == lstrlenA(teststring), "_snprintf returned %d, expected %d.\n", res, lstrlenA(teststring));
1512 ok(!strcmp(buffer, teststring), "_snprintf returned buffer '%s', expected '%s'.\n", buffer, teststring);
1513
1514 memset(buffer, 0x7c, sizeof(buffer));
1515 res = p_snprintf(buffer, 4, "test");
1516 ok(res == 4, "res = %d\n", res);
1517 ok(!memcmp(buffer, "test", 4), "buf = %s\n", buffer);
1518 ok(buffer[4] == 0x7c, "buffer[4] = %x\n", buffer[4]);
1519
1520 memset(buffer, 0x7c, sizeof(buffer));
1521 res = p_snprintf(buffer, 3, "test");
1522 ok(res == -1, "res = %d\n", res);
1523 ok(!memcmp(buffer, "tes", 3), "buf = %s\n", buffer);
1524 ok(buffer[3] == 0x7c, "buffer[3] = %x\n", buffer[3]);
1525
1526 memset(buffer, 0x7c, sizeof(buffer));
1527 res = p_snprintf(buffer, 4, "%s", "test");
1528 ok(res == 4, "res = %d\n", res);
1529 ok(!memcmp(buffer, "test", 4), "buf = %s\n", buffer);
1530 ok(buffer[4] == 0x7c, "buffer[4] = %x\n", buffer[4]);
1531
1532 memset(buffer, 0x7c, sizeof(buffer));
1533 res = p_snprintf(buffer, 3, "%s", "test");
1534 ok(res == -1, "res = %d\n", res);
1535 ok(!memcmp(buffer, "tes", 3), "buf = %s\n", buffer);
1536 ok(buffer[3] == 0x7c, "buffer[3] = %x\n", buffer[3]);
1537
1538 res = p_snprintf(buffer, sizeof(buffer), "%ls", L"test");
1539 ok(res == strlen(buffer), "wrong size %d\n", res);
1540 ok(!strcmp(buffer, "test"), "got %s\n", debugstr_a(buffer));
1541
1542 res = p_snprintf(buffer, sizeof(buffer), "%Ls", "test");
1543 ok(res == strlen(buffer), "wrong size %d\n", res);
1544 ok(!strcmp(buffer, "test"), "got %s\n", debugstr_a(buffer));
1545
1546 res = p_snprintf(buffer, sizeof(buffer), "%I64x %d", (ULONGLONG)0x1234567890, 1);
1547 ok(res == strlen(buffer), "wrong size %d\n", res);
1548 ok(!strcmp(buffer, "1234567890 1"), "got %s\n", debugstr_a(buffer));
1549
1550 res = p_snprintf(buffer, sizeof(buffer), "%I32x %d", 0x123456, 1);
1551 ok(res == strlen(buffer), "wrong size %d\n", res);
1552 ok(!strcmp(buffer, "123456 1"), "got %s\n", debugstr_a(buffer));
1553
1554 res = p_snprintf(buffer, sizeof(buffer), "%#x %#x", 0, 1);
1555 ok(res == lstrlenA(buffer), "wrong size %d\n", res);
1556 ok(!strcmp(buffer, "0 0x1"), "got %s\n", debugstr_a(buffer));
1557
1558 res = p_snprintf(buffer, sizeof(buffer), "%hx %hd", 0x123456, 987654);
1559 ok(res == strlen(buffer), "wrong size %d\n", res);
1560 ok(!strcmp(buffer, "3456 4614"), "got %s\n", debugstr_a(buffer));
1561
1562 if (sizeof(void *) == 8)
1563 {
1564 res = p_snprintf(buffer, sizeof(buffer), "%Ix %d", (ULONG_PTR)0x1234567890, 1);
1565 ok(res == strlen(buffer), "wrong size %d\n", res);
1566 ok(!strcmp(buffer, "1234567890 1"), "got %s\n", debugstr_a(buffer));
1567
1568 res = p_snprintf(buffer, sizeof(buffer), "%zx %d", (ULONG_PTR)0x1234567890, 1);
1569 ok(res == strlen(buffer), "wrong size %d\n", res);
1570 ok(!strcmp(buffer, "1234567890 1") || broken(!strcmp(buffer, "zx 878082192")),
1571 "got %s\n", debugstr_a(buffer));
1572
1573 res = p_snprintf(buffer, sizeof(buffer), "%tx %d", (ULONG_PTR)0x1234567890, 1);
1574 ok(res == strlen(buffer), "wrong size %d\n", res);
1575 ok(!strcmp(buffer, "1234567890 1") || broken(!strcmp(buffer, "tx 878082192")),
1576 "got %s\n", debugstr_a(buffer));
1577
1578 res = p_snprintf(buffer, sizeof(buffer), "%jx %d", (ULONG_PTR)0x1234567890, 1);
1579 ok(res == strlen(buffer), "wrong size %d\n", res);
1580 ok(!strcmp(buffer, "1234567890 1") || broken(!strcmp(buffer, "jx 878082192")),
1581 "got %s\n", debugstr_a(buffer));
1582
1583 res = p_snprintf(buffer, sizeof(buffer), "%llx %d", (ULONG_PTR)0x1234567890, 1);
1584 ok(res == strlen(buffer), "wrong size %d\n", res);
1585 ok(!strcmp(buffer, "1234567890 1"), "got %s\n", debugstr_a(buffer));
1586 }
1587 else
1588 {
1589 res = p_snprintf(buffer, sizeof(buffer), "%Ix %d", (ULONG_PTR)0x123456, 1);
1590 ok(res == strlen(buffer), "wrong size %d\n", res);
1591 ok(!strcmp(buffer, "123456 1"), "got %s\n", debugstr_a(buffer));
1592
1593 res = p_snprintf(buffer, sizeof(buffer), "%zx %d", (ULONG_PTR)0x123456, 1);
1594 ok(res == strlen(buffer), "wrong size %d\n", res);
1595 ok(!strcmp(buffer, "123456 1") || broken(!strcmp(buffer, "zx 1193046")),
1596 "got %s\n", debugstr_a(buffer));
1597
1598 res = p_snprintf(buffer, sizeof(buffer), "%tx %d", (ULONG_PTR)0x123456, 1);
1599 ok(res == strlen(buffer), "wrong size %d\n", res);
1600 ok(!strcmp(buffer, "123456 1") || broken(!strcmp(buffer, "tx 1193046")),
1601 "got %s\n", debugstr_a(buffer));
1602
1603 res = p_snprintf(buffer, sizeof(buffer), "%jx %d", 0x1234567890ull, 1);
1604 ok(res == strlen(buffer), "wrong size %d\n", res);
1605 ok(!strcmp(buffer, "1234567890 1") || broken(!strcmp(buffer, "jx 878082192")),
1606 "got %s\n", debugstr_a(buffer));
1607
1608 res = p_snprintf(buffer, sizeof(buffer), "%llx %d", 0x1234567890ull, 1);
1609 ok(res == strlen(buffer), "wrong size %d\n", res);
1610 ok(!strcmp(buffer, "1234567890 1") || broken(!strcmp(buffer, "34567890 18")), /* winxp */
1611 "got %s\n", debugstr_a(buffer));
1612 }
1613}
1614
1615static void test__snprintf_s(void)
1616{
1617 char buf[32];
1618 int res;
1619
1620 if (!p_snprintf_s)
1621 {
1622 win_skip("_snprintf_s not available\n");
1623 return;
1624 }
1625
1626 memset(buf, 0xcc, sizeof(buf));
1627 res = p_snprintf_s(buf, sizeof(buf), sizeof(buf), "test");
1628 ok(res == 4, "res = %d\n", res);
1629 ok(!strcmp(buf, "test"), "buf = %s\n", buf);
1630
1631 memset(buf, 0xcc, sizeof(buf));
1632 res = p_snprintf_s(buf, 4, 4, "test");
1633 ok(res == -1, "res = %d\n", res);
1634 ok(!buf[0], "buf = %s\n", buf);
1635
1636 memset(buf, 0xcc, sizeof(buf));
1637 res = p_snprintf_s(buf, 5, 4, "test");
1638 ok(res == 4, "res = %d\n", res);
1639 ok(!strcmp(buf, "test"), "buf = %s\n", buf);
1640
1641 memset(buf, 0xcc, sizeof(buf));
1642 res = p_snprintf_s(buf, 5, 3, "test");
1643 ok(res == -1, "res = %d\n", res);
1644 ok(!strcmp(buf, "tes"), "buf = %s\n", buf);
1645
1646 memset(buf, 0xcc, sizeof(buf));
1647 res = p_snprintf_s(buf, 4, 10, "test");
1648 ok(res == -1, "res = %d\n", res);
1649 ok(!buf[0], "buf = %s\n", buf);
1650
1651 memset(buf, 0xcc, sizeof(buf));
1652 res = p_snprintf_s(buf, 6, 5, "test%c", 0);
1653 ok(res == 5, "res = %d\n", res);
1654 ok(!memcmp(buf, "test\0", 6), "buf = %s\n", buf);
1655
1656}
1657
1658static void test__snwprintf(void)
1659{
1660 const WCHAR *origstring = L"XXXXXXXXXXXX";
1661 const WCHAR *teststring = L"hello world";
1662 WCHAR buffer[32];
1663 int res;
1664
1665 res = p_snwprintf(NULL, 0, teststring);
1666 ok(res == lstrlenW(teststring), "_snprintf returned %d, expected %d.\n", res, lstrlenW(teststring));
1667
1668 res = p_snwprintf(buffer, lstrlenW(teststring) - 1, teststring);
1669 ok(res < 0, "_snprintf returned %d, expected < 0.\n", res);
1670
1671 wcscpy(buffer, origstring);
1672 res = p_snwprintf(buffer, lstrlenW(teststring), teststring);
1673 ok(res == lstrlenW(teststring), "_snprintf returned %d, expected %d.\n", res, lstrlenW(teststring));
1674 ok(!wcscmp(buffer, L"hello worldX"), "_snprintf returned buffer %s, expected 'hello worldX'.\n",
1676
1677 wcscpy(buffer, origstring);
1678 res = p_snwprintf(buffer, lstrlenW(teststring) + 1, teststring);
1679 ok(res == lstrlenW(teststring), "_snprintf returned %d, expected %d.\n", res, lstrlenW(teststring));
1680 ok(!wcscmp(buffer, teststring), "_snprintf returned buffer %s, expected %s.\n",
1681 debugstr_w(buffer), debugstr_w(teststring));
1682
1683 memset(buffer, 0xcc, sizeof(buffer));
1684 res = p_snwprintf(buffer, 4, L"test");
1685 ok(res == 4, "res = %d\n", res);
1686 ok(!memcmp(buffer, L"test", 4 * sizeof(WCHAR)), "buf = %s\n", debugstr_w(buffer));
1687 ok(buffer[4] == 0xcccc, "buffer[4] = %x\n", buffer[4]);
1688
1689 memset(buffer, 0xcc, sizeof(buffer));
1690 res = p_snwprintf(buffer, 3, L"test");
1691 ok(res == -1, "res = %d\n", res);
1692 ok(!memcmp(buffer, L"tes", 3 * sizeof(WCHAR)), "buf = %s\n", debugstr_w(buffer));
1693 ok(buffer[3] == 0xcccc, "buffer[3] = %x\n", buffer[3]);
1694
1695 memset(buffer, 0xcc, sizeof(buffer));
1696 res = p_snwprintf(buffer, 4, L"%s", L"test");
1697 ok(res == 4, "res = %d\n", res);
1698 ok(!memcmp(buffer, L"test", 4 * sizeof(WCHAR)), "buf = %s\n", debugstr_w(buffer));
1699 ok(buffer[4] == 0xcccc, "buffer[4] = %x\n", buffer[4]);
1700
1701 memset(buffer, 0xcc, sizeof(buffer));
1702 res = p_snwprintf(buffer, 3, L"%s", L"test");
1703 ok(res == -1, "res = %d\n", res);
1704 ok(!memcmp(buffer, L"tes", 3), "buf = %s\n", debugstr_w(buffer));
1705 ok(buffer[3] == 0xcccc, "buffer[3] = %x\n", buffer[3]);
1706
1707 res = p_snwprintf(buffer, ARRAY_SIZE(buffer), L"%I64x %d", (ULONGLONG)0x1234567890, 1);
1708 ok(res == lstrlenW(buffer), "wrong size %d\n", res);
1709 ok(!wcscmp(buffer, L"1234567890 1"), "got %s\n", debugstr_w(buffer));
1710
1711 res = p_snwprintf(buffer, ARRAY_SIZE(buffer), L"%I32x %d", 0x123456, 1);
1712 ok(res == lstrlenW(buffer), "wrong size %d\n", res);
1713 ok(!wcscmp(buffer, L"123456 1"), "got %s\n", debugstr_w(buffer));
1714
1715 res = p_snwprintf(buffer, ARRAY_SIZE(buffer), L"%#x %#x", 0, 1);
1716 ok(res == lstrlenW(buffer), "wrong size %d\n", res);
1717 ok(!wcscmp(buffer, L"0 0x1"), "got %s\n", debugstr_w(buffer));
1718
1719 res = p_snwprintf(buffer, ARRAY_SIZE(buffer), L"%hx %hd", 0x123456, 987654);
1720 ok(res == lstrlenW(buffer), "wrong size %d\n", res);
1721 ok(!wcscmp(buffer, L"3456 4614"), "got %s\n", debugstr_w(buffer));
1722
1723 if (sizeof(void *) == 8)
1724 {
1725 res = p_snwprintf(buffer, ARRAY_SIZE(buffer), L"%Ix %d", (ULONG_PTR)0x1234567890, 1);
1726 ok(res == lstrlenW(buffer), "wrong size %d\n", res);
1727 ok(!wcscmp(buffer, L"1234567890 1"), "got %s\n", debugstr_w(buffer));
1728
1729 res = p_snwprintf(buffer, ARRAY_SIZE(buffer), L"%zx %d", (ULONG_PTR)0x1234567890, 1);
1730 ok(res == lstrlenW(buffer), "wrong size %d\n", res);
1731 ok(!wcscmp(buffer, L"1234567890 1") || broken(!wcscmp(buffer, L"zx 878082192")),
1732 "got %s\n", debugstr_w(buffer));
1733
1734 res = p_snwprintf(buffer, ARRAY_SIZE(buffer), L"%tx %d", (ULONG_PTR)0x1234567890, 1);
1735 ok(res == lstrlenW(buffer), "wrong size %d\n", res);
1736 ok(!wcscmp(buffer, L"1234567890 1") || broken(!wcscmp(buffer, L"tx 878082192")),
1737 "got %s\n", debugstr_w(buffer));
1738
1739 res = p_snwprintf(buffer, ARRAY_SIZE(buffer), L"%jx %d", (ULONG_PTR)0x1234567890, 1);
1740 ok(res == lstrlenW(buffer), "wrong size %d\n", res);
1741 ok(!wcscmp(buffer, L"1234567890 1") || broken(!wcscmp(buffer, L"jx 878082192")),
1742 "got %s\n", debugstr_w(buffer));
1743
1744 res = p_snwprintf(buffer, ARRAY_SIZE(buffer), L"%llx %d", (ULONG_PTR)0x1234567890, 1);
1745 ok(res == lstrlenW(buffer), "wrong size %d\n", res);
1746 ok(!wcscmp(buffer, L"1234567890 1"), "got %s\n", debugstr_w(buffer));
1747 }
1748 else
1749 {
1750 res = p_snwprintf(buffer, ARRAY_SIZE(buffer), L"%Ix %d", (ULONG_PTR)0x123456, 1);
1751 ok(res == lstrlenW(buffer), "wrong size %d\n", res);
1752 ok(!wcscmp(buffer, L"123456 1"), "got %s\n", debugstr_w(buffer));
1753
1754 res = p_snwprintf(buffer, ARRAY_SIZE(buffer), L"%zx %d", (ULONG_PTR)0x123456, 1);
1755 ok(res == lstrlenW(buffer), "wrong size %d\n", res);
1756 ok(!wcscmp(buffer, L"123456 1") || broken(!wcscmp(buffer, L"zx 1193046")),
1757 "got %s\n", debugstr_w(buffer));
1758
1759 res = p_snwprintf(buffer, ARRAY_SIZE(buffer), L"%tx %d", (ULONG_PTR)0x123456, 1);
1760 ok(res == lstrlenW(buffer), "wrong size %d\n", res);
1761 ok(!wcscmp(buffer, L"123456 1") || broken(!wcscmp(buffer, L"tx 1193046")),
1762 "got %s\n", debugstr_w(buffer));
1763
1764 res = p_snwprintf(buffer, ARRAY_SIZE(buffer), L"%jx %d", 0x1234567890ull, 1);
1765 ok(res == lstrlenW(buffer), "wrong size %d\n", res);
1766 ok(!wcscmp(buffer, L"1234567890 1") || broken(!wcscmp(buffer, L"jx 878082192")),
1767 "got %s\n", debugstr_w(buffer));
1768
1769 res = p_snwprintf(buffer, ARRAY_SIZE(buffer), L"%llx %d", 0x1234567890ull, 1);
1770 ok(res == lstrlenW(buffer), "wrong size %d\n", res);
1771 ok(!wcscmp(buffer, L"1234567890 1") || broken(!wcscmp(buffer, L"34567890 18")), /* winxp */
1772 "got %s\n", debugstr_w(buffer));
1773 }
1774}
1775
1776static void test__snwprintf_s(void)
1777{
1778 WCHAR buf[32];
1779 int res;
1780
1781 if (!p_snwprintf_s)
1782 {
1783 win_skip("_snwprintf_s not available\n");
1784 return;
1785 }
1786
1787 memset(buf, 0xcc, sizeof(buf));
1788 res = p_snwprintf_s(buf, sizeof(buf), sizeof(buf), L"test");
1789 ok(res == 4, "res = %d\n", res);
1790 ok(!wcscmp(buf, L"test"), "buf = %s\n", debugstr_w(buf));
1791
1792 memset(buf, 0xcc, sizeof(buf));
1793 res = p_snwprintf_s(buf, 4, 4, L"test");
1794 ok(res == -1, "res = %d\n", res);
1795 ok(!buf[0], "buf = %s\n", debugstr_w(buf));
1796
1797 memset(buf, 0xcc, sizeof(buf));
1798 res = p_snwprintf_s(buf, 5, 4, L"test");
1799 ok(res == 4, "res = %d\n", res);
1800 ok(!wcscmp(buf, L"test"), "buf = %s\n", debugstr_w(buf));
1801
1802 memset(buf, 0xcc, sizeof(buf));
1803 res = p_snwprintf_s(buf, 5, 3, L"test");
1804 ok(res == -1, "res = %d\n", res);
1805 ok(!wcscmp(buf, L"tes"), "buf = %s\n", debugstr_w(buf));
1806
1807 memset(buf, 0xcc, sizeof(buf));
1808 res = p_snwprintf_s(buf, 4, 10, L"test");
1809 ok(res == -1, "res = %d\n", res);
1810 ok(!buf[0], "buf = %s\n", debugstr_w(buf));
1811
1812 memset(buf, 0xcc, sizeof(buf));
1813 res = p_snwprintf_s(buf, 6, 5, L"test%c", 0);
1814 ok(res == 5, "res = %d\n", res);
1815 ok(!memcmp(buf, L"test\0", 6 * sizeof(WCHAR)), "buf = %s\n", debugstr_w(buf));
1816
1817}
1818
1819static void test_printf_format(void)
1820{
1821 const struct
1822 {
1823 const char *spec;
1824 unsigned int arg_size;
1825 const char *expected;
1826 const WCHAR *expectedw;
1827 ULONG64 arg;
1828 const void *argw;
1829 }
1830 tests[] =
1831 {
1832 { "%qu", 0, "qu", NULL, 10 },
1833 { "%ll", 0, "", NULL, 10 },
1834 { "%lu", sizeof(ULONG), "65537", NULL, 65537 },
1835 { "%llu", sizeof(ULONG64), "10", NULL, 10 },
1836 { "%lllllllu", sizeof(ULONG64), "10", NULL, 10 },
1837 { "%#lx", sizeof(ULONG), "0xa", NULL, 10 },
1838 { "%#llx", sizeof(ULONG64), "0x1000000000", NULL, 0x1000000000 },
1839 { "%#lllx", sizeof(ULONG64), "0x1000000000", NULL, 0x1000000000 },
1840 { "%hu", sizeof(ULONG), "1", NULL, 65537 },
1841 { "%hlu", sizeof(ULONG), "1", NULL, 65537 },
1842 { "%hllx", sizeof(ULONG64), "100000010", NULL, 0x100000010 },
1843 { "%hlllx", sizeof(ULONG64), "100000010", NULL, 0x100000010 },
1844 { "%llhx", sizeof(ULONG64), "100000010", NULL, 0x100000010 },
1845 { "%lllhx", sizeof(ULONG64), "100000010", NULL, 0x100000010 },
1846 { "%lhu", sizeof(ULONG), "1", NULL, 65537 },
1847 { "%hhu", sizeof(ULONG), "1", NULL, 65537 },
1848 { "%hwu", sizeof(ULONG), "1", NULL, 65537 },
1849 { "%whu", sizeof(ULONG), "1", NULL, 65537 },
1850 { "%##lhllwlx", sizeof(ULONG64), "0x1000000010", NULL, 0x1000000010 },
1851 { "%##lhlwlx", sizeof(ULONG), "0x10", NULL, 0x1000000010 },
1852 { "%04lhlwllx", sizeof(ULONG64), "1000000010", NULL, 0x1000000010 },
1853 { "%s", sizeof(ULONG_PTR), "str", NULL, (ULONG_PTR)"str", L"str" },
1854 { "%S", sizeof(ULONG_PTR), "str", NULL, (ULONG_PTR)L"str", "str" },
1855 { "%ls", sizeof(ULONG_PTR), "str", NULL, (ULONG_PTR)L"str" },
1856 { "%lS", sizeof(ULONG_PTR), "str", NULL, (ULONG_PTR)L"str" },
1857 { "%lls", sizeof(ULONG_PTR), "str", NULL, (ULONG_PTR)"str", L"str" },
1858 { "%llS", sizeof(ULONG_PTR), "str", NULL, (ULONG_PTR)L"str", "str" },
1859 { "%llls", sizeof(ULONG_PTR), "str", NULL, (ULONG_PTR)L"str" },
1860 { "%lllS", sizeof(ULONG_PTR), "str", NULL, (ULONG_PTR)L"str" },
1861 { "%lllls", sizeof(ULONG_PTR), "str", NULL, (ULONG_PTR)"str", L"str" },
1862 { "%llllS", sizeof(ULONG_PTR), "str", NULL, (ULONG_PTR)L"str", "str" },
1863 { "%hs", sizeof(ULONG_PTR), "str", NULL, (ULONG_PTR)"str" },
1864 { "%hS", sizeof(ULONG_PTR), "str", NULL, (ULONG_PTR)"str" },
1865 { "%ws", sizeof(ULONG_PTR), "str", NULL, (ULONG_PTR)L"str" },
1866 { "%wS", sizeof(ULONG_PTR), "str", NULL, (ULONG_PTR)L"str" },
1867 { "%hhs", sizeof(ULONG_PTR), "str", NULL, (ULONG_PTR)"str" },
1868 { "%hhS", sizeof(ULONG_PTR), "str", NULL, (ULONG_PTR)"str" },
1869 { "%wws", sizeof(ULONG_PTR), "str", NULL, (ULONG_PTR)L"str" },
1870 { "%wwS", sizeof(ULONG_PTR), "str", NULL, (ULONG_PTR)L"str" },
1871 { "%wwws", sizeof(ULONG_PTR), "str", NULL, (ULONG_PTR)L"str" },
1872 { "%wwwS", sizeof(ULONG_PTR), "str", NULL, (ULONG_PTR)L"str" },
1873 { "%hws", sizeof(ULONG_PTR), "str", NULL, (ULONG_PTR)L"str", "str" },
1874 { "%hwS", sizeof(ULONG_PTR), "str", NULL, (ULONG_PTR)L"str", "str" },
1875 { "%whs", sizeof(ULONG_PTR), "str", NULL, (ULONG_PTR)L"str", "str" },
1876 { "%whS", sizeof(ULONG_PTR), "str", NULL, (ULONG_PTR)L"str", "str" },
1877 { "%hwls", sizeof(ULONG_PTR), "str", NULL, (ULONG_PTR)L"str", "str" },
1878 { "%hwlls", sizeof(ULONG_PTR), "str", NULL, (ULONG_PTR)L"str", "str" },
1879 { "%hwlS", sizeof(ULONG_PTR), "str", NULL, (ULONG_PTR)L"str", "str" },
1880 { "%hwllS", sizeof(ULONG_PTR), "str", NULL, (ULONG_PTR)L"str", "str" },
1881 { "%lhws", sizeof(ULONG_PTR), "str", NULL, (ULONG_PTR)L"str", "str" },
1882 { "%llhws", sizeof(ULONG_PTR), "str", NULL, (ULONG_PTR)L"str", "str" },
1883 { "%lhwS", sizeof(ULONG_PTR), "str", NULL, (ULONG_PTR)L"str", "str" },
1884 { "%llhwS", sizeof(ULONG_PTR), "str", NULL, (ULONG_PTR)L"str", "str" },
1885 { "%c", sizeof(SHORT), "\xc8", L"\x95c8", 0x95c8 },
1886 { "%lc", sizeof(SHORT), "\x3f", L"\x95c8", 0x95c8 },
1887 { "%llc", sizeof(SHORT), "\xc8", L"\x95c8", 0x95c8 },
1888 { "%lllc", sizeof(SHORT), "\x3f", L"\x95c8", 0x95c8 },
1889 { "%llllc", sizeof(SHORT), "\xc8", L"\x95c8", 0x95c8 },
1890 { "%lllllc", sizeof(SHORT), "\x3f", L"\x95c8", 0x95c8 },
1891 { "%C", sizeof(SHORT), "\x3f", L"\xc8", 0x95c8 },
1892 { "%lC", sizeof(SHORT), "\x3f", L"\x95c8", 0x95c8 },
1893 { "%llC", sizeof(SHORT), "\x3f", L"\xc8", 0x95c8 },
1894 { "%lllC", sizeof(SHORT), "\x3f", L"\x95c8", 0x95c8 },
1895 { "%llllC", sizeof(SHORT), "\x3f", L"\xc8", 0x95c8 },
1896 { "%lllllC", sizeof(SHORT), "\x3f", L"\x95c8", 0x95c8 },
1897 { "%hc", sizeof(BYTE), "\xc8", L"\xc8", 0x95c8 },
1898 { "%hhc", sizeof(BYTE), "\xc8", L"\xc8", 0x95c8 },
1899 { "%hhhc", sizeof(BYTE), "\xc8", L"\xc8", 0x95c8 },
1900 { "%wc", sizeof(BYTE), "\x3f", L"\x95c8", 0x95c8 },
1901 { "%wC", sizeof(BYTE), "\x3f", L"\x95c8", 0x95c8 },
1902 { "%hwc", sizeof(BYTE), "\x3f", L"\xc8", 0x95c8 },
1903 { "%whc", sizeof(BYTE), "\x3f", L"\xc8", 0x95c8 },
1904 { "%hwC", sizeof(BYTE), "\x3f", L"\xc8", 0x95c8 },
1905 { "%whC", sizeof(BYTE), "\x3f", L"\xc8", 0x95c8 },
1906 { "%I64u", sizeof(ULONG64), "10", NULL, 10 },
1907 { "%llI64u", sizeof(ULONG64), "10", NULL, 10 },
1908 { "%I64llu", sizeof(ULONG64), "10", NULL, 10 },
1909 { "%I64s", sizeof(ULONG_PTR), "str", NULL, (ULONG_PTR)"str", L"str" },
1910 { "%q%u", sizeof(ULONG), "q10", NULL, 10 },
1911 { "%lhw%u", 0, "%u", NULL, 10 },
1912 { "%u% ", sizeof(ULONG), "10", NULL, 10 },
1913 { "%u% %u", sizeof(ULONG), "10%u", NULL, 10 },
1914 { "% ll u", 0, " u", NULL, 10 },
1915 { "% llu", sizeof(ULONG64), "10", NULL, 10 },
1916 { "%# llx", sizeof(ULONG64), "0xa", NULL, 10 },
1917 { "% #llx", sizeof(ULONG64), "0xa", NULL, 10 },
1918 };
1919 WCHAR ws[256], expectedw[256], specw[256];
1920 unsigned int i, j;
1921 char expected[256], spec[256], s[256];
1922 int len;
1923
1924 p_snprintf(s, ARRAY_SIZE(s), "%C", 0x95c8);
1925 p_snwprintf(ws, ARRAY_SIZE(ws), L"%c", 0x95c8);
1926 p_snwprintf(expectedw, ARRAY_SIZE(expectedw), L"%C", 0x95c8);
1927 if (s[0] != 0x3f || ws[0] != 0x95c8 || expectedw[0] != 0xc8)
1928 {
1929 /* The test is not designed for testing locale but some of the test expected results depend on locale. */
1930 skip("An English non-UTF8 locale is required for the printf tests.\n");
1931 return;
1932 }
1933
1934 for (i = 0; i < ARRAY_SIZE(tests); ++i)
1935 {
1936 strcpy(spec, tests[i].spec);
1937 winetest_push_context("%s", spec);
1938 strcat(spec,"|%s");
1939 *s = 0;
1940 *ws = 0;
1941 j = 0;
1942 do
1943 specw[j] = spec[j];
1944 while (specw[j++]);
1945 if (tests[i].argw)
1946 len = p_snwprintf(ws, ~(size_t)0, specw, tests[i].argw, L"end");
1947 switch (tests[i].arg_size)
1948 {
1949 case 0:
1950 p_snprintf(s, ~(size_t)0, spec, "end");
1951 len = p_snwprintf(ws, ~(size_t)0, specw, L"end");
1952 break;
1953 case 1:
1954 case 2:
1955 case 4:
1956 p_snprintf(s, ARRAY_SIZE(s), spec, (ULONG)tests[i].arg, "end");
1957 if (!tests[i].argw)
1958 len = p_snwprintf(ws, ~(size_t)0, specw, (ULONG)tests[i].arg, L"end");
1959 break;
1960 case 8:
1961 p_snprintf(s, ~(size_t)0, spec, (ULONG64)tests[i].arg, "end");
1962 if (!tests[i].argw)
1963 len = p_snwprintf(ws, ~(size_t)0, specw, (ULONG64)tests[i].arg, L"end");
1964 break;
1965 default:
1966 len = 0;
1967 ok(0, "unknown length %u.\n", tests[i].arg_size);
1968 break;
1969 }
1970#ifdef __REACTOS__
1971 if (!is_reactos() && (GetNTVersion() < _WIN32_WINNT_VISTA) && (len == -1))
1972 {
1973 win_skip("Skipping unsupported format test %u ('%s') on Windows 2003.\n", i, tests[i].spec);
1975 continue;
1976 }
1977#endif
1979 strcat(expected, "|end");
1980 ok(len == strlen(expected), "got len %d, expected %Id.\n", len, strlen(expected));
1981 ok(!strcmp(s, expected), "got %s, expected %s.\n", debugstr_a(s), debugstr_a(expected));
1982 if (tests[i].expectedw)
1983 {
1984 wcscpy(expectedw, tests[i].expectedw);
1985 wcscat(expectedw, L"|end");
1986 }
1987 else
1988 {
1989 for (j = 0; j < len; ++j)
1990 expectedw[j] = expected[j];
1991 }
1992 expectedw[len] = 0;
1993 ok(!wcscmp(ws, expectedw), "got %s, expected %s.\n", debugstr_w(ws), debugstr_w(expectedw));
1995 }
1996}
1997
1998static void test_tolower(void)
1999{
2000 int i, ret, exp_ret;
2001
2002#ifndef __REACTOS__ // This is nonsense
2003 if (!GetProcAddress(GetModuleHandleA("ntdll"), "NtRemoveIoCompletionEx"))
2004 {
2005 win_skip("tolower tests\n");
2006 return;
2007 }
2008#endif // __REACTOS__
2009
2010 ok(ptolower != NULL, "tolower is not available\n");
2011
2012 for (i = -512; i < 512; i++)
2013 {
2014 exp_ret = (char)i >= 'A' && (char)i <= 'Z' ? i - 'A' + 'a' : i;
2015 ret = ptolower(i);
2016 ok(ret == exp_ret, "tolower(%d) = %d\n", i, ret);
2017 }
2018}
2019
2020static void test_toupper(void)
2021{
2022
2023 int i, ret, exp_ret;
2024 char str[3], *p;
2025 WCHAR wc;
2026
2027 ok(ptoupper != NULL, "toupper is not available\n");
2028
2029 for (i = -512; i < 0xffff; i++)
2030 {
2031 str[0] = i;
2032 str[1] = i >> 8;
2033 str[2] = 0;
2034 p = str;
2035 wc = RtlAnsiCharToUnicodeChar( &p );
2036 wc = RtlUpcaseUnicodeChar( wc );
2037 ret = WideCharToMultiByte( CP_ACP, 0, &wc, 1, str, 2, NULL, NULL );
2038 ok(!ret || ret == 1 || ret == 2, "WideCharToMultiByte returned %d\n", ret);
2039 if (ret == 2)
2040 exp_ret = (unsigned char)str[1] + ((unsigned char)str[0] << 8);
2041 else if (ret == 1)
2042 exp_ret = (unsigned char)str[0];
2043 else
2044 exp_ret = (WCHAR)i;
2045
2046 ret = (WCHAR)ptoupper(i);
2047 ok(ret == exp_ret, "toupper(%x) = %x, expected %x\n", i, ret, exp_ret);
2048 }
2049}
2050
2051static void test__strnicmp(void)
2052{
2053 BOOL is_win64 = (sizeof(void *) > sizeof(int));
2054 int ret;
2055
2056 ok(p_strnicmp != NULL, "_strnicmp is not available\n");
2057
2058 ret = p_strnicmp("a", "C", 1);
2059 ok(ret == (is_win64 ? -2 : -1), "_strnicmp returned %d\n", ret);
2060 ret = p_strnicmp("a", "c", 1);
2061 ok(ret == (is_win64 ? -2 : -1), "_strnicmp returned %d\n", ret);
2062 ret = p_strnicmp("C", "a", 1);
2063 ok(ret == (is_win64 ? 2 : 1), "_strnicmp returned %d\n", ret);
2064 ret = p_strnicmp("c", "a", 1);
2065 ok(ret == (is_win64 ? 2 : 1), "_strnicmp returned %d\n", ret);
2066 ret = p_strnicmp("ijk0", "IJK1", 3);
2067 ok(!ret, "_strnicmp returned %d\n", ret);
2068 ret = p_strnicmp("ijk0", "IJK1", 4);
2069 ok(ret == -1, "_strnicmp returned %d\n", ret);
2070 ret = p_strnicmp("ijk\0X", "IJK\0Y", 5);
2071 ok(!ret, "_strnicmp returned %d\n", ret);
2072}
2073
2074static void test_sscanf(void)
2075{
2076 double d = 0.0;
2077 float f = 0.0f;
2078 int i = 0;
2079 int ret;
2080
2081 ret = psscanf("10", "%d", &i);
2082 ok(ret == 1, "ret = %d\n", ret);
2083 ok(i == 10, "i = %d\n", i);
2084
2085 ret = psscanf("10", "%f", &f);
2086 ok(ret == 0 || broken(ret == 1) /* xp/2003 */, "ret = %d\n", ret);
2087 ok(f == 0.0f, "f = %f\n", f);
2088
2089 ret = psscanf("10", "%g", &f);
2090 ok(ret == 0 || broken(ret == 1) /* xp/2003 */, "ret = %d\n", ret);
2091 ok(f == 0.0f, "f = %f\n", f);
2092
2093 ret = psscanf("10", "%e", &f);
2094 ok(ret == 0 || broken(ret == 1) /* xp/2003 */, "ret = %d\n", ret);
2095 ok(f == 0.0f, "f = %f\n", f);
2096
2097 ret = psscanf("10", "%lf", &d);
2098 ok(ret == 0 || broken(ret == 1) /* xp/2003 */, "ret = %d\n", ret);
2099 ok(d == 0.0, "d = %lf\n", f);
2100
2101 ret = psscanf("10", "%lg", &d);
2102 ok(ret == 0 || broken(ret == 1) /* xp/2003 */, "ret = %d\n", ret);
2103 ok(d == 0.0, "d = %lf\n", f);
2104
2105 ret = psscanf("10", "%le", &d);
2106 ok(ret == 0 || broken(ret == 1) /* xp/2003 */, "ret = %d\n", ret);
2107 ok(d == 0.0, "d = %lf\n", f);
2108}
2109
2110static const unsigned short wctypes[256] =
2111{
2112 /* 00 */
2113 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020,
2114 0x0020, 0x0068, 0x0028, 0x0028, 0x0028, 0x0028, 0x0020, 0x0020,
2115 /* 10 */
2116 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020,
2117 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020,
2118 /* 20 */
2119 0x0048, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010,
2120 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010,
2121 /* 30 */
2122 0x0084, 0x0084, 0x0084, 0x0084, 0x0084, 0x0084, 0x0084, 0x0084,
2123 0x0084, 0x0084, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010,
2124 /* 40 */
2125 0x0010, 0x0181, 0x0181, 0x0181, 0x0181, 0x0181, 0x0181, 0x0101,
2126 0x0101, 0x0101, 0x0101, 0x0101, 0x0101, 0x0101, 0x0101, 0x0101,
2127 /* 50 */
2128 0x0101, 0x0101, 0x0101, 0x0101, 0x0101, 0x0101, 0x0101, 0x0101,
2129 0x0101, 0x0101, 0x0101, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010,
2130 /* 60 */
2131 0x0010, 0x0182, 0x0182, 0x0182, 0x0182, 0x0182, 0x0182, 0x0102,
2132 0x0102, 0x0102, 0x0102, 0x0102, 0x0102, 0x0102, 0x0102, 0x0102,
2133 /* 70 */
2134 0x0102, 0x0102, 0x0102, 0x0102, 0x0102, 0x0102, 0x0102, 0x0102,
2135 0x0102, 0x0102, 0x0102, 0x0010, 0x0010, 0x0010, 0x0010, 0x0020,
2136 /* 80 */
2137 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020,
2138 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020,
2139 /* 90 */
2140 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020,
2141 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020,
2142 /* a0 */
2143 0x0048, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010,
2144 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010,
2145 /* b0 */
2146 0x0010, 0x0010, 0x0014, 0x0014, 0x0010, 0x0010, 0x0010, 0x0010,
2147 0x0010, 0x0014, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010,
2148 /* c0 */
2149 0x0101, 0x0101, 0x0101, 0x0101, 0x0101, 0x0101, 0x0101, 0x0101,
2150 0x0101, 0x0101, 0x0101, 0x0101, 0x0101, 0x0101, 0x0101, 0x0101,
2151 /* d0 */
2152 0x0101, 0x0101, 0x0101, 0x0101, 0x0101, 0x0101, 0x0101, 0x0010,
2153 0x0101, 0x0101, 0x0101, 0x0101, 0x0101, 0x0101, 0x0101, 0x0102,
2154 /* e0 */
2155 0x0102, 0x0102, 0x0102, 0x0102, 0x0102, 0x0102, 0x0102, 0x0102,
2156 0x0102, 0x0102, 0x0102, 0x0102, 0x0102, 0x0102, 0x0102, 0x0102,
2157 /* f0 */
2158 0x0102, 0x0102, 0x0102, 0x0102, 0x0102, 0x0102, 0x0102, 0x0010,
2159 0x0102, 0x0102, 0x0102, 0x0102, 0x0102, 0x0102, 0x0102, 0x0102
2160};
2161
2162static void test_wctype(void)
2163{
2164 int i;
2165
2166 for (i = 0; i < 65536; i++)
2167 {
2168 unsigned short type = (i < 256 ? wctypes[i] : 0);
2169 ok( piswctype( i, 0xffff ) == type, "%u: wrong type %x\n", i, piswctype( i, 0xffff ));
2170 ok( piswalpha( i ) == (type & (C1_ALPHA|C1_LOWER|C1_UPPER)), "%u: wrong iswalpha\n", i );
2171 ok( piswdigit( i ) == (type & C1_DIGIT), "%u: wrong iswdigit\n", i );
2172 ok( piswlower( i ) == (type & C1_LOWER), "%u: wrong iswlower\n", i );
2173 ok( piswspace( i ) == (type & C1_SPACE), "%u: wrong iswspace\n", i );
2174 ok( piswxdigit( i ) == (type & C1_XDIGIT), "%u: wrong iswxdigit\n", i );
2175 }
2176}
2177
2178/* we could reuse wctypes except for TAB, which doesn't have C1_BLANK for some reason... */
2179static const unsigned short ctypes[256] =
2180{
2181 /* 00 */
2182 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020,
2183 0x0020, 0x0028, 0x0028, 0x0028, 0x0028, 0x0028, 0x0020, 0x0020,
2184 /* 10 */
2185 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020,
2186 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020,
2187 /* 20 */
2188 0x0048, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010,
2189 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010,
2190 /* 30 */
2191 0x0084, 0x0084, 0x0084, 0x0084, 0x0084, 0x0084, 0x0084, 0x0084,
2192 0x0084, 0x0084, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010,
2193 /* 40 */
2194 0x0010, 0x0181, 0x0181, 0x0181, 0x0181, 0x0181, 0x0181, 0x0101,
2195 0x0101, 0x0101, 0x0101, 0x0101, 0x0101, 0x0101, 0x0101, 0x0101,
2196 /* 50 */
2197 0x0101, 0x0101, 0x0101, 0x0101, 0x0101, 0x0101, 0x0101, 0x0101,
2198 0x0101, 0x0101, 0x0101, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010,
2199 /* 60 */
2200 0x0010, 0x0182, 0x0182, 0x0182, 0x0182, 0x0182, 0x0182, 0x0102,
2201 0x0102, 0x0102, 0x0102, 0x0102, 0x0102, 0x0102, 0x0102, 0x0102,
2202 /* 70 */
2203 0x0102, 0x0102, 0x0102, 0x0102, 0x0102, 0x0102, 0x0102, 0x0102,
2204 0x0102, 0x0102, 0x0102, 0x0010, 0x0010, 0x0010, 0x0010, 0x0020
2205};
2206
2207static void test_ctype(void)
2208{
2209 int i;
2210
2211 for (i = -1; i < 256; i++)
2212 {
2213 unsigned short type = (i >= 0 ? ctypes[i] : 0);
2214 ok( pisalnum( i ) == (type & (C1_DIGIT|C1_LOWER|C1_UPPER)), "%u: wrong isalnum %x / %x\n", i, pisalnum(i), type );
2215 ok( pisalpha( i ) == (type & (C1_LOWER|C1_UPPER)), "%u: wrong isalpha %x / %x\n", i, pisalpha(i), type );
2216 ok( piscntrl( i ) == (type & C1_CNTRL), "%u: wrong iscntrl %x / %x\n", i, piscntrl( i ), type );
2217 ok( pisdigit( i ) == (type & C1_DIGIT), "%u: wrong isdigit %x / %x\n", i, pisdigit( i ), type );
2218 ok( pisgraph( i ) == (type & (C1_DIGIT|C1_PUNCT|C1_LOWER|C1_UPPER)), "%u: wrong isgraph %x / %x\n", i, pisgraph( i ), type );
2219 ok( pislower( i ) == (type & C1_LOWER), "%u: wrong islower %x / %x\n", i, pislower( i ), type );
2220 ok( pisprint( i ) == (type & (C1_DIGIT|C1_BLANK|C1_PUNCT|C1_LOWER|C1_UPPER)), "%u: wrong isprint %x / %x\n", i, pisprint( i ), type );
2221 ok( pispunct( i ) == (type & C1_PUNCT), "%u: wrong ispunct %x / %x\n", i, pispunct( i ), type );
2222 ok( pisspace( i ) == (type & C1_SPACE), "%u: wrong isspace %x / %x\n", i, pisspace( i ), type );
2223 ok( pisupper( i ) == (type & C1_UPPER), "%u: wrong isupper %x / %x\n", i, pisupper( i ), type );
2224 ok( pisxdigit( i ) == (type & C1_XDIGIT), "%u: wrong isxdigit %x / %x\n", i, pisxdigit( i ), type );
2225 }
2226}
2227
2228static void test_memchr(void)
2229{
2230 const char s[] = "ab";
2231 char *r;
2232
2233 r = pmemchr(s, 'z', 2);
2234 ok(!r, "memchr returned %p, expected NULL\n", r);
2235
2236 r = pmemchr(s, 'a', 2);
2237 ok(r == s, "memchr returned %p, expected %p\n", r, s);
2238
2239 r = pmemchr(s, 0x100 + 'a', 2);
2240 ok(r == s, "memchr returned %p, expected %p\n", r, s);
2241
2242 r = pmemchr(s, -0x100 + 'a', 2);
2243 ok(r == s, "memchr returned %p, expected %p\n", r, s);
2244}
2245
2247{
2249
2250 test_ulongtoa();
2252 test_atoi64();
2253 test_ulongtow();
2255 test_wtoi();
2256 test_wtol();
2257 test_wtoi64();
2258 test_wcstol();
2259 test_wcschr();
2260 test_wcsrchr();
2262 test_atoi();
2263 test_atol();
2264 test_qsort();
2265 test_bsearch();
2271 test_tolower();
2272 test_toupper();
2274 test_wcsicmp();
2275 test_sscanf();
2276 test_wctype();
2277 test_ctype();
2278 test_memchr();
2279}
static PFN_strnicmp p_strnicmp
Definition: _strnicmp.c:14
static PFN_wcsicmp p_wcsicmp
Definition: _wcsicmp.c:14
static PFN_wcslwr p_wcslwr
Definition: _wcslwr.c:14
static PFN_wcsnicmp p_wcsnicmp
Definition: _wcsnicmp.c:14
static PFN_wcsupr p_wcsupr
Definition: _wcsupr.c:14
#define isspace(c)
Definition: acclib.h:69
#define islower(c)
Definition: acclib.h:72
#define isalpha(c)
Definition: acclib.h:74
#define isdigit(c)
Definition: acclib.h:68
#define isprint(c)
Definition: acclib.h:73
#define isxdigit(c)
Definition: acclib.h:70
#define isupper(c)
Definition: acclib.h:71
#define VOID
Definition: acefi.h:82
#define GetNTVersion()
Definition: apitest.h:17
#define ok(value,...)
Definition: atltest.h:57
#define skip(...)
Definition: atltest.h:64
#define broken(x)
Definition: atltest.h:178
#define START_TEST(x)
Definition: atltest.h:75
#define ARRAY_SIZE(A)
Definition: main.h:20
r l[0]
Definition: byte_order.h:168
Definition: bufpool.h:45
#define NULL
Definition: types.h:112
#define NTSTATUS
Definition: precomp.h:19
#define wcschr
Definition: compat.h:17
#define wcsrchr
Definition: compat.h:16
#define CP_ACP
Definition: compat.h:109
#define GetProcAddress(x, y)
Definition: compat.h:753
static __inline const char * wine_dbgstr_longlong(ULONGLONG ll)
Definition: compat.h:49
#define _strnicmp(_String1, _String2, _MaxCount)
Definition: compat.h:23
#define WideCharToMultiByte
Definition: compat.h:111
#define lstrlenW
Definition: compat.h:750
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
Definition: loader.c:812
HINSTANCE WINAPI DECLSPEC_HOTPATCH LoadLibraryA(LPCSTR lpLibFileName)
Definition: loader.c:111
int WINAPI lstrcmpA(LPCSTR str1, LPCSTR str2)
Definition: string.c:58
int WINAPI lstrcmpiA(LPCSTR str1, LPCSTR str2)
Definition: string.c:74
int CDECL iscntrl(int c)
Definition: ctype.c:246
int CDECL isgraph(int c)
Definition: ctype.c:278
int CDECL isalnum(int c)
Definition: ctype.c:214
int CDECL ispunct(int c)
Definition: ctype.c:334
int CDECL tolower(int c)
Definition: ctype.c:572
int CDECL toupper(int c)
Definition: ctype.c:514
#define __cdecl
Definition: corecrt.h:121
unsigned int size_t
Definition: corecrt.h:203
_ACRTIMP int __cdecl _snwprintf_s(wchar_t *, size_t, size_t, const wchar_t *,...)
Definition: wcs.c:1520
_ACRTIMP int __cdecl _snwprintf(wchar_t *, size_t, const wchar_t *,...)
Definition: wcs.c:1493
_ACRTIMP __msvcrt_long __cdecl _wtol(const wchar_t *)
Definition: wcs.c:2798
_ACRTIMP __int64 __cdecl _wtoi64(const wchar_t *)
Definition: wcs.c:3040
_ACRTIMP __msvcrt_ulong __cdecl wcstoul(const wchar_t *, wchar_t **, int)
Definition: wcs.c:2912
_ACRTIMP __msvcrt_long __cdecl wcstol(const wchar_t *, wchar_t **, int)
Definition: wcs.c:2747
_ACRTIMP int __cdecl _wtoi(const wchar_t *)
Definition: wcs.c:2773
_ACRTIMP int __cdecl _wcsicmp(const wchar_t *, const wchar_t *)
Definition: wcs.c:159
_ACRTIMP int __cdecl wcscmp(const wchar_t *, const wchar_t *)
Definition: wcs.c:1972
_ACRTIMP int __cdecl memcmp(const void *, const void *, size_t)
Definition: string.c:2802
_ACRTIMP int __cdecl _wcsnicmp(const wchar_t *, const wchar_t *, size_t)
Definition: wcs.c:195
#define ULONG_MAX
Definition: limits.h:31
#define LONG_MAX
Definition: limits.h:30
#define LONG_MIN
Definition: limits.h:29
_ACRTIMP void __cdecl qsort(void *, size_t, size_t, int(__cdecl *)(const void *, const void *))
_ACRTIMP int __cdecl _ACRTIMP int __cdecl _snprintf_s(char *, size_t, size_t, const char *,...) __WINE_CRT_PRINTF_ATTR(4
_ACRTIMP int __cdecl _ACRTIMP int __cdecl _ACRTIMP int __cdecl _ACRTIMP int __cdecl _ACRTIMP int __cdecl _ACRTIMP int __cdecl _ACRTIMP int __cdecl sscanf(const char *, const char *,...) __WINE_CRT_SCANF_ATTR(2
static int __cdecl _snprintf(char *buffer, size_t size, const char *format,...) __WINE_CRT_PRINTF_ATTR(3
Definition: stdio.h:507
_ACRTIMP int __cdecl atoi(const char *)
Definition: string.c:1715
_ACRTIMP size_t __cdecl strlen(const char *)
Definition: string.c:1592
char *CDECL _i64toa(__int64 value, char *str, int radix)
Definition: string.c:2247
__int64 CDECL _atoi64(const char *str)
Definition: string.c:1757
wchar_t *CDECL _itow(int value, wchar_t *str, int radix)
Definition: string.c:2135
wchar_t *CDECL _ui64tow(unsigned __int64 value, wchar_t *str, int radix)
Definition: string.c:2223
char *CDECL _ui64toa(unsigned __int64 value, char *str, int radix)
Definition: string.c:2175
int __cdecl strcmp(const char *str1, const char *str2)
Definition: string.c:3319
wchar_t *CDECL _ltow(__msvcrt_long value, wchar_t *str, int radix)
Definition: string.c:2143
wchar_t *CDECL _i64tow(__int64 value, wchar_t *str, int radix)
Definition: string.c:2289
wchar_t *CDECL _ultow(__msvcrt_ulong value, wchar_t *str, int radix)
Definition: string.c:2199
__msvcrt_long CDECL atol(const char *str)
Definition: string.c:1782
unsigned char
Definition: typeof.h:29
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31
return ret
Definition: mutex.c:146
#define L(x)
Definition: resources.c:13
#define ULONG_PTR
Definition: config.h:101
UNICODE_STRING * PUNICODE_STRING
Definition: env_spec_w32.h:373
unsigned int BOOL
Definition: ntddk_ex.h:94
std::wstring STRING
Definition: fontsub.cpp:33
int __cdecl iswctype(wint_t wc, wctype_t wctypeFlags)
Definition: freeldr.c:166
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
GLdouble s
Definition: gl.h:2039
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
GLdouble GLdouble GLdouble GLdouble q
Definition: gl.h:2063
GLuint res
Definition: glext.h:9613
GLuint buffer
Definition: glext.h:5915
GLenum GLint GLuint mask
Definition: glext.h:6028
GLfloat f
Definition: glext.h:7540
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
GLuint64EXT * result
Definition: glext.h:11304
GLfloat GLfloat p
Definition: glext.h:8902
GLenum GLsizei len
Definition: glext.h:6722
GLboolean GLboolean GLboolean GLboolean a
Definition: glext.h:6204
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
Definition: glfuncs.h:250
#define C1_CNTRL
Definition: unicode.h:36
#define C1_DIGIT
Definition: unicode.h:33
#define C1_PUNCT
Definition: unicode.h:35
#define C1_SPACE
Definition: unicode.h:34
#define C1_ALPHA
Definition: unicode.h:39
#define C1_BLANK
Definition: unicode.h:37
#define C1_LOWER
Definition: unicode.h:32
#define C1_UPPER
Definition: unicode.h:31
#define C1_XDIGIT
Definition: unicode.h:38
static const WCHAR emptyW[]
Definition: navigate.c:40
#define d
Definition: ke_i.h:81
#define a
Definition: ke_i.h:78
#define b
Definition: ke_i.h:79
#define debugstr_a
Definition: kernel32.h:31
#define debugstr_w
Definition: kernel32.h:32
#define wine_dbgstr_w
Definition: kernel32.h:34
static const BOOL is_win64
Definition: kernelbase.h:49
int WINAPI lstrlenA(LPCSTR lpString)
Definition: lstring.c:145
#define win_skip
Definition: minitest.h:67
void __cdecl void __cdecl void __cdecl void __cdecl void __cdecl void winetest_pop_context(void)
void __cdecl void __cdecl void __cdecl void __cdecl void __cdecl winetest_push_context(const char *fmt,...) __WINE_PRINTF_ATTR(1
Definition: test.h:537
#define memchr(s, c, n)
Definition: mkisofs.h:875
unsigned __int64 ULONG64
Definition: imports.h:198
static struct test_info tests[]
BOOL expected
Definition: store.c:2000
static void test_tolower(void)
Definition: string.c:3333
static void test_atoi(void)
Definition: string.c:3756
static void test_toupper(void)
Definition: string.c:5005
static void test_atol(void)
Definition: string.c:3773
static HMODULE hntdll
Definition: string.c:38
static const str2long_t str2long[]
Definition: string.c:853
static int __cdecl istrcomparefunc(const void *a, const void *b)
Definition: string.c:1380
static void one_itoa_test(int test_num, const ulong2str_t *ulong2str)
Definition: string.c:287
static void test_ulongtow(void)
Definition: string.c:469
static void test_ulonglongtow(void)
Definition: string.c:812
static LPSTR
Definition: string.c:48
static void one_ui64toa_test(int test_num, const ulonglong2str_t *ulonglong2str)
Definition: string.c:691
static void one_i64tow_test(int test_num, const ulonglong2str_t *ulonglong2str)
Definition: string.c:726
static const char static unsigned short
Definition: string.c:89
static const ulong2str_t ulong2str[]
Definition: string.c:186
static void test_printf_format(void)
Definition: string.c:1819
static void test__snwprintf(void)
Definition: string.c:1658
#define ULL(a, b)
Definition: string.c:511
static int __cdecl intcomparefunc(const void *a, const void *b)
Definition: string.c:1352
static const ulonglong2str_t ulonglong2str[]
Definition: string.c:521
static void test__strnicmp(void)
Definition: string.c:2051
static void test_wcsicmp(void)
Definition: string.c:1330
static void test_sscanf(void)
Definition: string.c:2074
static void test__snprintf(void)
Definition: string.c:1485
static void test_ctype(void)
Definition: string.c:2207
static int __cdecl charcomparefunc(const void *a, const void *b)
Definition: string.c:1361
static const unsigned short wctypes[256]
Definition: string.c:2110
static const void *static void *__cdecl * pbsearch(void *, void *, size_t, size_t, int(__cdecl *compar)(const void *, const void *))
static void one_ui64tow_test(int test_num, const ulonglong2str_t *ulonglong2str)
Definition: string.c:776
static void one_ultoa_test(int test_num, const ulong2str_t *ulong2str)
Definition: string.c:325
static void test_memchr(void)
Definition: string.c:2228
static void test_bsearch(void)
Definition: string.c:1467
static void test__snprintf_s(void)
Definition: string.c:1615
static void one_itow_test(int test_num, const ulong2str_t *ulong2str)
Definition: string.c:362
static void one_ltoa_test(int test_num, const ulong2str_t *ulong2str)
Definition: string.c:306
static void test_wtol(void)
Definition: string.c:1000
#define X(name)
static void *__cdecl * pmemchr(const void *, int, size_t)
static const str2longlong_t str2longlong[]
Definition: string.c:1027
static void test_wctype(void)
Definition: string.c:2162
static void test_wcsrchr(void)
Definition: string.c:1274
static void InitFunctionPtrs(void)
Definition: string.c:108
static void test_wcstol(void)
Definition: string.c:1196
static void test_wcschr(void)
Definition: string.c:1262
static const unsigned short ctypes[256]
Definition: string.c:2179
static void one_ltow_test(int test_num, const ulong2str_t *ulong2str)
Definition: string.c:397
static void one_ultow_test(int test_num, const ulong2str_t *ulong2str)
Definition: string.c:433
static LPCWSTR
Definition: string.c:69
static void test_wcslwrupr(void)
Definition: string.c:1286
static void test_ulonglongtoa(void)
Definition: string.c:709
static int __cdecl strcomparefunc(const void *a, const void *b)
Definition: string.c:1370
static void one_i64toa_test(int test_num, const ulonglong2str_t *ulonglong2str)
Definition: string.c:662
#define LARGE_STRI_BUFFER_LENGTH
Definition: string.c:176
static void test_qsort(void)
Definition: string.c:1390
static LPCSTR
Definition: string.c:41
static void test_ulongtoa(void)
Definition: string.c:344
static void test_atoi64(void)
Definition: string.c:1144
static void test_wtoi64(void)
Definition: string.c:1167
static const UNICODE_STRING BOOLEAN
Definition: string.c:39
static void test__snwprintf_s(void)
Definition: string.c:1776
static void test_wtoi(void)
Definition: string.c:958
NTSYSAPI BOOLEAN NTAPI RtlCreateUnicodeStringFromAsciiz(_Out_ PUNICODE_STRING Destination, _In_ PCSZ Source)
WCHAR NTAPI RtlUpcaseUnicodeChar(_In_ WCHAR Source)
Definition: nlsboot.c:177
NTSYSAPI NTSTATUS NTAPI RtlUnicodeStringToAnsiString(PANSI_STRING DestinationString, PUNICODE_STRING SourceString, BOOLEAN AllocateDestinationString)
NTSYSAPI VOID NTAPI RtlFreeAnsiString(PANSI_STRING AnsiString)
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
short WCHAR
Definition: pedump.c:58
short SHORT
Definition: pedump.c:59
long LONG
Definition: pedump.c:60
#define INT
Definition: polytest.cpp:20
const WCHAR * str
#define WINAPIV
Definition: sdbpapi.h:64
#define iswspace(_c)
Definition: ctype.h:669
#define iswdigit(_c)
Definition: ctype.h:667
#define iswlower(_c)
Definition: ctype.h:666
#define iswxdigit(_c)
Definition: ctype.h:668
#define iswalpha(_c)
Definition: ctype.h:664
_wcslwr
wcscat
_wcsupr
wcscpy
_ultoa
Definition: stdlib.h:688
_ltoa
Definition: stdlib.h:665
_itoa
Definition: stdlib.h:642
strcat
Definition: string.h:92
strcpy
Definition: string.h:131
#define memset(x, y, z)
Definition: compat.h:39
#define towlower(c)
Definition: wctype.h:97
#define towupper(c)
Definition: wctype.h:99
#define _WIN32_WINNT_VISTA
Definition: sdkddkver.h:25
const char * ws
Definition: skip_ws.cpp:7
USHORT MaximumLength
Definition: env_spec_w32.h:370
LONG value
Definition: string.c:850
const char * str
Definition: string.c:849
LONGLONG value
Definition: string.c:1023
const char * str
Definition: string.c:1022
ULONG value
Definition: string.c:180
const char * Buffer
Definition: string.c:181
int mask
Definition: string.c:182
int base
Definition: string.c:179
const char * Buffer
Definition: string.c:516
ULONGLONG value
Definition: string.c:515
#define bsearch
uint16_t * LPWSTR
Definition: typedefs.h:56
int64_t LONGLONG
Definition: typedefs.h:68
char * LPSTR
Definition: typedefs.h:51
uint64_t ULONGLONG
Definition: typedefs.h:67
uint32_t ULONG_PTR
Definition: typedefs.h:65
uint32_t ULONG
Definition: typedefs.h:59
struct _STRING * PSTRING
Definition: pdh_main.c:96
void * arg
Definition: msvc.h:10
#define WINAPI
Definition: msvc.h:6
NTSYSAPI WCHAR WINAPI RtlAnsiCharToUnicodeChar(LPSTR *)
unsigned char BYTE
Definition: xxhash.c:193