ReactOS 0.4.17-dev-243-g1369312
string.c File Reference
#include <stdlib.h>
#include <limits.h>
#include <stdarg.h>
#include "ntstatus.h"
#include "windef.h"
#include "winbase.h"
#include "winternl.h"
#include "winnls.h"
#include "wine/test.h"
Include dependency graph for string.c:

Go to the source code of this file.

Classes

struct  ulong2str_t
 
struct  ulonglong2str_t
 
struct  str2long_t
 
struct  str2longlong_t
 

Macros

#define WIN32_NO_STATUS
 
#define X(name)   p##name = (void *)GetProcAddress( hntdll, #name );
 
#define LARGE_STRI_BUFFER_LENGTH   67
 
#define ULL(a, b)   (((ULONGLONG)(a) << 32) | (b))
 

Functions

static NTSTATUS (WINAPI *pRtlUnicodeStringToAnsiString)(STRING *
 
static VOID (WINAPI *pRtlFreeAnsiString)(PSTRING)
 
static BOOLEAN (WINAPI *pRtlCreateUnicodeStringFromAsciiz)(PUNICODE_STRING
 
static WCHAR (WINAPI *pRtlUpcaseUnicodeChar)(WCHAR)
 
static int (__cdecl *patoi)(const char *)
 
static LONG (__cdecl *patol)(const char *)
 
static LONGLONG (__cdecl *p_atoi64)(const char *)
 
static LPSTR (__cdecl *p_itoa)(int
 
static ULONG (__cdecl *pwcstoul)(LPCWSTR
 
static LPWSTR (__cdecl *p_itow)(int
 
static WCHAR (__cdecl *ptowlower)(WCHAR)
 
static void *__cdeclpmemchr (const void *, int, size_t)
 
static void (__cdecl *pqsort)(void *
 
static const void *static void *__cdeclpbsearch (void *, void *, size_t, size_t, int(__cdecl *compar)(const void *, const void *))
 
static int (WINAPIV *p_snprintf)(char *
 
static void InitFunctionPtrs (void)
 
static void one_itoa_test (int test_num, const ulong2str_t *ulong2str)
 
static void one_ltoa_test (int test_num, const ulong2str_t *ulong2str)
 
static void one_ultoa_test (int test_num, const ulong2str_t *ulong2str)
 
static void test_ulongtoa (void)
 
static void one_itow_test (int test_num, const ulong2str_t *ulong2str)
 
static void one_ltow_test (int test_num, const ulong2str_t *ulong2str)
 
static void one_ultow_test (int test_num, const ulong2str_t *ulong2str)
 
static void test_ulongtow (void)
 
static void one_i64toa_test (int test_num, const ulonglong2str_t *ulonglong2str)
 
static void one_ui64toa_test (int test_num, const ulonglong2str_t *ulonglong2str)
 
static void test_ulonglongtoa (void)
 
static void one_i64tow_test (int test_num, const ulonglong2str_t *ulonglong2str)
 
static void one_ui64tow_test (int test_num, const ulonglong2str_t *ulonglong2str)
 
static void test_ulonglongtow (void)
 
static void test_wtoi (void)
 
static void test_atoi (void)
 
static void test_atol (void)
 
static void test_wtol (void)
 
static void test_atoi64 (void)
 
static void test_wtoi64 (void)
 
static void test_wcstol (void)
 
static void test_wcschr (void)
 
static void test_wcsrchr (void)
 
static void test_wcslwrupr (void)
 
static void test_wcsicmp (void)
 
static int __cdecl intcomparefunc (const void *a, const void *b)
 
static int __cdecl charcomparefunc (const void *a, const void *b)
 
static int __cdecl strcomparefunc (const void *a, const void *b)
 
static int __cdecl istrcomparefunc (const void *a, const void *b)
 
static void test_qsort (void)
 
static void test_bsearch (void)
 
static void test__snprintf (void)
 
static void test__snprintf_s (void)
 
static void test__snwprintf (void)
 
static void test__snwprintf_s (void)
 
static void test_printf_format (void)
 
static void test_tolower (void)
 
static void test_toupper (void)
 
static void test__strnicmp (void)
 
static void test_sscanf (void)
 
static void test_wctype (void)
 
static void test_ctype (void)
 
static void test_memchr (void)
 
 START_TEST (string)
 

Variables

static HMODULE hntdll = 0
 
static const UNICODE_STRING BOOLEAN
 
static LPCSTR
 
static LPSTR
 
static INT
 
static LPWSTR
 
static int
 
static LPCWSTR
 
static WCHAR
 
static size_t
 
static const char static unsigned short
 
static const ulong2str_t ulong2str []
 
static const ulonglong2str_t ulonglong2str []
 
static const str2long_t str2long []
 
static const str2longlong_t str2longlong []
 
static const unsigned short wctypes [256]
 
static const unsigned short ctypes [256]
 

Macro Definition Documentation

◆ LARGE_STRI_BUFFER_LENGTH

#define LARGE_STRI_BUFFER_LENGTH   67

Definition at line 176 of file string.c.

◆ ULL

#define ULL (   a,
  b 
)    (((ULONGLONG)(a) << 32) | (b))

Definition at line 511 of file string.c.

◆ WIN32_NO_STATUS

#define WIN32_NO_STATUS

Definition at line 29 of file string.c.

◆ X

#define X (   name)    p##name = (void *)GetProcAddress( hntdll, #name );

Function Documentation

◆ BOOLEAN()

static BOOLEAN ( WINAPI pRtlCreateUnicodeStringFromAsciiz)
static

◆ charcomparefunc()

static int __cdecl charcomparefunc ( const void a,
const void b 
)
static

Definition at line 1361 of file string.c.

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}
#define ok(value,...)
Definition: atltest.h:57
GLdouble GLdouble GLdouble GLdouble q
Definition: gl.h:2063
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
GLfloat GLfloat p
Definition: glext.h:8902
GLboolean GLboolean GLboolean GLboolean a
Definition: glext.h:6204
#define a
Definition: ke_i.h:78
#define b
Definition: ke_i.h:79

Referenced by test_qsort().

◆ InitFunctionPtrs()

static void InitFunctionPtrs ( void  )
static

Definition at line 108 of file string.c.

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}
#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 wcschr
Definition: compat.h:17
#define wcsrchr
Definition: compat.h:16
#define _strnicmp(_String1, _String2, _MaxCount)
Definition: compat.h:23
HINSTANCE WINAPI DECLSPEC_HOTPATCH LoadLibraryA(LPCSTR lpLibFileName)
Definition: loader.c:111
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
_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 wchar_t *__cdecl _ltow(__msvcrt_long, wchar_t *, int)
Definition: string.c:2143
_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 wchar_t *__cdecl _ui64tow(unsigned __int64, wchar_t *, int)
Definition: string.c:2223
_ACRTIMP wchar_t *__cdecl _ultow(__msvcrt_ulong, wchar_t *, int)
Definition: string.c:2199
_ACRTIMP wchar_t *__cdecl _itow(int, wchar_t *, int)
Definition: string.c:2135
_ACRTIMP int __cdecl _wtoi(const wchar_t *)
Definition: wcs.c:2773
_ACRTIMP wchar_t *__cdecl _i64tow(__int64, wchar_t *, int)
Definition: string.c:2289
_ACRTIMP int __cdecl _wcsicmp(const wchar_t *, const wchar_t *)
Definition: wcs.c:159
_ACRTIMP int __cdecl _wcsnicmp(const wchar_t *, const wchar_t *, size_t)
Definition: wcs.c:195
_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 __msvcrt_long __cdecl atol(const char *)
Definition: string.c:1782
_ACRTIMP char *__cdecl _ui64toa(unsigned __int64, char *, int)
Definition: string.c:2175
_ACRTIMP char *__cdecl _i64toa(__int64, char *, int)
Definition: string.c:2247
_ACRTIMP __int64 __cdecl _atoi64(const char *)
Definition: string.c:1757
int __cdecl atoi(const char *str)
Definition: string.c:1715
int __cdecl iswctype(wint_t wc, wctype_t wctypeFlags)
Definition: freeldr.c:166
#define memchr(s, c, n)
Definition: mkisofs.h:875
static HMODULE hntdll
Definition: string.c:38
#define X(name)
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)
#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
_wcsupr
_ultoa
Definition: stdlib.h:688
_ltoa
Definition: stdlib.h:665
_itoa
Definition: stdlib.h:642
#define towlower(c)
Definition: wctype.h:97
#define towupper(c)
Definition: wctype.h:99
#define bsearch

Referenced by START_TEST().

◆ int() [1/2]

static int ( __cdecl patoi) const
static

◆ int() [2/2]

static int ( WINAPIV p_snprintf)
static

◆ intcomparefunc()

static int __cdecl intcomparefunc ( const void a,
const void b 
)
static

Definition at line 1352 of file string.c.

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}

Referenced by test_bsearch(), and test_qsort().

◆ istrcomparefunc()

static int __cdecl istrcomparefunc ( const void a,
const void b 
)
static

Definition at line 1380 of file string.c.

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}
int WINAPI lstrcmpiA(LPCSTR str1, LPCSTR str2)
Definition: string.c:74

Referenced by test_qsort().

◆ LONG()

static LONG ( __cdecl patol) const
static

◆ LONGLONG()

static LONGLONG ( __cdecl p_atoi64) const
static

◆ LPSTR()

static LPSTR ( __cdecl p_itoa)
static

◆ LPWSTR()

static LPWSTR ( __cdecl p_itow)
static

◆ NTSTATUS()

static NTSTATUS ( WINAPI pRtlUnicodeStringToAnsiString)
static

◆ one_i64toa_test()

static void one_i64toa_test ( int  test_num,
const ulonglong2str_t ulonglong2str 
)
static

Definition at line 662 of file string.c.

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}
Definition: bufpool.h:45
static __inline const char * wine_dbgstr_longlong(ULONGLONG ll)
Definition: compat.h:49
_ACRTIMP int __cdecl memcmp(const void *, const void *, size_t)
Definition: string.c:2802
GLuint64EXT * result
Definition: glext.h:11304
static const ulonglong2str_t ulonglong2str[]
Definition: string.c:521
#define LARGE_STRI_BUFFER_LENGTH
Definition: string.c:176
#define memset(x, y, z)
Definition: compat.h:39
const char * Buffer
Definition: string.c:516
ULONGLONG value
Definition: string.c:515
char * LPSTR
Definition: typedefs.h:51

Referenced by test_ulonglongtoa().

◆ one_i64tow_test()

static void one_i64tow_test ( int  test_num,
const ulonglong2str_t ulonglong2str 
)
static

Definition at line 726 of file string.c.

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}
std::wstring STRING
Definition: fontsub.cpp:33
short WCHAR
Definition: pedump.c:58
USHORT MaximumLength
Definition: env_spec_w32.h:370
uint16_t * LPWSTR
Definition: typedefs.h:56

Referenced by test_ulonglongtow().

◆ one_itoa_test()

static void one_itoa_test ( int  test_num,
const ulong2str_t ulong2str 
)
static

Definition at line 287 of file string.c.

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}
static const ulong2str_t ulong2str[]
Definition: string.c:186
ULONG value
Definition: string.c:180
const char * Buffer
Definition: string.c:181
int base
Definition: string.c:179
Definition: pdh_main.c:96

Referenced by test_ulongtoa().

◆ one_itow_test()

static void one_itow_test ( int  test_num,
const ulong2str_t ulong2str 
)
static

Definition at line 362 of file string.c.

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}

Referenced by test_ulongtow().

◆ one_ltoa_test()

static void one_ltoa_test ( int  test_num,
const ulong2str_t ulong2str 
)
static

Definition at line 306 of file string.c.

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}
long LONG
Definition: pedump.c:60

Referenced by test_ulongtoa().

◆ one_ltow_test()

static void one_ltow_test ( int  test_num,
const ulong2str_t ulong2str 
)
static

Definition at line 397 of file string.c.

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}

Referenced by test_ulongtow().

◆ one_ui64toa_test()

static void one_ui64toa_test ( int  test_num,
const ulonglong2str_t ulonglong2str 
)
static

Definition at line 691 of file string.c.

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}

Referenced by test_ulonglongtoa().

◆ one_ui64tow_test()

static void one_ui64tow_test ( int  test_num,
const ulonglong2str_t ulonglong2str 
)
static

Definition at line 776 of file string.c.

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}

Referenced by test_ulonglongtow().

◆ one_ultoa_test()

static void one_ultoa_test ( int  test_num,
const ulong2str_t ulong2str 
)
static

Definition at line 325 of file string.c.

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}
uint32_t ULONG
Definition: typedefs.h:59

Referenced by test_ulongtoa().

◆ one_ultow_test()

static void one_ultow_test ( int  test_num,
const ulong2str_t ulong2str 
)
static

Definition at line 433 of file string.c.

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}

Referenced by test_ulongtow().

◆ pbsearch()

static const void *static void *__cdecl * pbsearch ( void ,
void ,
size_t  ,
size_t  ,
int(__cdecl *compar)(const void *, const void *)   
)
static

Referenced by test_bsearch().

◆ pmemchr()

static void *__cdecl * pmemchr ( const void ,
int  ,
size_t   
)
static

Referenced by test_memchr().

◆ START_TEST()

START_TEST ( string  )

Definition at line 2246 of file string.c.

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 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 void test_ulongtow(void)
Definition: string.c:469
static void test_ulonglongtow(void)
Definition: string.c:812
static void test_printf_format(void)
Definition: string.c:1819
static void test__snwprintf(void)
Definition: string.c:1658
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 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 test_wtol(void)
Definition: string.c:1000
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 void test_wcslwrupr(void)
Definition: string.c:1286
static void test_ulonglongtoa(void)
Definition: string.c:709
static void test_qsort(void)
Definition: string.c:1390
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 void test__snwprintf_s(void)
Definition: string.c:1776
static void test_wtoi(void)
Definition: string.c:958

◆ strcomparefunc()

static int __cdecl strcomparefunc ( const void a,
const void b 
)
static

Definition at line 1370 of file string.c.

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}
int WINAPI lstrcmpA(LPCSTR str1, LPCSTR str2)
Definition: string.c:58

Referenced by test_qsort().

◆ test__snprintf()

static void test__snprintf ( void  )
static

Definition at line 1485 of file string.c.

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}
#define broken(x)
Definition: atltest.h:178
#define NULL
Definition: types.h:112
int __cdecl strcmp(const char *str1, const char *str2)
Definition: string.c:3319
size_t __cdecl strlen(const char *str)
Definition: string.c:1592
#define L(x)
Definition: resources.c:13
GLuint res
Definition: glext.h:9613
GLuint buffer
Definition: glext.h:5915
#define debugstr_a
Definition: kernel32.h:31
int WINAPI lstrlenA(LPCSTR lpString)
Definition: lstring.c:145
strcpy
Definition: string.h:131
uint64_t ULONGLONG
Definition: typedefs.h:67
uint32_t ULONG_PTR
Definition: typedefs.h:65

Referenced by START_TEST().

◆ test__snprintf_s()

static void test__snprintf_s ( void  )
static

Definition at line 1615 of file string.c.

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}
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
#define win_skip
Definition: minitest.h:67

Referenced by START_TEST().

◆ test__snwprintf()

static void test__snwprintf ( void  )
static

Definition at line 1658 of file string.c.

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}
#define ARRAY_SIZE(A)
Definition: main.h:20
#define lstrlenW
Definition: compat.h:750
_ACRTIMP int __cdecl wcscmp(const wchar_t *, const wchar_t *)
Definition: wcs.c:1972
#define debugstr_w
Definition: kernel32.h:32
wcscpy

Referenced by START_TEST().

◆ test__snwprintf_s()

static void test__snwprintf_s ( void  )
static

Definition at line 1776 of file string.c.

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}

Referenced by START_TEST().

◆ test__strnicmp()

static void test__strnicmp ( void  )
static

Definition at line 2051 of file string.c.

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}
static PFN_strnicmp p_strnicmp
Definition: _strnicmp.c:14
return ret
Definition: mutex.c:146
unsigned int BOOL
Definition: ntddk_ex.h:94
static const BOOL is_win64
Definition: kernelbase.h:49

Referenced by START_TEST().

◆ test_atoi()

static void test_atoi ( void  )
static

Definition at line 974 of file string.c.

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}
static const str2long_t str2long[]
Definition: string.c:853
const WCHAR * str

◆ test_atoi64()

static void test_atoi64 ( void  )
static

Definition at line 1144 of file string.c.

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}
#define ULL(a, b)
Definition: string.c:511
static const str2longlong_t str2longlong[]
Definition: string.c:1027
int64_t LONGLONG
Definition: typedefs.h:68

Referenced by START_TEST().

◆ test_atol()

static void test_atol ( void  )
static

Definition at line 987 of file string.c.

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}

◆ test_bsearch()

static void test_bsearch ( void  )
static

Definition at line 1467 of file string.c.

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}
r l[0]
Definition: byte_order.h:168
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
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
static int __cdecl intcomparefunc(const void *a, const void *b)
Definition: string.c:1352
static const void *static void *__cdecl * pbsearch(void *, void *, size_t, size_t, int(__cdecl *compar)(const void *, const void *))

Referenced by START_TEST().

◆ test_ctype()

static void test_ctype ( void  )
static

Definition at line 2207 of file string.c.

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}
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
#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_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 unsigned short ctypes[256]
Definition: string.c:2179

Referenced by START_TEST().

◆ test_memchr()

static void test_memchr ( void  )
static

Definition at line 2228 of file string.c.

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}
GLdouble s
Definition: gl.h:2039
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
static void *__cdecl * pmemchr(const void *, int, size_t)

Referenced by START_TEST().

◆ test_printf_format()

static void test_printf_format ( void  )
static

Definition at line 1819 of file string.c.

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}
#define GetNTVersion()
Definition: apitest.h:17
#define skip(...)
Definition: atltest.h:64
#define ULONG_PTR
Definition: config.h:101
GLenum GLsizei len
Definition: glext.h:6722
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
unsigned __int64 ULONG64
Definition: imports.h:198
static struct test_info tests[]
BOOL expected
Definition: store.c:2000
short SHORT
Definition: pedump.c:59
wcscat
strcat
Definition: string.h:92
#define _WIN32_WINNT_VISTA
Definition: sdkddkver.h:25
const char * ws
Definition: skip_ws.cpp:7
void * arg
Definition: msvc.h:10
unsigned char BYTE
Definition: xxhash.c:193

Referenced by START_TEST().

◆ test_qsort()

static void test_qsort ( void  )
static

Definition at line 1390 of file string.c.

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}
static int __cdecl istrcomparefunc(const void *a, const void *b)
Definition: string.c:1380
static int __cdecl charcomparefunc(const void *a, const void *b)
Definition: string.c:1361
static int __cdecl strcomparefunc(const void *a, const void *b)
Definition: string.c:1370

Referenced by START_TEST().

◆ test_sscanf()

static void test_sscanf ( void  )
static

Definition at line 2074 of file string.c.

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}
GLfloat f
Definition: glext.h:7540
#define d
Definition: ke_i.h:81

Referenced by START_TEST().

◆ test_tolower()

static void test_tolower ( void  )
static

Definition at line 1998 of file string.c.

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}
#define GetProcAddress(x, y)
Definition: compat.h:753
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
Definition: loader.c:812
unsigned char
Definition: typeof.h:29

◆ test_toupper()

static void test_toupper ( void  )
static

Definition at line 2020 of file string.c.

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}
#define CP_ACP
Definition: compat.h:109
#define WideCharToMultiByte
Definition: compat.h:111
NTSYSAPI WCHAR WINAPI RtlAnsiCharToUnicodeChar(LPSTR *)

◆ test_ulonglongtoa()

static void test_ulonglongtoa ( void  )
static

Definition at line 709 of file string.c.

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}
GLenum GLint GLuint mask
Definition: glext.h:6028
static void one_ui64toa_test(int test_num, const ulonglong2str_t *ulonglong2str)
Definition: string.c:691
static void one_i64toa_test(int test_num, const ulonglong2str_t *ulonglong2str)
Definition: string.c:662

Referenced by START_TEST().

◆ test_ulonglongtow()

static void test_ulonglongtow ( void  )
static

Definition at line 812 of file string.c.

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}
static void one_i64tow_test(int test_num, const ulonglong2str_t *ulonglong2str)
Definition: string.c:726
static void one_ui64tow_test(int test_num, const ulonglong2str_t *ulonglong2str)
Definition: string.c:776

Referenced by START_TEST().

◆ test_ulongtoa()

static void test_ulongtoa ( void  )
static

Definition at line 344 of file string.c.

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}
static void one_itoa_test(int test_num, const ulong2str_t *ulong2str)
Definition: string.c:287
static void one_ultoa_test(int test_num, const ulong2str_t *ulong2str)
Definition: string.c:325
static void one_ltoa_test(int test_num, const ulong2str_t *ulong2str)
Definition: string.c:306

Referenced by START_TEST().

◆ test_ulongtow()

static void test_ulongtow ( void  )
static

Definition at line 469 of file string.c.

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}
static void one_itow_test(int test_num, const ulong2str_t *ulong2str)
Definition: string.c:362
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

Referenced by START_TEST().

◆ test_wcschr()

static void test_wcschr ( void  )
static

Definition at line 1262 of file string.c.

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}

Referenced by START_TEST().

◆ test_wcsicmp()

static void test_wcsicmp ( void  )
static

Definition at line 1330 of file string.c.

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}
static PFN_wcsicmp p_wcsicmp
Definition: _wcsicmp.c:14
static PFN_wcsnicmp p_wcsnicmp
Definition: _wcsnicmp.c:14

Referenced by START_TEST().

◆ test_wcslwrupr()

static void test_wcslwrupr ( void  )
static

Definition at line 1286 of file string.c.

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}
static PFN_wcslwr p_wcslwr
Definition: _wcslwr.c:14
static PFN_wcsupr p_wcsupr
Definition: _wcsupr.c:14
static const WCHAR emptyW[]
Definition: navigate.c:40

Referenced by START_TEST().

◆ test_wcsrchr()

static void test_wcsrchr ( void  )
static

Definition at line 1274 of file string.c.

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}

Referenced by START_TEST().

◆ test_wcstol()

static void test_wcstol ( void  )
static

Definition at line 1196 of file string.c.

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}
#define ULONG_MAX
Definition: limits.h:31
#define LONG_MAX
Definition: limits.h:30
#define LONG_MIN
Definition: limits.h:29
#define wine_dbgstr_w
Definition: kernel32.h:34

Referenced by START_TEST().

◆ test_wctype()

static void test_wctype ( void  )
static

Definition at line 2162 of file string.c.

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}
#define C1_ALPHA
Definition: unicode.h:39
static const unsigned short wctypes[256]
Definition: string.c:2110

Referenced by START_TEST().

◆ test_wtoi()

static void test_wtoi ( void  )
static

Definition at line 958 of file string.c.

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}

Referenced by START_TEST().

◆ test_wtoi64()

static void test_wtoi64 ( void  )
static

Definition at line 1167 of file string.c.

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}

Referenced by START_TEST().

◆ test_wtol()

static void test_wtol ( void  )
static

Definition at line 1000 of file string.c.

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}

Referenced by START_TEST().

◆ ULONG()

static ULONG ( __cdecl pwcstoul)
static

◆ void()

static void ( __cdecl pqsort)
static

◆ VOID()

static VOID ( WINAPI pRtlFreeAnsiString)
static

◆ WCHAR() [1/2]

static WCHAR ( __cdecl ptowlower)
static

◆ WCHAR() [2/2]

static WCHAR ( WINAPI pRtlUpcaseUnicodeChar)
static

Variable Documentation

◆ BOOLEAN

Definition at line 39 of file string.c.

◆ ctypes

const unsigned short ctypes[256]
static
Initial value:
=
{
0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020,
0x0020, 0x0028, 0x0028, 0x0028, 0x0028, 0x0028, 0x0020, 0x0020,
0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020,
0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020,
0x0048, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010,
0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010,
0x0084, 0x0084, 0x0084, 0x0084, 0x0084, 0x0084, 0x0084, 0x0084,
0x0084, 0x0084, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010,
0x0010, 0x0181, 0x0181, 0x0181, 0x0181, 0x0181, 0x0181, 0x0101,
0x0101, 0x0101, 0x0101, 0x0101, 0x0101, 0x0101, 0x0101, 0x0101,
0x0101, 0x0101, 0x0101, 0x0101, 0x0101, 0x0101, 0x0101, 0x0101,
0x0101, 0x0101, 0x0101, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010,
0x0010, 0x0182, 0x0182, 0x0182, 0x0182, 0x0182, 0x0182, 0x0102,
0x0102, 0x0102, 0x0102, 0x0102, 0x0102, 0x0102, 0x0102, 0x0102,
0x0102, 0x0102, 0x0102, 0x0102, 0x0102, 0x0102, 0x0102, 0x0102,
0x0102, 0x0102, 0x0102, 0x0010, 0x0010, 0x0010, 0x0010, 0x0020
}

Definition at line 2179 of file string.c.

Referenced by test_ctype().

◆ hntdll

HMODULE hntdll = 0
static

Definition at line 38 of file string.c.

Referenced by InitFunctionPtrs(), and test_printf_format().

◆ INT

INT

Definition at line 48 of file string.c.

◆ int

int

Definition at line 59 of file string.c.

◆ LPCSTR

Definition at line 41 of file string.c.

◆ LPCWSTR

Definition at line 69 of file string.c.

◆ LPSTR

Definition at line 48 of file string.c.

◆ LPWSTR

Definition at line 59 of file string.c.

◆ short

const char static unsigned short

Definition at line 89 of file string.c.

◆ size_t

Definition at line 76 of file string.c.

◆ str2long

const str2long_t str2long[]
static

Definition at line 853 of file string.c.

Referenced by test_atoi(), test_atol(), test_wtoi(), and test_wtol().

◆ str2longlong

const str2longlong_t str2longlong[]
static

Definition at line 1027 of file string.c.

Referenced by test_atoi64(), and test_wtoi64().

◆ ulong2str

◆ ulonglong2str

◆ WCHAR

Definition at line 72 of file string.c.

◆ wctypes

const unsigned short wctypes[256]
static

Definition at line 2110 of file string.c.

Referenced by test_wctype().