ReactOS 0.4.16-dev-1506-g117cd33
string.c File Reference
#include "wine/test.h"
#include <string.h>
#include <mbstring.h>
#include <wchar.h>
#include <stdlib.h>
#include <stdio.h>
#include <mbctype.h>
#include <locale.h>
#include <errno.h>
#include <limits.h>
#include <float.h>
#include <math.h>
#include "winbase.h"
#include "winnls.h"
#include "winuser.h"
Include dependency graph for string.c:

Go to the source code of this file.

Macros

#define expect_eq(expr, value, type, format)   { type ret = (expr); ok((value) == ret, #expr " expected " format " got " format "\n", value, ret); }
 
#define expect_bin(buf, value, len)   { ok(memcmp((buf), value, len) == 0, "Binary buffer mismatch - expected %s, got %s\n", buf_to_string((unsigned char *)value, len, 1), buf_to_string((buf), len, 0)); }
 
#define SETNOFAIL(x, y)   x = (void*)GetProcAddress(hMsvcrt,y)
 
#define SET(x, y)   SETNOFAIL(x,y); ok(x != NULL, "Export '%s' not found\n", y)
 
#define test_codepage(num)   test_cp_table(num, result_cp_##num##_mbctype);
 
#define okchars(dst, b0, b1, b2, b3, b4, b5, b6, b7)
 
#define TEST_STRNCPY_LEN   10
 

Functions

static charbuf_to_string (const unsigned char *bin, int len, int nr)
 
static void *__cdeclpmemcpy (void *, const void *, size_t n)
 
static int (__cdecl *p_memcpy_s)(void *
 
static int *__cdeclpmemcmp (void *, const void *, size_t n)
 
static size_t (__cdecl *p_strnlen)(const char *
 
static __int64 (__cdecl *p_strtoi64)(const char *
 
static const char mbstate_t *static wchar_t const char mbstate_t *static const wchar_t int *static errno_t (__cdecl *p_gcvt_s)(char *
 
static wint_t (__cdecl *p_btowc)(int)
 
static _locale_t (__cdecl *p__create_locale)(int
 
static const char *static void (__cdecl *p__free_locale)(_locale_t)
 
static double (__cdecl *p__atof_l)(const char *
 
int CDECL __STRINGTOLD (_LDOUBLE *, char **, const char *, int)
 
static void test_swab (void)
 
static void test_strcspn (void)
 
static void test_cp_table (int cp, int *result)
 
static void test_mbcp (void)
 
static void test_mbsspn (void)
 
static void test_mbsspnp (void)
 
static void test_strdup (void)
 
static void test_wcsdup (void)
 
static void test_strcmp (void)
 
static void test_strcpy_s (void)
 
static void test_memcpy_s (void)
 
static void test_memmove_s (void)
 
static void test_strcat_s (void)
 
static void test__mbscat_s (void)
 
static void test__mbsnbcpy_s (void)
 
static void test__mbscpy_s (void)
 
static void test_wcscpy_s (void)
 
static void test__wcsupr_s (void)
 
static void test__wcslwr_s (void)
 
static void test_mbcjisjms (void)
 
static void test_mbcjmsjis (void)
 
static void test_mbctohira (void)
 
static void test_mbctokata (void)
 
static void test_mbbtombc (void)
 
static void test_mbctombb (void)
 
static void test_ismbckata (void)
 
static void test_ismbclegal (void)
 
static void test_strtok (void)
 
static void test_strtol (void)
 
static void test_strnlen (void)
 
static void test__strtoi64 (void)
 
static BOOL compare_double (double f, double g, unsigned int ulps)
 
static void test__strtod (void)
 
static void test_mbstowcs (void)
 
static void test__wcstombs_s_l (void)
 
static void test_gcvt (void)
 
static void test__itoa_s (void)
 
static void test__strlwr_s (void)
 
static void test_strncat_s (void)
 
static void test_wcsncat_s (void)
 
static void test__mbsnbcat_s (void)
 
static void test__mbsupr_s (void)
 
static void test__mbslwr_s (void)
 
static void test__mbstok (void)
 
static void test__ultoa_s (void)
 
static void test_wctob (void)
 
static void test_btowc (void)
 
static void test_wctomb (void)
 
static void test_tolower (void)
 
static double mul_pow10 (double x, double exp)
 
static void test__atodbl (void)
 
static void test__stricmp (void)
 
static void test__wcstoi64 (void)
 
static void test__wcstol (void)
 
static void test_atoi (void)
 
static void test_atol (void)
 
static void test_atof (void)
 
static void test_strncpy (void)
 
static void test_strxfrm (void)
 
static void test__strnset_s (void)
 
static void test__wcsnset_s (void)
 
static void test__wcsset_s (void)
 
static void test__mbscmp (void)
 
static void test__ismbclx (void)
 
static void test__memicmp (void)
 
static void test__memicmp_l (void)
 
static void test__strupr (void)
 
static void test__tcsncoll (void)
 
static void test__tcscoll (void)
 
static void test__tcsnicoll (void)
 
static void test___strncnt (void)
 
static void test_C_locale (void)
 
static void test_strstr (void)
 
static void test_iswdigit (void)
 
static void test_wcscmp (void)
 
static const chardebugstr_ldouble (_LDOUBLE *v)
 
static void test___STRINGTOLD (void)
 
static void test_SpecialCasing (void)
 
static void test__mbbtype (void)
 
static void test_wcsncpy (void)
 
static void test_mbsrev (void)
 
static void test__tolower_l (void)
 
static void test__strnicmp_l (void)
 
static void test_toupper (void)
 
 START_TEST (string)
 

Variables

static size_t
 
static const charsrc
 
static size_t len
 
static size_t size
 
static size_t const char size_t count
 
static size_t elem
 
static const unsigned char *static size_t const wchar_twcSrc
 
static char int
 
static char const wchar_t _locale_t
 
static const char mbstate_t *static wchar_t const char mbstate_t *static const wchar_t int *static double
 
static intp__mb_cur_max
 
static unsigned charp_mbctype
 
static size_t numberOfElements
 
static wchar_t
 
static HMODULE hMsvcrt
 
static int result_cp_932_mbctype []
 
static int result_cp_936_mbctype []
 
static int result_cp_949_mbctype []
 
static int result_cp_950_mbctype []
 
struct {
   const char *   string
 
   const char *   delimiter
 
   int   exp_offsetret1
 
   int   exp_offsetret2
 
   int   exp_offsetret3
 
testcases_strtok []
 

Macro Definition Documentation

◆ expect_bin

#define expect_bin (   buf,
  value,
  len 
)    { ok(memcmp((buf), value, len) == 0, "Binary buffer mismatch - expected %s, got %s\n", buf_to_string((unsigned char *)value, len, 1), buf_to_string((buf), len, 0)); }

Definition at line 59 of file string.c.

◆ expect_eq

#define expect_eq (   expr,
  value,
  type,
  format 
)    { type ret = (expr); ok((value) == ret, #expr " expected " format " got " format "\n", value, ret); }

Definition at line 58 of file string.c.

◆ okchars

#define okchars (   dst,
  b0,
  b1,
  b2,
  b3,
  b4,
  b5,
  b6,
  b7 
)
Value:
ok(dst[0] == b0 && dst[1] == b1 && dst[2] == b2 && dst[3] == b3 && \
dst[4] == b4 && dst[5] == b5 && dst[6] == b6 && dst[7] == b7, \
"Bad result: 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x\n",\
dst[0], dst[1], dst[2], dst[3], dst[4], dst[5], dst[6], dst[7])
#define ok(value,...)
Definition: atltest.h:57
GLenum GLenum dst
Definition: glext.h:6340
static CRYPT_DATA_BLOB b4
Definition: msg.c:2284
static CRYPT_DATA_BLOB b3[]
Definition: msg.c:592
static CRYPT_DATA_BLOB b2[]
Definition: msg.c:582
static CRYPT_DATA_BLOB b1[]
Definition: msg.c:573

Definition at line 874 of file string.c.

◆ SET

#define SET (   x,
  y 
)    SETNOFAIL(x,y); ok(x != NULL, "Export '%s' not found\n", y)

Definition at line 132 of file string.c.

◆ SETNOFAIL

#define SETNOFAIL (   x,
  y 
)    x = (void*)GetProcAddress(hMsvcrt,y)

Definition at line 131 of file string.c.

◆ test_codepage

#define test_codepage (   num)    test_cp_table(num, result_cp_##num##_mbctype);

Definition at line 260 of file string.c.

◆ TEST_STRNCPY_LEN

#define TEST_STRNCPY_LEN   10

Function Documentation

◆ __int64()

static unsigned __int64 ( __cdecl p_strtoi64) const
static

◆ __STRINGTOLD()

int CDECL __STRINGTOLD ( _LDOUBLE ,
char **  ,
const char ,
int   
)

Referenced by test___STRINGTOLD().

◆ _locale_t()

static _locale_t ( __cdecl p__create_locale)
static

◆ buf_to_string()

static char * buf_to_string ( const unsigned char bin,
int  len,
int  nr 
)
static

Definition at line 44 of file string.c.

45{
46 static char buf[2][1024];
47 char *w = buf[nr];
48 int i;
49
50 for (i = 0; i < len; i++)
51 {
52 sprintf(w, "%02x ", (unsigned char)bin[i]);
53 w += strlen(w);
54 }
55 return buf[nr];
56}
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
GLenum GLsizei len
Definition: glext.h:6722
GLubyte GLubyte GLubyte GLubyte w
Definition: glext.h:6102
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
#define sprintf(buf, format,...)
Definition: sprintf.c:55
ULONG nr
Definition: thread.c:7
static struct _PeImage bin

◆ compare_double()

static BOOL compare_double ( double  f,
double  g,
unsigned int  ulps 
)
inlinestatic

Definition at line 2062 of file string.c.

2063{
2064 ULONGLONG x = *(ULONGLONG *)&f;
2065 ULONGLONG y = *(ULONGLONG *)&g;
2066
2067 if (f < 0)
2068 x = ~x + 1;
2069 else
2070 x |= ((ULONGLONG)1)<<63;
2071 if (g < 0)
2072 y = ~y + 1;
2073 else
2074 y |= ((ULONGLONG)1)<<63;
2075
2076 return (x>y ? x-y : y-x) <= ulps;
2077}
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
GLfloat f
Definition: glext.h:7540
GLboolean GLboolean g
Definition: glext.h:6204
unsigned int ulps
Definition: effect.c:4332
uint64_t ULONGLONG
Definition: typedefs.h:67

Referenced by test__atodbl().

◆ debugstr_ldouble()

static const char * debugstr_ldouble ( _LDOUBLE v)
static

Definition at line 4673 of file string.c.

4674{
4675 static char buf[2 * ARRAY_SIZE(v->ld) + 1];
4676 int i;
4677
4678 for(i=0; i<ARRAY_SIZE(v->ld); i++)
4679 {
4680 buf[2*i] = v->ld[i] / 16 + '0';
4681 if(buf[2*i] > '9') buf[2*i] -= 10 + '0' - 'a';
4682 buf[2*i+1] = v->ld[i] % 16 + '0';
4683 if(buf[2*i+1] > '9') buf[2*i+1] -= 10 + '0' - 'a';
4684 }
4685 buf[2 * ARRAY_SIZE(v->ld)] = 0;
4686 return buf;
4687}
#define ARRAY_SIZE(A)
Definition: main.h:20
const GLdouble * v
Definition: gl.h:2040

Referenced by test___STRINGTOLD().

◆ double()

static double ( __cdecl p__atof_l) const
static

◆ errno_t()

static const char mbstate_t *static wchar_t const char mbstate_t *static const wchar_t int *static errno_t ( __cdecl p_gcvt_s)
static

◆ int()

static int ( __cdecl p_memcpy_s)
static

◆ mul_pow10()

static double mul_pow10 ( double  x,
double  exp 
)
static

Definition at line 3453 of file string.c.

3454{
3456 BOOL negexp = (exp < 0);
3457 int fpcontrol;
3458 double ret;
3459
3460 if(negexp)
3461 exp = -exp;
3462 fpcontrol = _control87(0, 0);
3463 _control87(fpexcept, 0xffffffff);
3464 ret = pow(10.0, exp);
3465 ret = (negexp ? x/ret : x*ret);
3466 _control87(fpcontrol, 0xffffffff);
3467 return ret;
3468}
return ret
Definition: mutex.c:146
unsigned int BOOL
Definition: ntddk_ex.h:94
double pow(double x, double y)
Definition: freeldr.c:178
#define _EM_UNDERFLOW
Definition: float.h:51
#define _EM_ZERODIVIDE
Definition: float.h:49
#define _EM_INEXACT
Definition: float.h:52
#define _EM_OVERFLOW
Definition: float.h:50
#define _EM_INVALID
Definition: float.h:47
#define _EM_DENORMAL
Definition: float.h:48
unsigned int __cdecl _control87(unsigned int, unsigned int)
Definition: _control87.c:16
DWORD exp
Definition: msg.c:16058

Referenced by test__atodbl().

◆ pmemcmp()

static int *__cdecl * pmemcmp ( void ,
const void ,
size_t  n 
)
static

Referenced by START_TEST().

◆ pmemcpy()

static void *__cdecl * pmemcpy ( void ,
const void ,
size_t  n 
)
static

Referenced by START_TEST().

◆ size_t()

static size_t ( __cdecl p_strnlen) const
static

◆ START_TEST()

START_TEST ( string  )

Definition at line 5054 of file string.c.

5055{
5056 char mem[100];
5057 static const char xilstring[]="c:/xilinx";
5058 int nLen;
5059
5060 hMsvcrt = GetModuleHandleA("msvcrt.dll");
5061 if (!hMsvcrt)
5062 hMsvcrt = GetModuleHandleA("msvcrtd.dll");
5063 ok(hMsvcrt != 0, "GetModuleHandleA failed\n");
5064 SET(pmemcpy,"memcpy");
5065 p_memcpy_s = (void*)GetProcAddress( hMsvcrt, "memcpy_s" );
5066 p_memmove_s = (void*)GetProcAddress( hMsvcrt, "memmove_s" );
5067 SET(pmemcmp,"memcmp");
5068 SET(p_mbctype,"_mbctype");
5069 SET(p__mb_cur_max,"__mb_cur_max");
5070 SET(p_strcpy, "strcpy");
5071 SET(p_strcmp, "strcmp");
5072 SET(p_strncmp, "strncmp");
5073 pstrcpy_s = (void *)GetProcAddress( hMsvcrt,"strcpy_s" );
5074 pstrcat_s = (void *)GetProcAddress( hMsvcrt,"strcat_s" );
5075 p_strncpy_s = (void *)GetProcAddress( hMsvcrt, "strncpy_s" );
5076 p_strncat_s = (void *)GetProcAddress( hMsvcrt, "strncat_s" );
5077 p_mbscat_s = (void*)GetProcAddress( hMsvcrt, "_mbscat_s" );
5078 p_mbsnbcat_s = (void *)GetProcAddress( hMsvcrt,"_mbsnbcat_s" );
5079 p_mbsnbcpy_s = (void *)GetProcAddress( hMsvcrt,"_mbsnbcpy_s" );
5080 p__mbscpy_s = (void *)GetProcAddress( hMsvcrt,"_mbscpy_s" );
5081 p_wcscpy_s = (void *)GetProcAddress( hMsvcrt,"wcscpy_s" );
5082 p_wcsncpy_s = (void *)GetProcAddress( hMsvcrt,"wcsncpy_s" );
5083 p_wcsncat_s = (void *)GetProcAddress( hMsvcrt,"wcsncat_s" );
5084 p_wcsupr_s = (void *)GetProcAddress( hMsvcrt,"_wcsupr_s" );
5085 p_strnlen = (void *)GetProcAddress( hMsvcrt,"strnlen" );
5086 p_strtoi64 = (void *)GetProcAddress(hMsvcrt, "_strtoi64");
5087 p_strtoui64 = (void *)GetProcAddress(hMsvcrt, "_strtoui64");
5088 p_wcstoi64 = (void *)GetProcAddress(hMsvcrt, "_wcstoi64");
5089 p_wcstoui64 = (void *)GetProcAddress(hMsvcrt, "_wcstoui64");
5090 pmbstowcs_s = (void *)GetProcAddress(hMsvcrt, "mbstowcs_s");
5091 pwcstombs_s = (void *)GetProcAddress(hMsvcrt, "wcstombs_s");
5092 p_wcstombs_s_l = (void *)GetProcAddress(hMsvcrt, "_wcstombs_s_l");
5093 pwcsrtombs = (void *)GetProcAddress(hMsvcrt, "wcsrtombs");
5094 p_gcvt_s = (void *)GetProcAddress(hMsvcrt, "_gcvt_s");
5095 p_itoa_s = (void *)GetProcAddress(hMsvcrt, "_itoa_s");
5096 p_strlwr_s = (void *)GetProcAddress(hMsvcrt, "_strlwr_s");
5097 p_ultoa_s = (void *)GetProcAddress(hMsvcrt, "_ultoa_s");
5098 p_wcslwr_s = (void*)GetProcAddress(hMsvcrt, "_wcslwr_s");
5099 p_mbsupr_s = (void*)GetProcAddress(hMsvcrt, "_mbsupr_s");
5100 p_mbslwr_s = (void*)GetProcAddress(hMsvcrt, "_mbslwr_s");
5101 p_btowc = (void*)GetProcAddress(hMsvcrt, "btowc");
5102 p_wctob = (void*)GetProcAddress(hMsvcrt, "wctob");
5103 p_wcrtomb = (void*)GetProcAddress(hMsvcrt, "wcrtomb");
5104 p_wcrtomb_s = (void*)GetProcAddress(hMsvcrt, "wcrtomb_s");
5105 p_tolower = (void*)GetProcAddress(hMsvcrt, "tolower");
5106 p_towlower = (void*)GetProcAddress(hMsvcrt, "towlower");
5107 p__towlower_l = (void*)GetProcAddress(hMsvcrt, "_towlower_l");
5108 p_towupper = (void*)GetProcAddress(hMsvcrt, "towupper");
5109 p__towupper_l = (void*)GetProcAddress(hMsvcrt, "_towupper_l");
5110 p__create_locale = (void*)GetProcAddress(hMsvcrt, "_create_locale");
5111 p__free_locale = (void*)GetProcAddress(hMsvcrt, "_free_locale");
5112 p_mbrlen = (void*)GetProcAddress(hMsvcrt, "mbrlen");
5113 p_mbrtowc = (void*)GetProcAddress(hMsvcrt, "mbrtowc");
5114 p_mbsrtowcs = (void*)GetProcAddress(hMsvcrt, "mbsrtowcs");
5115 p_mbsrtowcs_s = (void*)GetProcAddress(hMsvcrt, "mbsrtowcs_s");
5116 p__atodbl_l = (void*)GetProcAddress(hMsvcrt, "_atodbl_l");
5117 p__atof_l = (void*)GetProcAddress(hMsvcrt, "_atof_l");
5118 p__strtod_l = (void*)GetProcAddress(hMsvcrt, "_strtod_l");
5119 p__strnset_s = (void*)GetProcAddress(hMsvcrt, "_strnset_s");
5120 p__wcsnset_s = (void*)GetProcAddress(hMsvcrt, "_wcsnset_s");
5121 p__wcsset_s = (void*)GetProcAddress(hMsvcrt, "_wcsset_s");
5122 p__mbsnlen = (void*)GetProcAddress(hMsvcrt, "_mbsnlen");
5123 p__mbccpy_s = (void*)GetProcAddress(hMsvcrt, "_mbccpy_s");
5124 p__memicmp = (void*)GetProcAddress(hMsvcrt, "_memicmp");
5125 p__memicmp_l = (void*)GetProcAddress(hMsvcrt, "_memicmp_l");
5126 p___strncnt = (void*)GetProcAddress(hMsvcrt, "__strncnt");
5127 p_mbsnextc_l = (void*)GetProcAddress(hMsvcrt, "_mbsnextc_l");
5128 p_mbscmp_l = (void*)GetProcAddress(hMsvcrt, "_mbscmp_l");
5129 p__strnicmp_l = (void*)GetProcAddress(hMsvcrt, "_strnicmp_l");
5130 p_toupper = (void*)GetProcAddress(hMsvcrt, "toupper");
5131
5132 /* MSVCRT memcpy behaves like memmove for overlapping moves,
5133 MFC42 CString::Insert seems to rely on that behaviour */
5134 strcpy(mem,xilstring);
5135 nLen=strlen(xilstring);
5136 pmemcpy(mem+5, mem,nLen+1);
5137 ok(pmemcmp(mem+5,xilstring, nLen) == 0,
5138 "Got result %s\n",mem+5);
5139
5140 /* run tolower tests first */
5141 test_tolower();
5142 test_swab();
5143 test_strcspn();
5144 test_mbcp();
5145 test_mbsspn();
5146 test_mbsspnp();
5147 test_strdup();
5148 test_wcsdup();
5149 test_strcmp();
5150 test_strcpy_s();
5151 test_memcpy_s();
5153 test_strcat_s();
5162 test_mbbtombc();
5163 test_mbctombb();
5166 test_strtok();
5167 test__mbstok();
5168 test_wcscpy_s();
5170 test_strtol();
5171 test_strnlen();
5173 test__strtod();
5174 test_mbstowcs();
5176 test_gcvt();
5177 test__itoa_s();
5181 test__ultoa_s();
5185 test_wctob();
5186 test_btowc();
5187 test_wctomb();
5188 test__atodbl();
5189 test__stricmp();
5191 test__wcstol();
5192 test_atoi();
5193 test_atol();
5194 test_atof();
5195 test_strncpy();
5196 test_strxfrm();
5200 test__mbscmp();
5201 test__ismbclx();
5202 test__memicmp();
5204 test__strupr();
5206 test__tcscoll();
5209 test_C_locale();
5210 test_strstr();
5211 test_iswdigit();
5212 test_wcscmp();
5215 test__mbbtype();
5216 test_wcsncpy();
5217 test_mbsrev();
5218#ifndef __REACTOS__
5220#endif
5222 test_toupper();
5223}
#define GetProcAddress(x, y)
Definition: compat.h:753
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
Definition: loader.c:812
static void test_strxfrm(void)
Definition: string.c:3854
static void test_strtok(void)
Definition: string.c:1794
static void test__mbsupr_s(void)
Definition: string.c:2916
static void test_strdup(void)
Definition: string.c:701
static void test_mbbtombc(void)
Definition: string.c:1623
static void test__wcsnset_s(void)
Definition: string.c:3951
static void test_C_locale(void)
Definition: string.c:4541
static void test_SpecialCasing(void)
Definition: string.c:4730
static void test_ismbckata(void)
Definition: string.c:1671
static void test_mbctokata(void)
Definition: string.c:1594
static void test_mbcp(void)
Definition: string.c:264
static void test_wcsncpy(void)
Definition: string.c:4868
static void test_tolower(void)
Definition: string.c:3333
static void test___strncnt(void)
Definition: string.c:4506
static void test__strtod(void)
Definition: string.c:2079
static void test_mbcjisjms(void)
Definition: string.c:1510
static void test_strcmp(void)
Definition: string.c:719
static void test_memcpy_s(void)
Definition: string.c:880
static void test_wcscpy_s(void)
Definition: string.c:1236
static void test__memicmp(void)
Definition: string.c:4120
static void test__wcslwr_s(void)
Definition: string.c:1426
static void test_strncat_s(void)
Definition: string.c:2694
static void test__mbsnbcat_s(void)
Definition: string.c:2789
static void test__strtoi64(void)
Definition: string.c:1917
static void test_mbctohira(void)
Definition: string.c:1564
static void test__mbscmp(void)
Definition: string.c:4025
static void test_strtol(void)
Definition: string.c:1829
static void test_strcpy_s(void)
Definition: string.c:761
static void test__strnicmp_l(void)
Definition: string.c:4933
static void test_memmove_s(void)
Definition: string.c:948
static void test_mbsrev(void)
Definition: string.c:4879
#define SET(x, y)
Definition: string.c:132
static void test__wcsset_s(void)
Definition: string.c:3990
static void test_strcat_s(void)
Definition: string.c:1010
static void test__mbscpy_s(void)
Definition: string.c:1200
static HMODULE hMsvcrt
Definition: string.c:134
static void test_mbsspn(void)
Definition: string.c:614
static void test__wcsupr_s(void)
Definition: string.c:1342
static void test_iswdigit(void)
Definition: string.c:4637
static void test_strnlen(void)
Definition: string.c:1897
static void test__tcsncoll(void)
Definition: string.c:4246
static void test__itoa_s(void)
Definition: string.c:2538
static void test_strncpy(void)
Definition: string.c:3820
static void *__cdecl * pmemcpy(void *, const void *, size_t n)
static void test_atoi(void)
Definition: string.c:3756
static void test__wcstol(void)
Definition: string.c:3695
static void test__strnset_s(void)
Definition: string.c:3921
static unsigned char * p_mbctype
Definition: string.c:96
static void test__mbslwr_s(void)
Definition: string.c:2981
static void test__mbscat_s(void)
Definition: string.c:1073
static void test_strstr(void)
Definition: string.c:4604
static void test__wcstoi64(void)
Definition: string.c:3620
static void test__stricmp(void)
Definition: string.c:3542
static void test_wcscmp(void)
Definition: string.c:4659
static void test__tolower_l(void)
Definition: string.c:4901
static void test__memicmp_l(void)
Definition: string.c:4155
static void test___STRINGTOLD(void)
Definition: string.c:4689
static void test_gcvt(void)
Definition: string.c:2503
static void test_btowc(void)
Definition: string.c:3180
static void test_mbctombb(void)
Definition: string.c:1649
static void test__wcstombs_s_l(void)
Definition: string.c:2437
static void test__ismbclx(void)
Definition: string.c:4064
static void test_wctomb(void)
Definition: string.c:3256
static void test__tcscoll(void)
Definition: string.c:4343
static void test__mbsnbcpy_s(void)
Definition: string.c:1153
static void test__atodbl(void)
Definition: string.c:3470
static void test_toupper(void)
Definition: string.c:5005
static int * p__mb_cur_max
Definition: string.c:95
static void test__tcsnicoll(void)
Definition: string.c:4423
static void test__ultoa_s(void)
Definition: string.c:3064
static void test_atof(void)
Definition: string.c:3790
static void test__mbstok(void)
Definition: string.c:3046
static void test_wctob(void)
Definition: string.c:3142
static void test__strupr(void)
Definition: string.c:4198
static void test_wcsdup(void)
Definition: string.c:710
static void test_mbcjmsjis(void)
Definition: string.c:1536
static void test_atol(void)
Definition: string.c:3773
static void test__mbbtype(void)
Definition: string.c:4816
static void test_swab(void)
Definition: string.c:136
static void test__strlwr_s(void)
Definition: string.c:2634
static int *__cdecl * pmemcmp(void *, const void *, size_t n)
static void test_mbstowcs(void)
Definition: string.c:2185
static void test_mbsspnp(void)
Definition: string.c:666
static void test_ismbclegal(void)
Definition: string.c:1702
static void test_strcspn(void)
Definition: string.c:180
static void test_wcsncat_s(void)
Definition: string.c:2741
strcpy
Definition: string.h:131
Definition: mem.c:349

◆ test___STRINGTOLD()

static void test___STRINGTOLD ( void  )
static

Definition at line 4689 of file string.c.

4690{
4691 static const struct {
4692 const char *str;
4693 int endptr;
4694 int r;
4695 _LDOUBLE v;
4696 BOOL todo;
4697 } tests[] = {
4698 { "0", 1 },
4699 { "nan", 0, 4 },
4700 { "inf", 0, 4 },
4701 { "-0.0", 4, 0, {{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80 }} },
4702 { "1e0", 3, 0, {{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xff, 0x3f }} },
4703 { "1.7976931348623158e+308", 23, 0, {{ 0xaf, 0xfb, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0x43 }} },
4704 { "1.7976931348623159e+308", 23, 0, {{ 0xb1, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0x43 }} },
4705 { "3.65e-4951", 10, 0, {{ 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }} },
4706 { "1.82e-4951", 10, 0, {{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }}, TRUE },
4707 { "1e-99999", 8, 1, {{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }} },
4708 { "1.18e+4932", 10, 0, {{ 0x25, 0x75, 0x06, 0x68, 0x8a, 0xf1, 0xe7, 0xfd, 0xfe, 0x7f }} },
4709 { "1.19e+4932", 10, 2, {{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xff, 0x7f }} },
4710 { "1e+99999", 8, 2, {{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xff, 0x7f }} },
4711 };
4712
4713 char *endptr;
4714 _LDOUBLE v;
4715 int i, r;
4716
4717 for(i=0; i<ARRAY_SIZE(tests); i++)
4718 {
4719 errno = 0xdeadbeef;
4720 r = __STRINGTOLD(&v, &endptr, tests[i].str, 0);
4722 ok(r == tests[i].r, "%d) r = %d\n", i, r);
4723 ok(endptr == tests[i].str + tests[i].endptr, "%d) endptr = %p, expected %p\n",
4724 i, endptr, tests[i].str+tests[i].endptr);
4725 ok(!memcmp(&v, &tests[i].v, sizeof(v)), "%d) v = %s\n", i, debugstr_ldouble(&v));
4726 ok(errno == 0xdeadbeef, "%d) errno = %x\n", i, errno);
4727 }
4728}
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
#define TRUE
Definition: types.h:120
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
static struct test_info tests[]
BOOL todo
Definition: filedlg.c:313
#define todo_wine_if(is_todo)
Definition: custom.c:86
int CDECL __STRINGTOLD(_LDOUBLE *, char **, const char *, int)
static const char * debugstr_ldouble(_LDOUBLE *v)
Definition: string.c:4673
const WCHAR * str
#define errno
Definition: errno.h:18

Referenced by START_TEST().

◆ test___strncnt()

static void test___strncnt ( void  )
static

Definition at line 4506 of file string.c.

4507{
4508 static const struct
4509 {
4510 const char *str;
4511 size_t size;
4512 size_t ret;
4513 }
4514 strncnt_tests[] =
4515 {
4516 { NULL, 0, 0 },
4517 { "a", 0, 0 },
4518 { "a", 1, 1 },
4519 { "a", 10, 1 },
4520 { "abc", 1, 1 },
4521 };
4522 unsigned int i;
4523 size_t ret;
4524
4525 if (!p___strncnt)
4526 {
4527 win_skip("__strncnt() is not available.\n");
4528 return;
4529 }
4530
4531 if (0) /* crashes */
4532 ret = p___strncnt(NULL, 1);
4533
4534 for (i = 0; i < ARRAY_SIZE(strncnt_tests); ++i)
4535 {
4536 ret = p___strncnt(strncnt_tests[i].str, strncnt_tests[i].size);
4537 ok(ret == strncnt_tests[i].ret, "%u: unexpected return value %u.\n", i, (int)ret);
4538 }
4539}
#define NULL
Definition: types.h:112
GLsizeiptr size
Definition: glext.h:5919
#define win_skip
Definition: test.h:164

Referenced by START_TEST().

◆ test__atodbl()

static void test__atodbl ( void  )
static

Definition at line 3470 of file string.c.

3471{
3472 _CRT_DOUBLE d;
3473 char num[32];
3474 int i, j, ret;
3475
3476 if(!p__atodbl_l) {
3477 /* Old versions of msvcrt use different values for _OVERFLOW and _UNDERFLOW
3478 * Because of this lets skip _atodbl tests when _atodbl_l is not available */
3479 win_skip("_atodbl_l is not available\n");
3480 return;
3481 }
3482
3483 num[0] = 0;
3484 ret = p__atodbl_l(&d, num, NULL);
3485 ok(ret == 0, "_atodbl_l(&d, \"\", NULL) returned %d, expected 0\n", ret);
3486 ok(d.x == 0, "d.x = %lf, expected 0\n", d.x);
3487 ret = _atodbl(&d, num);
3488 ok(ret == 0, "_atodbl(&d, \"\") returned %d, expected 0\n", ret);
3489 ok(d.x == 0, "d.x = %lf, expected 0\n", d.x);
3490
3491 strcpy(num, "t");
3492 ret = p__atodbl_l(&d, num, NULL);
3493 ok(ret == 0, "_atodbl_l(&d, \"t\", NULL) returned %d, expected 0\n", ret);
3494 ok(d.x == 0, "d.x = %lf, expected 0\n", d.x);
3495 ret = _atodbl(&d, num);
3496 ok(ret == 0, "_atodbl(&d, \"t\") returned %d, expected 0\n", ret);
3497 ok(d.x == 0, "d.x = %lf, expected 0\n", d.x);
3498
3499 strcpy(num, "0");
3500 ret = p__atodbl_l(&d, num, NULL);
3501 ok(ret == 0, "_atodbl_l(&d, \"0\", NULL) returned %d, expected 0\n", ret);
3502 ok(d.x == 0, "d.x = %lf, expected 0\n", d.x);
3503 ret = _atodbl(&d, num);
3504 ok(ret == 0, "_atodbl(&d, \"0\") returned %d, expected 0\n", ret);
3505 ok(d.x == 0, "d.x = %lf, expected 0\n", d.x);
3506
3507 strcpy(num, "123");
3508 ret = p__atodbl_l(&d, num, NULL);
3509 ok(ret == 0, "_atodbl_l(&d, \"123\", NULL) returned %d, expected 0\n", ret);
3510 ok(d.x == 123, "d.x = %lf, expected 123\n", d.x);
3511 ret = _atodbl(&d, num);
3512 ok(ret == 0, "_atodbl(&d, \"123\") returned %d, expected 0\n", ret);
3513 ok(d.x == 123, "d.x = %lf, expected 123\n", d.x);
3514
3515 /* check over the whole range of (simple) normal doubles */
3516 for (j = DBL_MIN_10_EXP; j <= DBL_MAX_10_EXP; j++) {
3517 for (i = 1; i <= 9; i++) {
3518 double expected = mul_pow10(i, j);
3519 if (expected < DBL_MIN || expected > DBL_MAX) continue;
3520 snprintf(num, sizeof(num), "%de%d", i, j);
3521 ret = _atodbl(&d, num);
3522 ok(compare_double(d.x, expected, 2), "d.x = %.16e, expected %.16e\n", d.x, expected);
3523 }
3524 }
3525
3526 /* check with denormal doubles */
3527 strcpy(num, "1e-309");
3528 ret = p__atodbl_l(&d, num, NULL);
3529 ok(ret == _UNDERFLOW, "_atodbl_l(&d, \"1e-309\", NULL) returned %d, expected _UNDERFLOW\n", ret);
3530 ok(compare_double(d.x, 1e-309, 1), "d.x = %.16e, expected 0\n", d.x);
3531 ret = _atodbl(&d, num);
3532 ok(ret == _UNDERFLOW, "_atodbl(&d, \"1e-309\") returned %d, expected _UNDERFLOW\n", ret);
3533 ok(compare_double(d.x, 1e-309, 1), "d.x = %.16e, expected 0\n", d.x);
3534
3535 strcpy(num, "1e309");
3536 ret = p__atodbl_l(&d, num, NULL);
3537 ok(ret == _OVERFLOW, "_atodbl_l(&d, \"1e309\", NULL) returned %d, expected _OVERFLOW\n", ret);
3538 ret = _atodbl(&d, num);
3539 ok(ret == _OVERFLOW, "_atodbl(&d, \"1e309\") returned %d, expected _OVERFLOW\n", ret);
3540}
int _atodbl(void *value, char *str)
Definition: stubs.c:30
GLuint GLuint num
Definition: glext.h:9618
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 _UNDERFLOW
Definition: math.h:42
#define _OVERFLOW
Definition: math.h:41
#define DBL_MIN_10_EXP
Definition: float.h:80
#define DBL_MAX_10_EXP
Definition: float.h:77
#define DBL_MAX
Definition: float.h:76
#define d
Definition: ke_i.h:81
#define e
Definition: ke_i.h:82
BOOL expected
Definition: store.c:2063
static BOOL compare_double(double f, double g, unsigned int ulps)
Definition: string.c:2062
static double mul_pow10(double x, double exp)
Definition: string.c:3453
#define snprintf
Definition: wintirpc.h:48

Referenced by START_TEST().

◆ test__ismbclx()

static void test__ismbclx ( void  )
static

Definition at line 4064 of file string.c.

4065{
4066 int ret, cp = _getmbcp();
4067
4068 ret = _ismbcl0(0);
4069 ok(!ret, "got %d\n", ret);
4070
4071 ret = _ismbcl1(0);
4072 ok(!ret, "got %d\n", ret);
4073
4074 ret = _ismbcl2(0);
4075 ok(!ret, "got %d\n", ret);
4076
4077 _setmbcp(1252);
4078
4079 ret = _ismbcl0(0x8140);
4080 ok(!ret, "got %d\n", ret);
4081
4082 ret = _ismbcl1(0x889f);
4083 ok(!ret, "got %d\n", ret);
4084
4085 ret = _ismbcl2(0x989f);
4086 ok(!ret, "got %d\n", ret);
4087
4088 _setmbcp(932);
4089
4090 ret = _ismbcl0(0);
4091 ok(!ret, "got %d\n", ret);
4092
4093 ret = _ismbcl0(0x8140);
4094 ok(ret, "got %d\n", ret);
4095
4096 ret = _ismbcl0(0x817f);
4097 ok(!ret, "got %d\n", ret);
4098
4099 ret = _ismbcl1(0);
4100 ok(!ret, "got %d\n", ret);
4101
4102 ret = _ismbcl1(0x889f);
4103 ok(ret, "got %d\n", ret);
4104
4105 ret = _ismbcl1(0x88fd);
4106 ok(!ret, "got %d\n", ret);
4107
4108 ret = _ismbcl2(0);
4109 ok(!ret, "got %d\n", ret);
4110
4111 ret = _ismbcl2(0x989f);
4112 ok(ret, "got %d\n", ret);
4113
4114 ret = _ismbcl2(0x993f);
4115 ok(!ret, "got %d\n", ret);
4116
4117 _setmbcp(cp);
4118}
_CRTIMP int __cdecl _getmbcp(void)
Definition: locale.c:1474
_Check_return_ _CRTIMP int __cdecl _ismbcl1(_In_ unsigned int _Ch)
_Check_return_ _CRTIMP int __cdecl _ismbcl2(_In_ unsigned int _Ch)
_Check_return_ _CRTIMP int __cdecl _ismbcl0(_In_ unsigned int _Ch)
POINT cp
Definition: magnifier.c:59
int __cdecl _setmbcp(int)
Definition: _setmbcp.c:218

Referenced by START_TEST().

◆ test__itoa_s()

static void test__itoa_s ( void  )
static

Definition at line 2538 of file string.c.

2539{
2540 errno_t ret;
2541 char buffer[33];
2542
2543 if (!p_itoa_s)
2544 {
2545 win_skip("Skipping _itoa_s tests\n");
2546 return;
2547 }
2548
2549 errno = EBADF;
2550 ret = p_itoa_s(0, NULL, 0, 0);
2551 ok(ret == EINVAL, "Expected _itoa_s to return EINVAL, got %d\n", ret);
2552 ok(errno == EINVAL, "Expected errno to be EINVAL, got %d\n", errno);
2553
2554 memset(buffer, 'X', sizeof(buffer));
2555 errno = EBADF;
2556 ret = p_itoa_s(0, buffer, 0, 0);
2557 ok(ret == EINVAL, "Expected _itoa_s to return EINVAL, got %d\n", ret);
2558 ok(errno == EINVAL, "Expected errno to be EINVAL, got %d\n", errno);
2559 ok(buffer[0] == 'X', "Expected the output buffer to be untouched\n");
2560
2561 memset(buffer, 'X', sizeof(buffer));
2562 errno = EBADF;
2563 ret = p_itoa_s(0, buffer, sizeof(buffer), 0);
2564 ok(ret == EINVAL, "Expected _itoa_s to return EINVAL, got %d\n", ret);
2565 ok(errno == EINVAL, "Expected errno to be EINVAL, got %d\n", errno);
2566 ok(buffer[0] == '\0', "Expected the output buffer to be null terminated\n");
2567
2568 memset(buffer, 'X', sizeof(buffer));
2569 errno = EBADF;
2570 ret = p_itoa_s(0, buffer, sizeof(buffer), 64);
2571 ok(ret == EINVAL, "Expected _itoa_s to return EINVAL, got %d\n", ret);
2572 ok(errno == EINVAL, "Expected errno to be EINVAL, got %d\n", errno);
2573 ok(buffer[0] == '\0', "Expected the output buffer to be null terminated\n");
2574
2575 memset(buffer, 'X', sizeof(buffer));
2576 errno = EBADF;
2577 ret = p_itoa_s(12345678, buffer, 4, 10);
2578 ok(ret == ERANGE, "Expected _itoa_s to return ERANGE, got %d\n", ret);
2579 ok(errno == ERANGE, "Expected errno to be ERANGE, got %d\n", errno);
2580 ok(!memcmp(buffer, "\000765", 4),
2581 "Expected the output buffer to be null terminated with truncated output\n");
2582
2583 memset(buffer, 'X', sizeof(buffer));
2584 errno = EBADF;
2585 ret = p_itoa_s(12345678, buffer, 8, 10);
2586 ok(ret == ERANGE, "Expected _itoa_s to return ERANGE, got %d\n", ret);
2587 ok(errno == ERANGE, "Expected errno to be ERANGE, got %d\n", errno);
2588 ok(!memcmp(buffer, "\0007654321", 8),
2589 "Expected the output buffer to be null terminated with truncated output\n");
2590
2591 memset(buffer, 'X', sizeof(buffer));
2592 errno = EBADF;
2593 ret = p_itoa_s(-12345678, buffer, 9, 10);
2594 ok(ret == ERANGE, "Expected _itoa_s to return ERANGE, got %d\n", ret);
2595 ok(errno == ERANGE, "Expected errno to be ERANGE, got %d\n", errno);
2596 ok(!memcmp(buffer, "\00087654321", 9),
2597 "Expected the output buffer to be null terminated with truncated output\n");
2598
2599 ret = p_itoa_s(12345678, buffer, 9, 10);
2600 ok(ret == 0, "Expected _itoa_s to return 0, got %d\n", ret);
2601 ok(!strcmp(buffer, "12345678"),
2602 "Expected output buffer string to be \"12345678\", got \"%s\"\n",
2603 buffer);
2604
2605 ret = p_itoa_s(43690, buffer, sizeof(buffer), 2);
2606 ok(ret == 0, "Expected _itoa_s to return 0, got %d\n", ret);
2607 ok(!strcmp(buffer, "1010101010101010"),
2608 "Expected output buffer string to be \"1010101010101010\", got \"%s\"\n",
2609 buffer);
2610
2611 ret = p_itoa_s(1092009, buffer, sizeof(buffer), 36);
2612 ok(ret == 0, "Expected _itoa_s to return 0, got %d\n", ret);
2613 ok(!strcmp(buffer, "nell"),
2614 "Expected output buffer string to be \"nell\", got \"%s\"\n",
2615 buffer);
2616
2617 ret = p_itoa_s(5704, buffer, sizeof(buffer), 18);
2618 ok(ret == 0, "Expected _itoa_s to return 0, got %d\n", ret);
2619 ok(!strcmp(buffer, "hag"),
2620 "Expected output buffer string to be \"hag\", got \"%s\"\n",
2621 buffer);
2622
2623 ret = p_itoa_s(-12345678, buffer, sizeof(buffer), 10);
2624 ok(ret == 0, "Expected _itoa_s to return 0, got %d\n", ret);
2625 ok(!strcmp(buffer, "-12345678"),
2626 "Expected output buffer string to be \"-12345678\", got \"%s\"\n",
2627 buffer);
2628
2629 itoa(100, buffer, 100);
2630 ok(!strcmp(buffer, "10"),
2631 "Expected output buffer string to be \"10\", got \"%s\"\n", buffer);
2632}
#define EINVAL
Definition: acclib.h:90
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
#define ERANGE
Definition: acclib.h:92
#define EBADF
Definition: acclib.h:82
GLuint buffer
Definition: glext.h:5915
_CRTIMP char *__cdecl itoa(_In_ int _Val, _Pre_notnull_ _Post_z_ char *_DstBuf, _In_ int _Radix)
#define memset(x, y, z)
Definition: compat.h:39
int errno_t
Definition: corecrt.h:615

Referenced by START_TEST().

◆ test__mbbtype()

static void test__mbbtype ( void  )
static

Definition at line 4816 of file string.c.

4817{
4818 static const char *test_locales[] =
4819 {
4820 "Arabic_Algeria",
4821 "Chinese_China",
4822 "English_Australia",
4823 "French_Belgium",
4824 "German_Austria",
4825 "Greek",
4826 "Hindi",
4827 "Japanese",
4828 "Korean",
4829 "Polish",
4830 "Portuguese_Brazil",
4831 "Russian",
4832 "Spanish_Argentina",
4833 "Swedish_Finland",
4834 "Ukrainian",
4835 "Vietnamese",
4836 };
4837
4838 int expected, ret;
4839 unsigned int c, i;
4840
4841 for (i = 0; i < ARRAY_SIZE(test_locales); ++i)
4842 {
4843 setlocale(LC_ALL, test_locales[i]);
4845 for (c = 0; c < 256; ++c)
4846 {
4847 if (_ismbblead(c))
4849 else if (isprint(c))
4851 else
4853
4854 ret = _mbbtype(c, 0);
4855 ok(ret == expected, "test %u, c %#x, got ret %#x, expected %#x.\n", i, c, ret, expected);
4856
4857 if (_ismbbtrail(c))
4859 else
4861
4862 ret = _mbbtype(c, 1);
4863 ok(ret == expected, "test %u, c %#x, got ret %#x, expected %#x.\n", i, c, ret, expected);
4864 }
4865 }
4866}
#define isprint(c)
Definition: acclib.h:73
_Check_return_ _CRTIMP int __cdecl _ismbbtrail(_In_ unsigned int _C)
const GLubyte * c
Definition: glext.h:8905
#define LC_ALL
Definition: locale.h:17
_Check_return_ _CRTIMP int __cdecl _mbbtype(_In_ unsigned char _Ch, _In_ int _CType)
#define c
Definition: ke_i.h:80
#define _MBC_TRAIL
Definition: msvcrt.h:825
#define _MBC_SINGLE
Definition: msvcrt.h:823
#define _MBC_LEAD
Definition: msvcrt.h:824
#define _MBC_ILLEGAL
Definition: msvcrt.h:826
#define _MB_CP_LOCALE
Definition: msvcrt.h:831
int __cdecl _ismbblead(unsigned int)
Definition: ismblead.c:20
#define setlocale(n, s)
Definition: locale.h:46

Referenced by START_TEST().

◆ test__mbscat_s()

static void test__mbscat_s ( void  )
static

Definition at line 1073 of file string.c.

1074{
1075 unsigned char dst[8], src[4];
1076 int err;
1077 int prev_cp = _getmbcp();
1078
1079 if(!p_mbscat_s)
1080 {
1081 win_skip("_mbscat_s not found\n");
1082 return;
1083 }
1084
1085
1086 src[0] = dst[0] = 0;
1087 err = p_mbscat_s(NULL, sizeof(dst), src);
1088 ok(err == EINVAL, "_mbscat_s returned %d\n", err);
1089
1090 err = p_mbscat_s(dst, sizeof(dst), NULL);
1091 ok(err == EINVAL, "_mbscat_s returned %d\n", err);
1092
1093 dst[0] = 'a';
1094 err = p_mbscat_s(dst, 1, src);
1095 ok(err == EINVAL, "_mbscat_s returned %d\n", err);
1096
1097 memset(dst, 'a', sizeof(dst));
1098 dst[6] = 0;
1099 src[0] = 'b';
1100 src[1] = 0;
1101
1102 err = p_mbscat_s(dst, sizeof(dst), src);
1103 ok(err == 0, "_mbscat_s returned %d\n", err);
1104 ok(!memcmp(dst, "aaaaaab", 8), "dst = %s\n", dst);
1105
1106 err = p_mbscat_s(dst, sizeof(dst), src);
1107 ok(err == ERANGE, "_mbscat_s returned %d\n", err);
1108 ok(!dst[0], "dst[0] = %c\n", dst[0]);
1109 ok(dst[1] == 'a', "dst[1] = %c\n", dst[1]);
1110
1111 _setmbcp(932);
1112 /* test invalid str in dst */
1113 dst[0] = 0x81;
1114 dst[1] = 0x81;
1115 dst[2] = 0x52;
1116 dst[3] = 0;
1117 src[0] = 'a';
1118 src[1] = 0;
1119 err = p_mbscat_s(dst, sizeof(dst), src);
1120 ok(err == 0, "_mbscat_s returned %d\n", err);
1121
1122 /* test invalid str in src */
1123 dst[0] = 0;
1124 src[0] = 0x81;
1125 src[1] = 0x81;
1126 src[2] = 0x52;
1127 src[3] = 0;
1128 err = p_mbscat_s(dst, sizeof(dst), src);
1129 ok(err == 0, "_mbscat_s returned %d\n", err);
1130
1131 /* test dst with leading byte on the end of buffer */
1132 dst[0] = 'a';
1133 dst[1] = 0x81;
1134 dst[2] = 0;
1135 src[0] = 'R';
1136 src[1] = 0;
1137 err = p_mbscat_s(dst, sizeof(dst), src);
1138 ok(err == EILSEQ, "_mbscat_s returned %d\n", err);
1139 ok(!memcmp(dst, "aR", 3), "dst = %s\n", dst);
1140
1141 /* test src with leading byte on the end of buffer */
1142 dst[0] = 'a';
1143 dst[1] = 0;
1144 src[0] = 'b';
1145 src[1] = 0x81;
1146 src[2] = 0;
1147 err = p_mbscat_s(dst, sizeof(dst), src);
1148 ok(err == EILSEQ, "_mbscat_s returned %d\n", err);
1149 ok(!memcmp(dst, "ab", 3), "dst = %s\n", dst);
1150 _setmbcp(prev_cp);
1151}
GLenum src
Definition: glext.h:6340
#define err(...)
#define EILSEQ
Definition: errno.h:109

Referenced by START_TEST().

◆ test__mbscmp()

static void test__mbscmp ( void  )
static

Definition at line 4025 of file string.c.

4026{
4027 static const unsigned char a[] = {'a',0}, b[] = {'b',0};
4028 int ret;
4029
4030 if (!p_mbrlen)
4031 {
4032 win_skip("_mbscmp tests\n");
4033 return;
4034 }
4035
4036 ret = _mbscmp(NULL, NULL);
4037 ok(ret == INT_MAX, "got %d\n", ret);
4038
4039 ret = _mbscmp(a, NULL);
4040 ok(ret == INT_MAX, "got %d\n", ret);
4041
4042 ret = _mbscmp(NULL, a);
4043 ok(ret == INT_MAX, "got %d\n", ret);
4044
4045 ret = _mbscmp(a, a);
4046 ok(!ret, "got %d\n", ret);
4047
4048 ret = _mbscmp(a, b);
4049 ok(ret == -1, "got %d\n", ret);
4050
4051 ret = _mbscmp(b, a);
4052 ok(ret == 1, "got %d\n", ret);
4053
4054 if (!p_mbscmp_l)
4055 {
4056 win_skip("_mbscmp_l tests\n");
4057 return;
4058 }
4059
4060 ret = p_mbscmp_l(a, b, NULL);
4061 ok(ret == -1, "got %d\n", ret);
4062}
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
GLboolean GLboolean GLboolean GLboolean a
Definition: glext.h:6204
_Check_return_ _CRTIMP int __cdecl _mbscmp(_In_z_ const unsigned char *_Str1, _In_z_ const unsigned char *_Str2)
#define INT_MAX
Definition: intsafe.h:150

Referenced by START_TEST().

◆ test__mbscpy_s()

static void test__mbscpy_s ( void  )
static

Definition at line 1200 of file string.c.

1201{
1202 const unsigned char src[] = "source string";
1203 unsigned char dest[16];
1204 int ret;
1205
1206 if(!p__mbscpy_s)
1207 {
1208 win_skip("_mbscpy_s not found\n");
1209 return;
1210 }
1211
1212 ret = p__mbscpy_s(NULL, 0, src);
1213 ok(ret == EINVAL, "got %d\n", ret);
1214 ret = p__mbscpy_s(NULL, sizeof(dest), src);
1215 ok(ret == EINVAL, "got %d\n", ret);
1216 ret = p__mbscpy_s(dest, 0, src);
1217 ok(ret == EINVAL, "got %d\n", ret);
1218 dest[0] = 'x';
1219 ret = p__mbscpy_s(dest, sizeof(dest), NULL);
1220 ok(ret == EINVAL, "got %d\n", ret);
1221 ok(!dest[0], "dest buffer was not modified on invalid argument\n");
1222
1223 memset(dest, 'X', sizeof(dest));
1224 ret = p__mbscpy_s(dest, sizeof(dest), src);
1225 ok(!ret, "got %d\n", ret);
1226 ok(!memcmp(dest, src, sizeof(src)), "dest = %s\n", dest);
1227 ok(dest[sizeof(src)] == 'X', "unused part of buffer was modified\n");
1228
1229 memset(dest, 'X', sizeof(dest));
1230 ret = p__mbscpy_s(dest, 4, src);
1231 ok(ret == ERANGE, "got %d\n", ret);
1232 ok(!dest[0], "incorrect dest buffer (%d)\n", dest[0]);
1233 ok(dest[1] == src[1], "incorrect dest buffer (%d)\n", dest[1]);
1234}
static char * dest
Definition: rtl.c:135

Referenced by START_TEST().

◆ test__mbslwr_s()

static void test__mbslwr_s ( void  )
static

Definition at line 2981 of file string.c.

2982{
2983 errno_t ret;
2984 unsigned char buffer[20];
2985 int cp = _getmbcp();
2986
2987 if (!p_mbslwr_s)
2988 {
2989 win_skip("Skipping _mbslwr_s tests\n");
2990 return;
2991 }
2992
2993 errno = EBADF;
2994 ret = p_mbslwr_s(NULL, 0);
2995 ok(ret == 0, "Expected _mbslwr_s to return 0, got %d\n", ret);
2996
2997 errno = EBADF;
2998 ret = p_mbslwr_s(NULL, sizeof(buffer));
2999 ok(ret == EINVAL, "Expected _mbslwr_s to return EINVAL, got %d\n", ret);
3000 ok(errno == EINVAL, "Expected errno to be EINVAL, got %d\n", errno);
3001
3002 errno = EBADF;
3003 ret = p_mbslwr_s(buffer, 0);
3004 ok(ret == EINVAL, "Expected _mbslwr_s to return EINVAL, got %d\n", ret);
3005 ok(errno == EINVAL, "Expected errno to be EINVAL, got %d\n", errno);
3006
3007 memcpy(buffer, "ABCDEFGH", sizeof("ABCDEFGH"));
3008 errno = EBADF;
3009 ret = p_mbslwr_s(buffer, sizeof("ABCDEFGH"));
3010 ok(ret == 0, "Expected _mbslwr_s to return 0, got %d\n", ret);
3011 ok(!memcmp(buffer, "abcdefgh", sizeof("abcdefgh")),
3012 "Expected the output buffer to be \"abcdefgh\", got \"%s\"\n",
3013 buffer);
3014
3015 memcpy(buffer, "ABCDEFGH", sizeof("ABCDEFGH"));
3016 errno = EBADF;
3017 ret = p_mbslwr_s(buffer, sizeof(buffer));
3018 ok(ret == 0, "Expected _mbslwr_s to return 0, got %d\n", ret);
3019 ok(!memcmp(buffer, "abcdefgh", sizeof("abcdefgh")),
3020 "Expected the output buffer to be \"abcdefgh\", got \"%s\"\n",
3021 buffer);
3022
3023 memcpy(buffer, "ABCDEFGH", sizeof("ABCDEFGH"));
3024 errno = EBADF;
3025 ret = p_mbslwr_s(buffer, sizeof("ABCDEFGH") - 1);
3026 ok(ret == EINVAL, "Expected _mbslwr_s to return EINVAL, got %d\n", ret);
3027 ok(errno == EINVAL, "Expected errno to be EINVAL, got %d\n", errno);
3028
3029 memcpy(buffer, "ABCDEFGH\0IJKLMNOP", sizeof("ABCDEFGH\0IJKLMNOP"));
3030 errno = EBADF;
3031 ret = p_mbslwr_s(buffer, sizeof(buffer));
3032 ok(ret == 0, "Expected _mbslwr_s to return 0, got %d\n", ret);
3033 ok(!memcmp(buffer, "abcdefgh\0IJKLMNOP", sizeof("abcdefgh\0IJKLMNOP")),
3034 "Expected the output buffer to be \"abcdefgh\\0IJKLMNOP\", got \"%s\"\n",
3035 buffer);
3036
3037 _setmbcp(936);
3038 memcpy(buffer, "\xa2\xf1\xa2\xf2Q", sizeof("\xa2\xf1\xa2\xf2Q"));
3039 ret = p_mbslwr_s(buffer, sizeof(buffer));
3040 ok(ret == 0, "Expected _mbsupr_s to return 0, got %d\n", ret);
3041 ok(!memcmp(buffer, "\xa2\xa1\xa2\xa2q", sizeof("\xa2\xa1\xa2\xa2q")),
3042 "got %s\n", debugstr_a((char*)buffer));
3043 _setmbcp(cp);
3044}
#define debugstr_a
Definition: kernel32.h:31
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878

Referenced by START_TEST().

◆ test__mbsnbcat_s()

static void test__mbsnbcat_s ( void  )
static

Definition at line 2789 of file string.c.

2790{
2791 unsigned char dest[16];
2792 const unsigned char first[] = "dinosaur";
2793 const unsigned char second[] = "duck";
2794 int ret;
2795
2796 if (!p_mbsnbcat_s)
2797 {
2798 win_skip("Skipping _mbsnbcat_s tests\n");
2799 return;
2800 }
2801
2802 /* Test invalid arguments. */
2803 ret = p_mbsnbcat_s(NULL, 0, NULL, 0);
2804 ok(ret == 0, "Expected _mbsnbcat_s to return 0, got %d\n", ret);
2805
2806 errno = EBADF;
2807 ret = p_mbsnbcat_s(NULL, 10, NULL, 0);
2808 ok(ret == EINVAL, "Expected _mbsnbcat_s to return EINVAL, got %d\n", ret);
2809 ok(errno == EINVAL, "Expected errno to be EINVAL, got %d\n", errno);
2810
2811 errno = EBADF;
2812 ret = p_mbsnbcat_s(NULL, 0, NULL, 10);
2813 ok(ret == EINVAL, "Expected _mbsnbcat_s to return EINVAL, got %d\n", ret);
2814 ok(errno == EINVAL, "Expected errno to be EINVAL, got %d\n", errno);
2815
2816 memset(dest, 'X', sizeof(dest));
2817 errno = EBADF;
2818 ret = p_mbsnbcat_s(dest, 0, NULL, 0);
2819 ok(ret == EINVAL, "Expected _mbsnbcat_s to return EINVAL, got %d\n", ret);
2820 ok(errno == EINVAL, "Expected errno to be EINVAL, got %d\n", errno);
2821 ok(dest[0] == 'X', "Expected the output buffer to be untouched\n");
2822
2823 memset(dest, 'X', sizeof(dest));
2824 errno = EBADF;
2825 ret = p_mbsnbcat_s(dest, 0, second, 0);
2826 ok(ret == EINVAL, "Expected _mbsnbcat_s to return EINVAL, got %d\n", ret);
2827 ok(errno == EINVAL, "Expected errno to be EINVAL, got %d\n", errno);
2828 ok(dest[0] == 'X', "Expected the output buffer to be untouched\n");
2829
2830 memset(dest, 'X', sizeof(dest));
2831 errno = EBADF;
2832 ret = p_mbsnbcat_s(dest, sizeof(dest), NULL, 0);
2833 ok(ret == EINVAL, "Expected _mbsnbcat_s to return EINVAL, got %d\n", ret);
2834 ok(errno == EINVAL, "Expected errno to be EINVAL, got %d\n", errno);
2835 ok(dest[0] == '\0', "Expected the output buffer to be null terminated\n");
2836
2837 memset(dest, 'X', sizeof(dest));
2838 errno = EBADF;
2839 ret = p_mbsnbcat_s(dest, sizeof(dest), NULL, 10);
2840 ok(ret == EINVAL, "Expected _mbsnbcat_s to return EINVAL, got %d\n", ret);
2841 ok(errno == EINVAL, "Expected errno to be EINVAL, got %d\n", errno);
2842 ok(dest[0] == '\0', "Expected the output buffer to be null terminated\n");
2843
2844 memset(dest, 'X', sizeof(dest));
2845 dest[0] = '\0';
2846 ret = p_mbsnbcat_s(dest, sizeof(dest), second, sizeof(second));
2847 ok(ret == 0, "Expected _mbsnbcat_s to return 0, got %d\n", ret);
2848 ok(!memcmp(dest, second, sizeof(second)),
2849 "Expected the output buffer string to be \"duck\"\n");
2850
2851 /* Test source truncation behavior. */
2852 memset(dest, 'X', sizeof(dest));
2853 memcpy(dest, first, sizeof(first));
2854 ret = p_mbsnbcat_s(dest, sizeof(dest), second, 0);
2855 ok(ret == 0, "Expected _mbsnbcat_s to return 0, got %d\n", ret);
2856 ok(!memcmp(dest, first, sizeof(first)),
2857 "Expected the output buffer string to be \"dinosaur\"\n");
2858
2859 memset(dest, 'X', sizeof(dest));
2860 memcpy(dest, first, sizeof(first));
2861 ret = p_mbsnbcat_s(dest, sizeof(dest), second, sizeof(second));
2862 ok(ret == 0, "Expected _mbsnbcat_s to return 0, got %d\n", ret);
2863 ok(!memcmp(dest, "dinosaurduck", sizeof("dinosaurduck")),
2864 "Expected the output buffer string to be \"dinosaurduck\"\n");
2865
2866 memset(dest, 'X', sizeof(dest));
2867 memcpy(dest, first, sizeof(first));
2868 ret = p_mbsnbcat_s(dest, sizeof(dest), second, sizeof(second) + 1);
2869 ok(ret == 0, "Expected _mbsnbcat_s to return 0, got %d\n", ret);
2870 ok(!memcmp(dest, "dinosaurduck", sizeof("dinosaurduck")),
2871 "Expected the output buffer string to be \"dinosaurduck\"\n");
2872
2873 memset(dest, 'X', sizeof(dest));
2874 memcpy(dest, first, sizeof(first));
2875 ret = p_mbsnbcat_s(dest, sizeof(dest), second, sizeof(second) - 1);
2876 ok(ret == 0, "Expected _mbsnbcat_s to return 0, got %d\n", ret);
2877 ok(!memcmp(dest, "dinosaurduck", sizeof("dinosaurduck")),
2878 "Expected the output buffer string to be \"dinosaurduck\"\n");
2879
2880 memset(dest, 'X', sizeof(dest));
2881 memcpy(dest, first, sizeof(first));
2882 ret = p_mbsnbcat_s(dest, sizeof(dest), second, sizeof(second) - 2);
2883 ok(ret == 0, "Expected _mbsnbcat_s to return 0, got %d\n", ret);
2884 ok(!memcmp(dest, "dinosaurduc", sizeof("dinosaurduc")),
2885 "Expected the output buffer string to be \"dinosaurduc\"\n");
2886
2887 /* Test destination truncation behavior. */
2888 memset(dest, 'X', sizeof(dest));
2889 memcpy(dest, first, sizeof(first));
2890 errno = EBADF;
2891 ret = p_mbsnbcat_s(dest, sizeof(first) - 1, second, sizeof(second));
2892 ok(ret == EINVAL, "Expected _mbsnbcat_s to return EINVAL, got %d\n", ret);
2893 ok(errno == EINVAL, "Expected errno to be EINVAL, got %d\n", errno);
2894 ok(!memcmp(dest, "\0inosaur", sizeof("\0inosaur") - 1),
2895 "Expected the output buffer string to be \"\\0inosaur\" without ending null terminator\n");
2896
2897 memset(dest, 'X', sizeof(dest));
2898 memcpy(dest, first, sizeof(first));
2899 errno = EBADF;
2900 ret = p_mbsnbcat_s(dest, sizeof(first), second, sizeof(second));
2901 ok(ret == ERANGE, "Expected _mbsnbcat_s to return ERANGE, got %d\n", ret);
2902 ok(errno == ERANGE, "Expected errno to be ERANGE, got %d\n", errno);
2903 ok(!memcmp(dest, "\0inosaurd", sizeof("\0inosaurd") - 1),
2904 "Expected the output buffer string to be \"\\0inosaurd\" without ending null terminator\n");
2905
2906 memset(dest, 'X', sizeof(dest));
2907 memcpy(dest, first, sizeof(first));
2908 errno = EBADF;
2909 ret = p_mbsnbcat_s(dest, sizeof(first) + 1, second, sizeof(second));
2910 ok(ret == ERANGE, "Expected _mbsnbcat_s to return ERANGE, got %d\n", ret);
2911 ok(errno == ERANGE, "Expected errno to be ERANGE, got %d\n", errno);
2912 ok(!memcmp(dest, "\0inosaurdu", sizeof("\0inosaurdu") - 1),
2913 "Expected the output buffer string to be \"\\0inosaurdu\" without ending null terminator\n");
2914}
const GLint * first
Definition: glext.h:5794

Referenced by START_TEST().

◆ test__mbsnbcpy_s()

static void test__mbsnbcpy_s ( void  )
static

Definition at line 1153 of file string.c.

1154{
1155 unsigned char dest[8];
1156 const unsigned char big[] = "atoolongstringforthislittledestination";
1157 const unsigned char small[] = "small";
1158 int ret;
1159
1160 if(!p_mbsnbcpy_s)
1161 {
1162 win_skip("_mbsnbcpy_s not found\n");
1163 return;
1164 }
1165
1166 memset(dest, 'X', sizeof(dest));
1167 ret = p_mbsnbcpy_s(dest, sizeof(dest), small, sizeof(small));
1168 ok(ret == 0, "_mbsnbcpy_s: Copying a string into a big enough destination returned %d, expected 0\n", ret);
1169 ok(dest[0] == 's' && dest[1] == 'm' && dest[2] == 'a' && dest[3] == 'l' &&
1170 dest[4] == 'l' && dest[5] == '\0'&& dest[6] == 'X' && dest[7] == 'X',
1171 "Unexpected return data from _mbsnbcpy_s: 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x\n",
1172 dest[0], dest[1], dest[2], dest[3], dest[4], dest[5], dest[6], dest[7]);
1173
1174 /* WTF? */
1175 memset(dest, 'X', sizeof(dest));
1176 ret = p_mbsnbcpy_s(dest, sizeof(dest) - 2, big, sizeof(small));
1177 ok(ret == ERANGE, "_mbsnbcpy_s: Copying a too long string returned %d, expected ERANGE\n", ret);
1178 ok(dest[0] == '\0'&& dest[1] == 't' && dest[2] == 'o' && dest[3] == 'o' &&
1179 dest[4] == 'l' && dest[5] == 'o' && dest[6] == 'X' && dest[7] == 'X',
1180 "Unexpected return data from _mbsnbcpy_s: 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x\n",
1181 dest[0], dest[1], dest[2], dest[3], dest[4], dest[5], dest[6], dest[7]);
1182
1183 memset(dest, 'X', sizeof(dest));
1184 ret = p_mbsnbcpy_s(dest, sizeof(dest) - 2, big, 4);
1185 ok(ret == 0, "_mbsnbcpy_s: Copying a too long string with a count cap returned %d, expected 0\n", ret);
1186 ok(dest[0] == 'a' && dest[1] == 't' && dest[2] == 'o' && dest[3] == 'o' &&
1187 dest[4] == '\0'&& dest[5] == 'X' && dest[6] == 'X' && dest[7] == 'X',
1188 "Unexpected return data from _mbsnbcpy_s: 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x\n",
1189 dest[0], dest[1], dest[2], dest[3], dest[4], dest[5], dest[6], dest[7]);
1190
1191 memset(dest, 'X', sizeof(dest));
1192 ret = p_mbsnbcpy_s(dest, sizeof(dest) - 2, small, sizeof(small) + 10);
1193 ok(ret == 0, "_mbsnbcpy_s: Copying more data than the source string len returned %d, expected 0\n", ret);
1194 ok(dest[0] == 's' && dest[1] == 'm' && dest[2] == 'a' && dest[3] == 'l' &&
1195 dest[4] == 'l' && dest[5] == '\0'&& dest[6] == 'X' && dest[7] == 'X',
1196 "Unexpected return data from _mbsnbcpy_s: 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x\n",
1197 dest[0], dest[1], dest[2], dest[3], dest[4], dest[5], dest[6], dest[7]);
1198}
#define small
Definition: rpcndr.h:115

Referenced by START_TEST().

◆ test__mbstok()

static void test__mbstok ( void  )
static

Definition at line 3046 of file string.c.

3047{
3048 const unsigned char delim[] = "t";
3049
3050 char str[] = "!.!test";
3051 unsigned char *ret;
3052
3053 strtok(str, "!");
3054
3055 ret = _mbstok(NULL, delim);
3056 /* most versions of msvcrt use the same buffer for strtok and _mbstok */
3057 ok(!ret || broken((char*)ret==str+4),
3058 "_mbstok(NULL, \"t\") = %p, expected NULL (%p)\n", ret, str);
3059
3060 ret = _mbstok(NULL, delim);
3061 ok(!ret, "_mbstok(NULL, \"t\") = %p, expected NULL\n", ret);
3062}
char * strtok(char *String, const char *Delimiters)
Definition: utclib.c:338
#define broken(x)
Definition: atltest.h:178
_Check_return_ _CRTIMP unsigned char *__cdecl _mbstok(_Inout_opt_z_ unsigned char *_Str, _In_z_ const unsigned char *_Delim)

Referenced by START_TEST().

◆ test__mbsupr_s()

static void test__mbsupr_s ( void  )
static

Definition at line 2916 of file string.c.

2917{
2918 errno_t ret;
2919 unsigned char buffer[20];
2920 int cp = _getmbcp();
2921
2922 if (!p_mbsupr_s)
2923 {
2924 win_skip("Skipping _mbsupr_s tests\n");
2925 return;
2926 }
2927
2928 errno = EBADF;
2929 ret = p_mbsupr_s(NULL, 0);
2930 ok(ret == 0, "Expected _mbsupr_s to return 0, got %d\n", ret);
2931
2932 errno = EBADF;
2933 ret = p_mbsupr_s(NULL, sizeof(buffer));
2934 ok(ret == EINVAL, "Expected _mbsupr_s to return EINVAL, got %d\n", ret);
2935 ok(errno == EINVAL, "Expected errno to be EINVAL, got %d\n", errno);
2936
2937 errno = EBADF;
2938 ret = p_mbsupr_s(buffer, 0);
2939 ok(ret == EINVAL, "Expected _mbsupr_s to return EINVAL, got %d\n", ret);
2940 ok(errno == EINVAL, "Expected errno to be EINVAL, got %d\n", errno);
2941
2942 memcpy(buffer, "abcdefgh", sizeof("abcdefgh"));
2943 errno = EBADF;
2944 ret = p_mbsupr_s(buffer, sizeof("abcdefgh"));
2945 ok(ret == 0, "Expected _mbsupr_s to return 0, got %d\n", ret);
2946 ok(!memcmp(buffer, "ABCDEFGH", sizeof("ABCDEFGH")),
2947 "Expected the output buffer to be \"ABCDEFGH\", got \"%s\"\n",
2948 buffer);
2949
2950 memcpy(buffer, "abcdefgh", sizeof("abcdefgh"));
2951 errno = EBADF;
2952 ret = p_mbsupr_s(buffer, sizeof(buffer));
2953 ok(ret == 0, "Expected _mbsupr_s to return 0, got %d\n", ret);
2954 ok(!memcmp(buffer, "ABCDEFGH", sizeof("ABCDEFGH")),
2955 "Expected the output buffer to be \"ABCDEFGH\", got \"%s\"\n",
2956 buffer);
2957
2958 memcpy(buffer, "abcdefgh", sizeof("abcdefgh"));
2959 errno = EBADF;
2960 ret = p_mbsupr_s(buffer, sizeof("abcdefgh") - 1);
2961 ok(ret == EINVAL, "Expected _mbsupr_s to return EINVAL, got %d\n", ret);
2962 ok(errno == EINVAL, "Expected errno to be EINVAL, got %d\n", errno);
2963
2964 memcpy(buffer, "abcdefgh\0ijklmnop", sizeof("abcdefgh\0ijklmnop"));
2965 errno = EBADF;
2966 ret = p_mbsupr_s(buffer, sizeof(buffer));
2967 ok(ret == 0, "Expected _mbsupr_s to return 0, got %d\n", ret);
2968 ok(!memcmp(buffer, "ABCDEFGH\0ijklmnop", sizeof("ABCDEFGH\0ijklmnop")),
2969 "Expected the output buffer to be \"ABCDEFGH\\0ijklmnop\", got \"%s\"\n",
2970 buffer);
2971
2972 _setmbcp(936);
2973 memcpy(buffer, "\xa2\xa1\xa2\xa2q", sizeof("\xa2\xa1\xa2\xa2q"));
2974 ret = p_mbsupr_s(buffer, sizeof(buffer));
2975 ok(ret == 0, "Expected _mbsupr_s to return 0, got %d\n", ret);
2976 ok(!memcmp(buffer, "\xa2\xf1\xa2\xf2Q", sizeof("\xa2\xf1\xa2\xf2Q")),
2977 "got %s\n", debugstr_a((char*)buffer));
2978 _setmbcp(cp);
2979}

Referenced by START_TEST().

◆ test__memicmp()

static void test__memicmp ( void  )
static

Definition at line 4120 of file string.c.

4121{
4122 static const char *s1 = "abc";
4123 static const char *s2 = "aBd";
4124 int ret;
4125
4126 ret = p__memicmp(NULL, NULL, 0);
4127 ok(!ret, "got %d\n", ret);
4128
4129 ret = p__memicmp(s1, s2, 2);
4130 ok(!ret, "got %d\n", ret);
4131
4132 ret = p__memicmp(s1, s2, 3);
4133 ok(ret == -1, "got %d\n", ret);
4134
4135 if (!p__memicmp_l)
4136 return;
4137
4138 /* Following calls crash on WinXP/W2k3. */
4139 errno = 0xdeadbeef;
4140 ret = p__memicmp(NULL, NULL, 1);
4141 ok(ret == _NLSCMPERROR, "got %d\n", ret);
4142 ok(errno == EINVAL, "errno is %d, expected EINVAL\n", errno);
4143
4144 errno = 0xdeadbeef;
4145 ret = p__memicmp(s1, NULL, 1);
4146 ok(ret == _NLSCMPERROR, "got %d\n", ret);
4147 ok(errno == EINVAL, "errno is %d, expected EINVAL\n", errno);
4148
4149 errno = 0xdeadbeef;
4150 ret = p__memicmp(NULL, s2, 1);
4151 ok(ret == _NLSCMPERROR, "got %d\n", ret);
4152 ok(errno == EINVAL, "errno is %d, expected EINVAL\n", errno);
4153}
struct S1 s1
#define _NLSCMPERROR
Definition: string.h:19
PCWSTR s2
Definition: shell32_main.h:38

Referenced by START_TEST().

◆ test__memicmp_l()

static void test__memicmp_l ( void  )
static

Definition at line 4155 of file string.c.

4156{
4157 static const char *s1 = "abc";
4158 static const char *s2 = "aBd";
4159 int ret;
4160
4161 if (!p__memicmp_l)
4162 {
4163 win_skip("_memicmp_l not found.\n");
4164 return;
4165 }
4166
4167 errno = 0xdeadbeef;
4168 ret = p__memicmp_l(NULL, NULL, 0, NULL);
4169 ok(!ret, "got %d\n", ret);
4170 ok(errno == 0xdeadbeef, "errno is %d, expected 0xdeadbeef\n", errno);
4171
4172 errno = 0xdeadbeef;
4173 ret = p__memicmp_l(NULL, NULL, 1, NULL);
4174 ok(ret == _NLSCMPERROR, "got %d\n", ret);
4175 ok(errno == EINVAL, "errno is %d, expected EINVAL\n", errno);
4176
4177 errno = 0xdeadbeef;
4178 ret = p__memicmp_l(s1, NULL, 1, NULL);
4179 ok(ret == _NLSCMPERROR, "got %d\n", ret);
4180 ok(errno == EINVAL, "errno is %d, expected EINVAL\n", errno);
4181
4182 errno = 0xdeadbeef;
4183 ret = p__memicmp_l(NULL, s2, 1, NULL);
4184 ok(ret == _NLSCMPERROR, "got %d\n", ret);
4185 ok(errno == EINVAL, "errno is %d, expected EINVAL\n", errno);
4186
4187 errno = 0xdeadbeef;
4188 ret = p__memicmp_l(s1, s2, 2, NULL);
4189 ok(!ret, "got %d\n", ret);
4190 ok(errno == 0xdeadbeef, "errno is %d, expected 0xdeadbeef\n", errno);
4191
4192 errno = 0xdeadbeef;
4193 ret = p__memicmp_l(s1, s2, 3, NULL);
4194 ok(ret == -1, "got %d\n", ret);
4195 ok(errno == 0xdeadbeef, "errno is %d, expected 0xdeadbeef\n", errno);
4196}

Referenced by START_TEST().

◆ test__stricmp()

static void test__stricmp ( void  )
static

Definition at line 3542 of file string.c.

3543{
3544 int ret;
3545
3546 ret = _stricmp("test", "test");
3547 ok(ret == 0, "_stricmp returned %d\n", ret);
3548 ret = _stricmp("a", "z");
3549 ok(ret < 0, "_stricmp returned %d\n", ret);
3550 ret = _stricmp("z", "a");
3551 ok(ret > 0, "_stricmp returned %d\n", ret);
3552 ret = _stricmp("\xa5", "\xb9");
3553 ok(ret < 0, "_stricmp returned %d\n", ret);
3554 ret = _stricmp("\xa5\xa1", "\xb9\xa1"); /* valid gbk characters */
3555 ok(ret < 0, "_stricmp returned %d\n", ret);
3556 ret = _stricmp("abc\xa5\xa1", "abc");
3557 ok(ret > 0, "_stricmp returned %d\n", ret);
3558
3559 if(!setlocale(LC_ALL, "polish")) {
3560 win_skip("stricmp tests\n");
3561 return;
3562 }
3563
3564 ret = _stricmp("test", "test");
3565 ok(ret == 0, "_stricmp returned %d\n", ret);
3566 ret = _stricmp("a", "z");
3567 ok(ret < 0, "_stricmp returned %d\n", ret);
3568 ret = _stricmp("z", "a");
3569 ok(ret > 0, "_stricmp returned %d\n", ret);
3570 ret = _stricmp("\xa5", "\xb9");
3571 ok(ret == 0, "_stricmp returned %d\n", ret);
3572 ret = _stricmp("a", "\xb9");
3573 ok(ret < 0, "_stricmp returned %d\n", ret);
3574 ret = _stricmp("\xa5\xa1", "\xb9\xa1"); /* valid gbk characters */
3575 ok(ret == 0, "_stricmp returned %d\n", ret);
3576 ret = _stricmp("abc\xa5\xa1", "abc");
3577 ok(ret > 0, "_stricmp returned %d\n", ret);
3578
3579 ok(setlocale(LC_ALL, ".936") != NULL, "setlocale failed.\n");
3580 ret = _stricmp("test", "test");
3581 ok(ret == 0, "_stricmp returned %d\n", ret);
3582 ret = _stricmp("a", "z");
3583 ok(ret < 0, "_stricmp returned %d\n", ret);
3584 ret = _stricmp("z", "a");
3585 ok(ret > 0, "_stricmp returned %d\n", ret);
3586 ret = _stricmp("\xa5", "\xb9");
3587 ok(ret < 0, "_stricmp returned %d\n", ret);
3588 ret = _stricmp("a", "\xb9");
3589 ok(ret < 0, "_stricmp returned %d\n", ret);
3590 ret = _stricmp("\xa5\xa1", "\xb9\xa1"); /* valid gbk characters */
3591 ok(ret < 0, "_stricmp returned %d\n", ret);
3592 ret = _stricmp("\x82\xa0", "\x83\x41"); /* valid shift-jis characters */
3593 ok(ret < 0, "_stricmp returned %d\n", ret);
3594 ret = _stricmp("\x81\x00", "\x81\x01"); /* invalid for gbk and shift-jis */
3595 ok(ret < 0, "_stricmp returned %d\n", ret);
3596 ret = _stricmp("abc\xa5\xa1", "abc");
3597 ok(ret > 0, "_stricmp returned %d\n", ret);
3598
3599 skip_2k3_fail ok(setlocale(LC_ALL, "Japanese_Japan.932") != NULL, "setlocale failed.\n");
3600 ret = _stricmp("test", "test");
3601 ok(ret == 0, "_stricmp returned %d\n", ret);
3602 ret = _stricmp("a", "z");
3603 ok(ret < 0, "_stricmp returned %d\n", ret);
3604 ret = _stricmp("z", "a");
3605 ok(ret > 0, "_stricmp returned %d\n", ret);
3606 ret = _stricmp("\xa5", "\xb9");
3607 ok(ret < 0, "_stricmp returned %d\n", ret);
3608 ret = _stricmp("\xa5\xa1", "\xb9\xa1"); /* valid gbk characters */
3609 ok(ret < 0, "_stricmp returned %d\n", ret);
3610 ret = _stricmp("\x82\xa0", "\x83\x41"); /* valid shift-jis characters */
3611 ok(ret < 0, "_stricmp returned %d\n", ret);
3612 ret = _stricmp("\x81\x00", "\x81\x01"); /* invalid for gbk and shift-jis */
3613 ok(ret < 0, "_stricmp returned %d\n", ret);
3614 ret = _stricmp("abc\x82\xa0", "abc");
3615 ok(ret > 0, "_stricmp returned %d\n", ret);
3616
3617 setlocale(LC_ALL, "C");
3618}
#define _stricmp
Definition: cat.c:22
#define skip_2k3_fail
Definition: test.h:191

Referenced by START_TEST().

◆ test__strlwr_s()

static void test__strlwr_s ( void  )
static

Definition at line 2634 of file string.c.

2635{
2636 errno_t ret;
2637 char buffer[20];
2638
2639 if (!p_strlwr_s)
2640 {
2641 win_skip("Skipping _strlwr_s tests\n");
2642 return;
2643 }
2644
2645 errno = EBADF;
2646 ret = p_strlwr_s(NULL, 0);
2647 ok(ret == EINVAL, "Expected _strlwr_s to return EINVAL, got %d\n", ret);
2648 ok(errno == EINVAL, "Expected errno to be EINVAL, got %d\n", errno);
2649
2650 errno = EBADF;
2651 ret = p_strlwr_s(NULL, sizeof(buffer));
2652 ok(ret == EINVAL, "Expected _strlwr_s to return EINVAL, got %d\n", ret);
2653 ok(errno == EINVAL, "Expected errno to be EINVAL, got %d\n", errno);
2654
2655 errno = EBADF;
2656 ret = p_strlwr_s(buffer, 0);
2657 ok(ret == EINVAL, "Expected _strlwr_s to return EINVAL, got %d\n", ret);
2658 ok(errno == EINVAL, "Expected errno to be EINVAL, got %d\n", errno);
2659
2660 strcpy(buffer, "GoRrIsTeR");
2661 errno = EBADF;
2662 ret = p_strlwr_s(buffer, 5);
2663 ok(ret == EINVAL, "Expected _strlwr_s to return EINVAL, got %d\n", ret);
2664 ok(errno == EINVAL, "Expected errno to be EINVAL, got %d\n", errno);
2665 ok(!memcmp(buffer, "\0oRrIsTeR", sizeof("\0oRrIsTeR")),
2666 "Expected the output buffer to be \"\\0oRrIsTeR\"\n");
2667
2668 strcpy(buffer, "GoRrIsTeR");
2669 errno = EBADF;
2670 ret = p_strlwr_s(buffer, sizeof("GoRrIsTeR") - 1);
2671 ok(ret == EINVAL, "Expected _strlwr_s to return EINVAL, got %d\n", ret);
2672 ok(errno == EINVAL, "Expected errno to be EINVAL, got %d\n", errno);
2673 ok(!memcmp(buffer, "\0oRrIsTeR", sizeof("\0oRrIsTeR")),
2674 "Expected the output buffer to be \"\\0oRrIsTeR\"\n");
2675
2676 strcpy(buffer, "GoRrIsTeR");
2677 ret = p_strlwr_s(buffer, sizeof("GoRrIsTeR"));
2678 ok(ret == 0, "Expected _strlwr_s to return 0, got %d\n", ret);
2679 ok(!strcmp(buffer, "gorrister"),
2680 "Expected the output buffer to be \"gorrister\", got \"%s\"\n",
2681 buffer);
2682
2683 memcpy(buffer, "GoRrIsTeR\0ELLEN", sizeof("GoRrIsTeR\0ELLEN"));
2684 ret = p_strlwr_s(buffer, sizeof(buffer));
2685 ok(ret == 0, "Expected _strlwr_s to return 0, got %d\n", ret);
2686 ok(!memcmp(buffer, "gorrister\0ELLEN", sizeof("gorrister\0ELLEN")),
2687 "Expected the output buffer to be \"gorrister\\0ELLEN\", got \"%s\"\n",
2688 buffer);
2689
2690 ret = p_strlwr_s((char *)"already_lowercase", sizeof("already_lowercase"));
2691 ok(ret == 0, "Expected _strlwr_s to return 0, got %d\n", ret);
2692}

Referenced by START_TEST().

◆ test__strnicmp_l()

static void test__strnicmp_l ( void  )
static

Definition at line 4933 of file string.c.

4934{
4935 static const struct {
4936 const char *str1;
4937 const char *str2;
4938 } tests[] = {
4939 { "wine", "win" },
4940 /* GBK string tests */
4941 { "\xce\xac", "ceac" },
4942 { "\xce\xac\xc4\xe1", "\xce\xac" },
4943 { "\xce\xac""abc", "\xce\xac" },
4944 { "abc\xce\xac", "abc" },
4945 { "\xce\xac\xc4\xe1", "\xc4\xe1" },
4946 { "\xce\xac", "\xc4\xe1" },
4947 { "\xb8\xdf", "\xb8\xdb" },
4948 { "\xb9", "\xa5" },
4949 };
4951 int ret, i;
4952
4953 if (!p__strnicmp_l)
4954 {
4955 win_skip("_strnicmp_l isn't available.\n");
4956 return;
4957 }
4958
4959 for (i = 0; i < ARRAY_SIZE(tests); i++)
4960 {
4961 ret = p__strnicmp_l(tests[i].str1, tests[i].str2, INT_MAX, 0);
4962 ok(ret > 0, "tests[%d]: Got %d.\n", i, ret);
4963
4964 ret = p__strnicmp_l(tests[i].str2, tests[i].str1, INT_MAX, 0);
4965 ok(ret < 0, "tests[%d]: Got %d.\n", i, ret);
4966 }
4967
4968 if (!p__create_locale)
4969 win_skip("_create_locale isn't available.\n");
4970 else
4971 {
4972 locale = p__create_locale(LC_ALL, ".936");
4973 ok(locale != NULL, "Failed to create locale.\n");
4974
4975 for (i = 0; i < ARRAY_SIZE(tests); i++)
4976 {
4977 ret = p__strnicmp_l(tests[i].str1, tests[i].str2, INT_MAX, locale);
4978 ok(ret > 0, "tests[%d]: Got %d.\n", i, ret);
4979
4980 ret = p__strnicmp_l(tests[i].str2, tests[i].str1, INT_MAX, locale);
4981 ok(ret < 0, "tests[%d]: Got %d.\n", i, ret);
4982 }
4983
4984 p__free_locale(locale);
4985 }
4986
4987 if (!setlocale(LC_ALL, ".936"))
4988 {
4989 win_skip("Skip testing _strnicmp_l with 936 code page.\n");
4990 return;
4991 }
4992
4993 for (i = 0; i < ARRAY_SIZE(tests); i++)
4994 {
4995 ret = p__strnicmp_l(tests[i].str1, tests[i].str2, INT_MAX, 0);
4996 ok(ret > 0, "tests[%d]: Got %d.\n", i, ret);
4997
4998 ret = p__strnicmp_l(tests[i].str2, tests[i].str1, INT_MAX, 0);
4999 ok(ret < 0, "tests[%d]: Got %d.\n", i, ret);
5000 }
5001
5002 setlocale(LC_ALL, "C");
5003}
Definition: _locale.h:75

Referenced by START_TEST().

◆ test__strnset_s()

static void test__strnset_s ( void  )
static

Definition at line 3921 of file string.c.

3922{
3923 char buf[5] = {0};
3924 int r;
3925
3926 if(!p__strnset_s) {
3927 win_skip("_strnset_s not available\n");
3928 return;
3929 }
3930
3931 r = p__strnset_s(NULL, 0, 'a', 0);
3932 ok(r == 0, "r = %d\n", r);
3933
3934 buf[0] = buf[1] = buf[2] = 'b';
3935 r = p__strnset_s(buf, sizeof(buf), 'a', 2);
3936 ok(r == 0, "r = %d\n", r);
3937 ok(!strcmp(buf, "aab"), "buf = %s\n", buf);
3938
3939 r = p__strnset_s(buf, 0, 'a', 0);
3940 ok(r == EINVAL, "r = %d\n", r);
3941
3942 r = p__strnset_s(NULL, 0, 'a', 1);
3943 ok(r == EINVAL, "r = %d\n", r);
3944
3945 buf[3] = 'b';
3946 r = p__strnset_s(buf, sizeof(buf)-1, 'c', 2);
3947 ok(r == EINVAL, "r = %d\n", r);
3948 ok(!buf[0] && buf[1]=='c' && buf[2]=='b', "buf = %s\n", buf);
3949}

Referenced by START_TEST().

◆ test__strtod()

static void test__strtod ( void  )
static

Definition at line 2079 of file string.c.

2080{
2081 static const struct {
2082 const char *str;
2083 int len;
2084 double ret;
2085 int err;
2086 } tests[] = {
2087 { "12.1", 4, 12.1 },
2088 { "-13.721", 7, -13.721 },
2089 { "INF", 0, 0 },
2090 { ".21e12", 6, 210000000000.0 },
2091 { "214353e-3", 9, 214.353 },
2092 { "NAN", 0, 0 },
2093 { "12.1d2", 6, 12.1e2 },
2094 { " d10", 0, 0 },
2095 { "0.1", 3, 0.1 },
2096 { "-0.1", 4, -0.1 },
2097 { "0.1281832188491894198128921", 27, 0.1281832188491894198128921 },
2098 { "0.82181281288121", 16, 0.82181281288121 },
2099 { "21921922352523587651128218821", 29, 21921922352523587651128218821.0 },
2100 { "0.1d238", 7, 0.1e238 },
2101 { "0.1D-4736", 9, 0, ERANGE },
2102 { "3.4028234663852887e38", 21, FLT_MAX },
2103 { "1.1754943508222875e-38", 22, FLT_MIN },
2104 { "1.7976931348623158e+308", 23, DBL_MAX },
2105 { "1.7976931348623159e+308", 23, INFINITY, ERANGE },
2106 { "2.2250738585072014e-308", 23, DBL_MIN },
2107 { "-1.7976931348623158e+308", 24, -DBL_MAX },
2108 { "-1.7976931348623159e+308", 24, -INFINITY, ERANGE },
2109 { "00", 2, 0 },
2110 { "00.", 3, 0 },
2111 { ".00", 3, 0 },
2112 { "-0.", 3, 0 },
2113 { "0e13", 4, 0 },
2114 };
2115 const char overflow[] = "1d9999999999999999999";
2116
2117 char *end;
2118 double d;
2119 int i;
2120
2121 for (i=0; i<ARRAY_SIZE(tests); i++)
2122 {
2123#ifdef __REACTOS__
2124 if ((i == 19) && IsReactOS())
2125 {
2126 skip("Skipping i == 19, because it crashes on ReactOS\n");
2127 continue;
2128 }
2129#endif
2130 errno = 0xdeadbeef;
2131 d = strtod(tests[i].str, &end);
2132 ok(d == tests[i].ret, "%d) d = %.16e\n", i, d);
2133 ok(end == tests[i].str + tests[i].len, "%d) len = %d\n",
2134 i, (int)(end - tests[i].str));
2135 ok(errno == tests[i].err || (!tests[i].err && errno == 0xdeadbeef) /* <= 2003 */,
2136 "%d) errno = %d\n", i, errno);
2137 }
2138
2139 if (!p__strtod_l)
2140 win_skip("_strtod_l not found\n");
2141 else
2142 {
2143 errno = EBADF;
2144 d = strtod(NULL, NULL);
2145 ok(d == 0.0, "d = %.16e\n", d);
2146 ok(errno == EINVAL, "errno = %x\n", errno);
2147
2148 errno = EBADF;
2149 end = (char *)0xdeadbeef;
2150 d = strtod(NULL, &end);
2151 ok(d == 0.0, "d = %.16e\n", d);
2152 ok(errno == EINVAL, "errno = %x\n", errno);
2153 ok(!end, "incorrect end ptr %p\n", end);
2154
2155 errno = EBADF;
2156 d = p__strtod_l(NULL, NULL, NULL);
2157 ok(d == 0.0, "d = %.16e\n", d);
2158 ok(errno == EINVAL, "errno = %x\n", errno);
2159 }
2160
2161 /* Set locale with non '.' decimal point (',') */
2162 if(!setlocale(LC_ALL, "Polish")) {
2163 win_skip("system with limited locales\n");
2164 return;
2165 }
2166
2167 d = strtod("12.1", NULL);
2168 ok(d == 12.0, "d = %.16e\n", d);
2169
2170 d = strtod("12,1", NULL);
2171 ok(d == 12.1, "d = %.16e\n", d);
2172
2173 setlocale(LC_ALL, "C");
2174
2175 errno = 0xdeadbeef;
2176 strtod(overflow, &end);
2177 ok(errno == ERANGE, "errno = %x\n", errno);
2178 ok(end == overflow+21, "incorrect end (%d)\n", (int)(end-overflow));
2179
2180 errno = 0xdeadbeef;
2181 strtod("-1d309", NULL);
2182 ok(errno == ERANGE, "errno = %x\n", errno);
2183}
#define skip(...)
Definition: atltest.h:64
GLuint GLuint end
Definition: gl.h:1545
#define INFINITY
Definition: math.h:56
#define FLT_MAX
Definition: float.h:91
#define FLT_MIN
Definition: float.h:94
#define DBL_MIN
Definition: float.h:79
_Check_return_ double __cdecl strtod(_In_z_ const char *_Str, _Out_opt_ _Deref_post_z_ char **_EndPtr)

Referenced by START_TEST().

◆ test__strtoi64()

static void test__strtoi64 ( void  )
static

Definition at line 1917 of file string.c.

1918{
1919 static const char no1[] = "31923";
1920 static const char no2[] = "-213312";
1921 static const char no3[] = "12aa";
1922 static const char no4[] = "abc12";
1923 static const char overflow[] = "99999999999999999999";
1924 static const char neg_overflow[] = "-99999999999999999999";
1925 static const char hex[] = "0x123";
1926 static const char oct[] = "000123";
1927 static const char blanks[] = " 12 212.31";
1928
1929 __int64 res;
1930 unsigned __int64 ures;
1931 char *endpos;
1932
1933 if(!p_strtoi64 || !p_strtoui64) {
1934 win_skip("_strtoi64 or _strtoui64 not found\n");
1935 return;
1936 }
1937
1938 errno = 0xdeadbeef;
1939 res = p_strtoi64(no1, NULL, 10);
1940 ok(res == 31923, "res != 31923\n");
1941 res = p_strtoi64(no2, NULL, 10);
1942 ok(res == -213312, "res != -213312\n");
1943 res = p_strtoi64(no3, NULL, 10);
1944 ok(res == 12, "res != 12\n");
1945 res = p_strtoi64(no4, &endpos, 10);
1946 ok(res == 0, "res != 0\n");
1947 ok(endpos == no4, "Scanning was not stopped on first character\n");
1948 res = p_strtoi64(hex, &endpos, 10);
1949 ok(res == 0, "res != 0\n");
1950 ok(endpos == hex+1, "Incorrect endpos (%p-%p)\n", hex, endpos);
1951 res = p_strtoi64(oct, &endpos, 10);
1952 ok(res == 123, "res != 123\n");
1953 ok(endpos == oct+strlen(oct), "Incorrect endpos (%p-%p)\n", oct, endpos);
1954 res = p_strtoi64(blanks, &endpos, 10);
1955 ok(res == 12, "res != 12\n");
1956 ok(endpos == blanks+10, "Incorrect endpos (%p-%p)\n", blanks, endpos);
1957 ok(errno == 0xdeadbeef, "errno = %x\n", errno);
1958
1959 errno = 0xdeadbeef;
1960 res = p_strtoi64(overflow, &endpos, 10);
1961 ok(res == _I64_MAX, "res != _I64_MAX\n");
1962 ok(endpos == overflow+strlen(overflow), "Incorrect endpos (%p-%p)\n", overflow, endpos);
1963 ok(errno == ERANGE, "errno = %x\n", errno);
1964
1965 errno = 0xdeadbeef;
1966 res = p_strtoi64(neg_overflow, &endpos, 10);
1967 ok(res == _I64_MIN, "res != _I64_MIN\n");
1968 ok(endpos == neg_overflow+strlen(neg_overflow), "Incorrect endpos (%p-%p)\n", neg_overflow, endpos);
1969 ok(errno == ERANGE, "errno = %x\n", errno);
1970
1971 errno = 0xdeadbeef;
1972 res = p_strtoi64(no1, &endpos, 16);
1973 ok(res == 203043, "res != 203043\n");
1974 ok(endpos == no1+strlen(no1), "Incorrect endpos (%p-%p)\n", no1, endpos);
1975 res = p_strtoi64(no2, &endpos, 16);
1976 ok(res == -2175762, "res != -2175762\n");
1977 ok(endpos == no2+strlen(no2), "Incorrect endpos (%p-%p)\n", no2, endpos);
1978 res = p_strtoi64(no3, &endpos, 16);
1979 ok(res == 4778, "res != 4778\n");
1980 ok(endpos == no3+strlen(no3), "Incorrect endpos (%p-%p)\n", no3, endpos);
1981 res = p_strtoi64(no4, &endpos, 16);
1982 ok(res == 703506, "res != 703506\n");
1983 ok(endpos == no4+strlen(no4), "Incorrect endpos (%p-%p)\n", no4, endpos);
1984 res = p_strtoi64(hex, &endpos, 16);
1985 ok(res == 291, "res != 291\n");
1986 ok(endpos == hex+strlen(hex), "Incorrect endpos (%p-%p)\n", hex, endpos);
1987 res = p_strtoi64(oct, &endpos, 16);
1988 ok(res == 291, "res != 291\n");
1989 ok(endpos == oct+strlen(oct), "Incorrect endpos (%p-%p)\n", oct, endpos);
1990 res = p_strtoi64(blanks, &endpos, 16);
1991 ok(res == 18, "res != 18\n");
1992 ok(endpos == blanks+10, "Incorrect endpos (%p-%p)\n", blanks, endpos);
1993 ok(errno == 0xdeadbeef, "errno = %x\n", errno);
1994
1995 errno = 0xdeadbeef;
1996 res = p_strtoi64(hex, &endpos, 36);
1997 ok(res == 1541019, "res != 1541019\n");
1998 ok(endpos == hex+strlen(hex), "Incorrect endpos (%p-%p)\n", hex, endpos);
1999 ok(errno == 0xdeadbeef, "errno = %x\n", errno);
2000
2001 errno = 0xdeadbeef;
2002 res = p_strtoi64(no1, &endpos, 0);
2003 ok(res == 31923, "res != 31923\n");
2004 ok(endpos == no1+strlen(no1), "Incorrect endpos (%p-%p)\n", no1, endpos);
2005 res = p_strtoi64(no2, &endpos, 0);
2006 ok(res == -213312, "res != -213312\n");
2007 ok(endpos == no2+strlen(no2), "Incorrect endpos (%p-%p)\n", no2, endpos);
2008 res = p_strtoi64(no3, &endpos, 10);
2009 ok(res == 12, "res != 12\n");
2010 ok(endpos == no3+2, "Incorrect endpos (%p-%p)\n", no3, endpos);
2011 res = p_strtoi64(no4, &endpos, 10);
2012 ok(res == 0, "res != 0\n");
2013 ok(endpos == no4, "Incorrect endpos (%p-%p)\n", no4, endpos);
2014 res = p_strtoi64(hex, &endpos, 10);
2015 ok(res == 0, "res != 0\n");
2016 ok(endpos == hex+1, "Incorrect endpos (%p-%p)\n", hex, endpos);
2017 res = p_strtoi64(oct, &endpos, 10);
2018 ok(res == 123, "res != 123\n");
2019 ok(endpos == oct+strlen(oct), "Incorrect endpos (%p-%p)\n", oct, endpos);
2020 res = p_strtoi64(blanks, &endpos, 10);
2021 ok(res == 12, "res != 12\n");
2022 ok(endpos == blanks+10, "Incorrect endpos (%p-%p)\n", blanks, endpos);
2023 ok(errno == 0xdeadbeef, "errno = %x\n", errno);
2024
2025 errno = 0xdeadbeef;
2026 ures = p_strtoui64(no1, &endpos, 0);
2027 ok(ures == 31923, "ures != 31923\n");
2028 ok(endpos == no1+strlen(no1), "Incorrect endpos (%p-%p)\n", no1, endpos);
2029 ures = p_strtoui64(no2, &endpos, 0);
2030 ok(ures == -213312, "ures != -213312\n");
2031 ok(endpos == no2+strlen(no2), "Incorrect endpos (%p-%p)\n", no2, endpos);
2032 ures = p_strtoui64(no3, &endpos, 10);
2033 ok(ures == 12, "ures != 12\n");
2034 ok(endpos == no3+2, "Incorrect endpos (%p-%p)\n", no3, endpos);
2035 ures = p_strtoui64(no4, &endpos, 10);
2036 ok(ures == 0, "ures != 0\n");
2037 ok(endpos == no4, "Incorrect endpos (%p-%p)\n", no4, endpos);
2038 ures = p_strtoui64(hex, &endpos, 10);
2039 ok(ures == 0, "ures != 0\n");
2040 ok(endpos == hex+1, "Incorrect endpos (%p-%p)\n", hex, endpos);
2041 ures = p_strtoui64(oct, &endpos, 10);
2042 ok(ures == 123, "ures != 123\n");
2043 ok(endpos == oct+strlen(oct), "Incorrect endpos (%p-%p)\n", oct, endpos);
2044 ures = p_strtoui64(blanks, &endpos, 10);
2045 ok(ures == 12, "ures != 12\n");
2046 ok(endpos == blanks+10, "Incorrect endpos (%p-%p)\n", blanks, endpos);
2047 ok(errno == 0xdeadbeef, "errno = %x\n", errno);
2048
2049 errno = 0xdeadbeef;
2050 ures = p_strtoui64(overflow, &endpos, 10);
2051 ok(ures == _UI64_MAX, "ures != _UI64_MAX\n");
2052 ok(endpos == overflow+strlen(overflow), "Incorrect endpos (%p-%p)\n", overflow, endpos);
2053 ok(errno == ERANGE, "errno = %x\n", errno);
2054
2055 errno = 0xdeadbeef;
2056 ures = p_strtoui64(neg_overflow, &endpos, 10);
2057 ok(ures == 1, "ures != 1\n");
2058 ok(endpos == neg_overflow+strlen(neg_overflow), "Incorrect endpos (%p-%p)\n", neg_overflow, endpos);
2059 ok(errno == ERANGE, "errno = %x\n", errno);
2060}
ios_base &_STLP_CALL oct(ios_base &__s)
Definition: _ios_base.h:327
#define __int64
Definition: basetyps.h:16
GLuint res
Definition: glext.h:9613
int hex(char ch)
#define _I64_MAX
Definition: limits.h:62
#define _I64_MIN
Definition: limits.h:61
#define _UI64_MAX
Definition: limits.h:63

Referenced by START_TEST().

◆ test__strupr()

static void test__strupr ( void  )
static

Definition at line 4198 of file string.c.

4199{
4200 const char str[] = "123";
4201 const char *const_p;
4202 char str2[4];
4203 char *mem, *p;
4204 DWORD prot;
4205
4207 ok(mem != NULL, "VirtualAlloc failed\n");
4208 memcpy(mem, str, sizeof(str));
4209 ok(VirtualProtect(mem, sizeof(str), PAGE_READONLY, &prot), "VirtualProtect failed\n");
4210
4211 strcpy(str2, "aBc");
4212 p = _strupr(str2);
4213 ok(p == str2, "_strupr returned %p\n", p);
4214 ok(!strcmp(str2, "ABC"), "str2 = %s\n", str2);
4215
4216 p = _strupr(mem);
4217 ok(p == mem, "_strupr returned %p\n", p);
4218 ok(!strcmp(mem, "123"), "mem = %s\n", mem);
4219
4220 const_p = "ALREADY_UPPERCASE";
4221 p = _strupr((char *)const_p);
4222 ok(p == const_p, "_strupr returned %p\n", p);
4223
4224 if(!setlocale(LC_ALL, "english")) {
4225 VirtualFree(mem, sizeof(str), MEM_RELEASE);
4226 win_skip("English locale _strupr tests\n");
4227 return;
4228 }
4229
4230 strcpy(str2, "aBc");
4231 p = _strupr(str2);
4232 ok(p == str2, "_strupr returned %p\n", p);
4233 ok(!strcmp(str2, "ABC"), "str2 = %s\n", str2);
4234
4235 if (0) /* crashes on Windows */
4236 {
4237 p = _strupr(mem);
4238 ok(p == mem, "_strupr returned %p\n", p);
4239 ok(!strcmp(mem, "123"), "mem = %s\n", mem);
4240 }
4241
4242 setlocale(LC_ALL, "C");
4243 VirtualFree(mem, sizeof(str), MEM_RELEASE);
4244}
#define PAGE_READONLY
Definition: compat.h:138
unsigned long DWORD
Definition: ntddk_ex.h:95
GLfloat GLfloat p
Definition: glext.h:8902
#define PAGE_READWRITE
Definition: nt_native.h:1304
#define MEM_RELEASE
Definition: nt_native.h:1316
#define MEM_COMMIT
Definition: nt_native.h:1313
_strupr
Definition: string.h:453
LPVOID NTAPI VirtualAlloc(IN LPVOID lpAddress, IN SIZE_T dwSize, IN DWORD flAllocationType, IN DWORD flProtect)
Definition: virtmem.c:65
BOOL NTAPI VirtualProtect(IN LPVOID lpAddress, IN SIZE_T dwSize, IN DWORD flNewProtect, OUT PDWORD lpflOldProtect)
Definition: virtmem.c:135
BOOL NTAPI VirtualFree(IN LPVOID lpAddress, IN SIZE_T dwSize, IN DWORD dwFreeType)
Definition: virtmem.c:119

Referenced by START_TEST().

◆ test__tcscoll()

static void test__tcscoll ( void  )
static

Definition at line 4343 of file string.c.

4344{
4345 struct test {
4346 const char *locale;
4347 const char *str1;
4348 const char *str2;
4349 int exp;
4350 };
4351 static const struct test tests[] = {
4352 { "English", "ABCD", "ABCD", 0 },
4353 { "English", "ABC", "ABCD", -1 },
4354 { "English", "ABCD", "ABC", 1 },
4355 { "English", "ABCe", "ABCf", -1 },
4356 { "English", "abcd", "ABCD", -1 },
4357 { "English", "AB D", "AB-D", 1 },
4358 { "English", "AB D", "AB'D", 1 },
4359
4360 { "C", "ABCD", "ABCD", 0 },
4361 { "C", "ABC", "ABCD", -1 },
4362 { "C", "ABCD", "ABC", 1 },
4363 { "C", "ABCe", "ABCf", -1 },
4364 { "C", "abcd", "ABCD", 1 },
4365 { "C", "AB D", "AB-D", -1 },
4366 { "C", "AB D", "AB'D", -1 },
4367 };
4368 WCHAR str1W[16];
4369 WCHAR str2W[16];
4370 char str1[16];
4371 char str2[16];
4372 size_t len;
4373 int i, ret;
4374
4375 for (i = 0; i < ARRAY_SIZE(tests); i++)
4376 {
4377 if (!setlocale(LC_ALL, tests[i].locale))
4378 {
4379 win_skip("%s locale _tcsncoll tests\n", tests[i].locale);
4380 for (; i+1 < ARRAY_SIZE(tests); i++)
4381 if (strcmp(tests[i].locale, tests[i+1].locale)) break;
4382 continue;
4383 }
4384
4385 memset(str1, 0xee, sizeof(str1));
4386 strcpy(str1, tests[i].str1);
4387
4388 memset(str2, 0xff, sizeof(str2));
4389 strcpy(str2, tests[i].str2);
4390
4391 ret = strcoll(str1, str2);
4392 if (!tests[i].exp)
4393 ok(!ret, "expected 0, got %d for %s, %s for locale %s\n",
4394 ret, str1, str2, tests[i].locale);
4395 else if (tests[i].exp < 0)
4396 ok(ret < 0, "expected < 0, got %d for %s, %s for locale %s\n",
4397 ret, str1, str2, tests[i].locale);
4398 else
4399 ok(ret > 0, "expected > 0, got %d for %s, %s for locale %s\n",
4400 ret, str1, str2, tests[i].locale);
4401
4402 memset(str1W, 0xee, sizeof(str1W));
4403 len = mbstowcs(str1W, str1, ARRAY_SIZE(str1W));
4404 str1W[len] = 0;
4405
4406 memset(str2W, 0xff, sizeof(str2W));
4407 len = mbstowcs(str2W, str2, ARRAY_SIZE(str2W));
4408 str2W[len] = 0;
4409
4410 ret = wcscoll(str1W, str2W);
4411 if (!tests[i].exp)
4412 ok(!ret, "expected 0, got %d for %s, %s for locale %s\n",
4413 ret, str1, str2, tests[i].locale);
4414 else if (tests[i].exp < 0)
4415 ok(ret < 0, "expected < 0, got %d for %s, %s for locale %s\n",
4416 ret, str1, str2, tests[i].locale);
4417 else
4418 ok(ret > 0, "expected > 0, got %d for %s, %s for locale %s\n",
4419 ret, str1, str2, tests[i].locale);
4420 }
4421}
#define strcoll
Definition: util.h:34
#define test
Definition: rosglue.h:37
_Check_return_ _CRTIMP int __cdecl wcscoll(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
mbstowcs
Definition: stdlib.h:925
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by START_TEST().

◆ test__tcsncoll()

static void test__tcsncoll ( void  )
static

Definition at line 4246 of file string.c.

4247{
4248 struct test {
4249 const char *locale;
4250 const char *str1;
4251 const char *str2;
4252 size_t count;
4253 int exp;
4254 };
4255 static const struct test tests[] = {
4256 { "English", "ABCD", "ABCD", 4, 0 },
4257 { "English", "ABCD", "ABCD", 10, 0 },
4258
4259 { "English", "ABC", "ABCD", 3, 0 },
4260 { "English", "ABC", "ABCD", 4, -1 },
4261 { "English", "ABC", "ABCD", 10, -1 },
4262
4263 { "English", "ABCD", "ABC", 3, 0 },
4264 { "English", "ABCD", "ABC", 4, 1 },
4265 { "English", "ABCD", "ABC", 10, 1 },
4266
4267 { "English", "ABCe", "ABCf", 3, 0 },
4268 { "English", "abcd", "ABCD", 10, -1 },
4269
4270 { "English", "AB D", "AB-D", 4, 1 },
4271 { "English", "AB D", "AB'D", 4, 1 },
4272
4273 { "C", "ABCD", "ABCD", 4, 0 },
4274 { "C", "ABCD", "ABCD", 10, 0 },
4275
4276 { "C", "ABC", "ABCD", 3, 0 },
4277 { "C", "ABC", "ABCD", 10, -1 },
4278
4279 { "C", "ABCD", "ABC", 3, 0 },
4280 { "C", "ABCD", "ABC", 10, 1 },
4281
4282 { "C", "ABCe", "ABCf", 3, 0 },
4283 { "C", "abcd", "ABCD", 10, 1 },
4284
4285 { "C", "AB D", "AB-D", 4, -1 },
4286 { "C", "AB D", "AB'D", 4, -1 },
4287 };
4288 WCHAR str1W[16];
4289 WCHAR str2W[16];
4290 char str1[16];
4291 char str2[16];
4292 size_t len;
4293 int i, ret;
4294
4295 for (i = 0; i < ARRAY_SIZE(tests); i++)
4296 {
4297 if (!setlocale(LC_ALL, tests[i].locale))
4298 {
4299 win_skip("%s locale _tcsncoll tests\n", tests[i].locale);
4300 for (; i+1 < ARRAY_SIZE(tests); i++)
4301 if (strcmp(tests[i].locale, tests[i+1].locale)) break;
4302 continue;
4303 }
4304
4305 memset(str1, 0xee, sizeof(str1));
4306 strcpy(str1, tests[i].str1);
4307
4308 memset(str2, 0xff, sizeof(str2));
4309 strcpy(str2, tests[i].str2);
4310
4311 ret = _strncoll(str1, str2, tests[i].count);
4312 if (!tests[i].exp)
4313 ok(!ret, "expected 0, got %d for %s, %s, %d for locale %s\n",
4314 ret, str1, str2, (int)tests[i].count, tests[i].locale);
4315 else if (tests[i].exp < 0)
4316 ok(ret < 0, "expected < 0, got %d for %s, %s, %d for locale %s\n",
4317 ret, str1, str2, (int)tests[i].count, tests[i].locale);
4318 else
4319 ok(ret > 0, "expected > 0, got %d for %s, %s, %d for locale %s\n",
4320 ret, str1, str2, (int)tests[i].count, tests[i].locale);
4321
4322 memset(str1W, 0xee, sizeof(str1W));
4323 len = mbstowcs(str1W, str1, ARRAY_SIZE(str1W));
4324 str1W[len] = 0;
4325
4326 memset(str2W, 0xff, sizeof(str2W));
4327 len = mbstowcs(str2W, str2, ARRAY_SIZE(str2W));
4328 str2W[len] = 0;
4329
4330 ret = _wcsncoll(str1W, str2W, tests[i].count);
4331 if (!tests[i].exp)
4332 ok(!ret, "expected 0, got %d for %s, %s, %d for locale %s\n",
4333 ret, str1, str2, (int)tests[i].count, tests[i].locale);
4334 else if (tests[i].exp < 0)
4335 ok(ret < 0, "expected < 0, got %d for %s, %s, %d for locale %s\n",
4336 ret, str1, str2, (int)tests[i].count, tests[i].locale);
4337 else
4338 ok(ret > 0, "expected > 0, got %d for %s, %s, %d for locale %s\n",
4339 ret, str1, str2, (int)tests[i].count, tests[i].locale);
4340 }
4341}
GLuint GLuint GLsizei count
Definition: gl.h:1545
_Check_return_ _CRTIMP int __cdecl _strncoll(_In_z_ const char *_Str1, _In_z_ const char *_Str2, _In_ size_t _MaxCount)
_Check_return_ _CRTIMP int __cdecl _wcsncoll(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2, _In_ size_t _MaxCount)

Referenced by START_TEST().

◆ test__tcsnicoll()

static void test__tcsnicoll ( void  )
static

Definition at line 4423 of file string.c.

4424{
4425 struct test {
4426 const char *locale;
4427 const char *str1;
4428 const char *str2;
4429 size_t count;
4430 int exp;
4431 };
4432 static const struct test tests[] = {
4433 { "English", "abcd", "ABCD", 4, 0 },
4434 { "English", "abcd", "ABCD", 10, 0 },
4435
4436 { "English", "abc", "ABCD", 3, 0 },
4437 { "English", "abc", "ABCD", 4, -1 },
4438 { "English", "abc", "ABCD", 10, -1 },
4439
4440 { "English", "abcd", "ABC", 3, 0 },
4441 { "English", "abcd", "ABC", 4, 1 },
4442 { "English", "abcd", "ABC", 10, 1 },
4443
4444 { "English", "abcE", "ABCF", 3, 0 },
4445
4446 { "C", "abcd", "ABCD", 4, 0 },
4447 { "C", "abcd", "ABCD", 10, 0 },
4448
4449 { "C", "abc", "ABCD", 3, 0 },
4450 { "C", "abc", "ABCD", 10, -1 },
4451
4452 { "C", "abcd", "ABC", 3, 0 },
4453 { "C", "abcd", "ABC", 10, 1 },
4454
4455 { "C", "abce", "ABCf", 3, 0 },
4456 };
4457 WCHAR str1W[16];
4458 WCHAR str2W[16];
4459 char str1[16];
4460 char str2[16];
4461 size_t len;
4462 int i, ret;
4463
4464 for (i = 0; i < ARRAY_SIZE(tests); i++)
4465 {
4466 if (!setlocale(LC_ALL, tests[i].locale))
4467 {
4468 win_skip("%s locale _tcsnicoll tests\n", tests[i].locale);
4469 for (; i+1 < ARRAY_SIZE(tests); i++)
4470 if (strcmp(tests[i].locale, tests[i+1].locale)) break;
4471 continue;
4472 }
4473
4474 memset(str1, 0xee, sizeof(str1));
4475 strcpy(str1, tests[i].str1);
4476
4477 memset(str2, 0xff, sizeof(str2));
4478 strcpy(str2, tests[i].str2);
4479
4480 ret = _strnicoll(str1, str2, tests[i].count);
4481 if (!tests[i].exp)
4482 ok(!ret, "expected 0, got %d for %s, %s, %d\n", ret, str1, str2, (int)tests[i].count);
4483 else if (tests[i].exp < 0)
4484 ok(ret < 0, "expected < 0, got %d for %s, %s, %d\n", ret, str1, str2, (int)tests[i].count);
4485 else
4486 ok(ret > 0, "expected > 0, got %d for %s, %s, %d\n", ret, str1, str2, (int)tests[i].count);
4487
4488 memset(str1W, 0xee, sizeof(str1W));
4489 len = mbstowcs(str1W, str1, ARRAY_SIZE(str1W));
4490 str1W[len] = 0;
4491
4492 memset(str2W, 0xff, sizeof(str2W));
4493 len = mbstowcs(str2W, str2, ARRAY_SIZE(str2W));
4494 str2W[len] = 0;
4495
4496 ret = _wcsnicoll(str1W, str2W, tests[i].count);
4497 if (!tests[i].exp)
4498 ok(!ret, "expected 0, got %d for %s, %s, %d\n", ret, str1, str2, (int)tests[i].count);
4499 else if (tests[i].exp < 0)
4500 ok(ret < 0, "expected < 0, got %d for %s, %s, %d\n", ret, str1, str2, (int)tests[i].count);
4501 else
4502 ok(ret > 0, "expected > 0, got %d for %s, %s, %d\n", ret, str1, str2, (int)tests[i].count);
4503 }
4504}
_Check_return_ _CRTIMP int __cdecl _wcsnicoll(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2, _In_ size_t _MaxCount)
_Check_return_ _CRTIMP int __cdecl _strnicoll(_In_z_ const char *_Str1, _In_z_ const char *_Str2, _In_ size_t _MaxCount)

Referenced by START_TEST().

◆ test__tolower_l()

static void test__tolower_l ( void  )
static

Definition at line 4901 of file string.c.

4902{
4903 int ret;
4904
4905 ok(setlocale(LC_ALL, "english") != NULL, "setlocale failed.\n");
4906 ret = _tolower_l('\xa5', 0);
4907 ok(ret == 165, "Got %d.\n", ret);
4908 ret = _tolower_l('\xb9', 0);
4909 ok(ret == 185, "Got %d.\n", ret);
4910 ret = _tolower_l('a', 0);
4911 ok(ret == 97, "Got %d.\n", ret);
4912
4913 ok(setlocale(LC_ALL, ".936") != NULL, "setlocale failed.\n");
4914 ret = _tolower_l('\xa5', 0);
4915 ok(ret == -91, "Got %d.\n", ret);
4916 ret = _tolower_l('\xb9', 0);
4917 ok(ret == -71, "Got %d.\n", ret);
4918 ret = _tolower_l('a', 0);
4919 ok(ret == 97, "Got %d.\n", ret);
4920
4921 ok(setlocale(LC_ALL, "chinese-simplified") != NULL, "setlocale failed.\n");
4922 ret = _tolower_l('\xa5', 0);
4923 ok(ret == -91, "Got %d.\n", ret);
4924 ret = _tolower_l('\xb9', 0);
4925 ok(ret == -71, "Got %d.\n", ret);
4926 ret = _tolower_l('a', 0);
4927 ok(ret == 97, "Got %d.\n", ret);
4928
4929 setlocale(LC_ALL, "C");
4930}
_Check_return_ _CRTIMP int __cdecl _tolower_l(_In_ int c, _In_opt_ _locale_t locale)
Definition: stubs.c:697

Referenced by START_TEST().

◆ test__ultoa_s()

static void test__ultoa_s ( void  )
static

Definition at line 3064 of file string.c.

3065{
3066 errno_t ret;
3067 char buffer[33];
3068
3069 if (!p_ultoa_s)
3070 {
3071 win_skip("Skipping _ultoa_s tests\n");
3072 return;
3073 }
3074
3075 errno = EBADF;
3076 ret = p_ultoa_s(0, NULL, 0, 0);
3077 ok(ret == EINVAL, "Expected _ultoa_s to return EINVAL, got %d\n", ret);
3078 ok(errno == EINVAL, "Expected errno to be EINVAL, got %d\n", errno);
3079
3080 memset(buffer, 'X', sizeof(buffer));
3081 errno = EBADF;
3082 ret = p_ultoa_s(0, buffer, 0, 0);
3083 ok(ret == EINVAL, "Expected _ultoa_s to return EINVAL, got %d\n", ret);
3084 ok(errno == EINVAL, "Expected errno to be EINVAL, got %d\n", errno);
3085 ok(buffer[0] == 'X', "Expected the output buffer to be untouched\n");
3086
3087 memset(buffer, 'X', sizeof(buffer));
3088 errno = EBADF;
3089 ret = p_ultoa_s(0, buffer, sizeof(buffer), 0);
3090 ok(ret == EINVAL, "Expected _ultoa_s to return EINVAL, got %d\n", ret);
3091 ok(errno == EINVAL, "Expected errno to be EINVAL, got %d\n", errno);
3092 ok(buffer[0] == '\0', "Expected the output buffer to be null terminated\n");
3093
3094 memset(buffer, 'X', sizeof(buffer));
3095 errno = EBADF;
3096 ret = p_ultoa_s(0, buffer, sizeof(buffer), 64);
3097 ok(ret == EINVAL, "Expected _ultoa_s to return EINVAL, got %d\n", ret);
3098 ok(errno == EINVAL, "Expected errno to be EINVAL, got %d\n", errno);
3099 ok(buffer[0] == '\0', "Expected the output buffer to be null terminated\n");
3100
3101 memset(buffer, 'X', sizeof(buffer));
3102 errno = EBADF;
3103 ret = p_ultoa_s(12345678, buffer, 4, 10);
3104 ok(ret == ERANGE, "Expected _ultoa_s to return ERANGE, got %d\n", ret);
3105 ok(errno == ERANGE, "Expected errno to be ERANGE, got %d\n", errno);
3106 ok(!memcmp(buffer, "\000765", 4),
3107 "Expected the output buffer to be null terminated with truncated output\n");
3108
3109 memset(buffer, 'X', sizeof(buffer));
3110 errno = EBADF;
3111 ret = p_ultoa_s(12345678, buffer, 8, 10);
3112 ok(ret == ERANGE, "Expected _ultoa_s to return ERANGE, got %d\n", ret);
3113 ok(errno == ERANGE, "Expected errno to be ERANGE, got %d\n", errno);
3114 ok(!memcmp(buffer, "\0007654321", 8),
3115 "Expected the output buffer to be null terminated with truncated output\n");
3116
3117 ret = p_ultoa_s(12345678, buffer, 9, 10);
3118 ok(ret == 0, "Expected _ultoa_s to return 0, got %d\n", ret);
3119 ok(!strcmp(buffer, "12345678"),
3120 "Expected output buffer string to be \"12345678\", got \"%s\"\n",
3121 buffer);
3122
3123 ret = p_ultoa_s(43690, buffer, sizeof(buffer), 2);
3124 ok(ret == 0, "Expected _ultoa_s to return 0, got %d\n", ret);
3125 ok(!strcmp(buffer, "1010101010101010"),
3126 "Expected output buffer string to be \"1010101010101010\", got \"%s\"\n",
3127 buffer);
3128
3129 ret = p_ultoa_s(1092009, buffer, sizeof(buffer), 36);
3130 ok(ret == 0, "Expected _ultoa_s to return 0, got %d\n", ret);
3131 ok(!strcmp(buffer, "nell"),
3132 "Expected output buffer string to be \"nell\", got \"%s\"\n",
3133 buffer);
3134
3135 ret = p_ultoa_s(5704, buffer, sizeof(buffer), 18);
3136 ok(ret == 0, "Expected _ultoa_s to return 0, got %d\n", ret);
3137 ok(!strcmp(buffer, "hag"),
3138 "Expected output buffer string to be \"hag\", got \"%s\"\n",
3139 buffer);
3140}

Referenced by START_TEST().

◆ test__wcslwr_s()

static void test__wcslwr_s ( void  )
static

Definition at line 1426 of file string.c.

1427{
1428 static const WCHAR mixedString[] = L"MiXeDlowerUPPER";
1429 static const WCHAR expectedString[] = L"mixedlowerupper";
1430 WCHAR buffer[2*ARRAY_SIZE(mixedString)];
1431 int ret;
1432
1433 if (!p_wcslwr_s)
1434 {
1435 win_skip("_wcslwr_s not found\n");
1436 return;
1437 }
1438
1439 /* Test NULL input string and invalid size. */
1440 errno = EBADF;
1441 ret = p_wcslwr_s(NULL, 0);
1442 ok(ret == EINVAL, "expected EINVAL, got %d\n", ret);
1443 ok(errno == EINVAL, "expected errno EINVAL, got %d\n", errno);
1444
1445 /* Test NULL input string and valid size. */
1446 errno = EBADF;
1447 ret = p_wcslwr_s(NULL, ARRAY_SIZE(buffer));
1448 ok(ret == EINVAL, "expected EINVAL, got %d\n", ret);
1449 ok(errno == EINVAL, "expected errno EINVAL, got %d\n", errno);
1450
1451 /* Test empty string with zero size. */
1452 errno = EBADF;
1453 buffer[0] = 'a';
1454 ret = p_wcslwr_s(buffer, 0);
1455 ok(ret == EINVAL, "expected EINVAL, got %d\n", ret);
1456 ok(errno == EINVAL, "expected errno EINVAL, got %d\n", errno);
1457 ok(buffer[0] == 0, "expected empty string\n");
1458
1459 /* Test empty string with size of one. */
1460 buffer[0] = 0;
1461 ret = p_wcslwr_s(buffer, 1);
1462 ok(ret == 0, "got %d\n", ret);
1463 ok(buffer[0] == 0, "expected buffer to be unchanged\n");
1464
1465 /* Test one-byte buffer with zero size. */
1466 errno = EBADF;
1467 buffer[0] = 'x';
1468 ret = p_wcslwr_s(buffer, 0);
1469 ok(ret == EINVAL, "expected EINVAL, got %d\n", ret);
1470 ok(errno == EINVAL, "expected errno to be EINVAL, got %d\n", errno);
1471 ok(buffer[0] == '\0', "expected empty string\n");
1472
1473 /* Test one-byte buffer with size of one. */
1474 errno = EBADF;
1475 buffer[0] = 'x';
1476 ret = p_wcslwr_s(buffer, 1);
1477 ok(ret == EINVAL, "expected EINVAL, got %d\n", ret);
1478 ok(errno == EINVAL, "expected errno to be EINVAL, got %d\n", errno);
1479 ok(buffer[0] == '\0', "expected empty string\n");
1480
1481 /* Test invalid size. */
1482 wcscpy(buffer, mixedString);
1483 errno = EBADF;
1484 ret = p_wcslwr_s(buffer, 0);
1485 ok(ret == EINVAL, "Expected EINVAL, got %d\n", ret);
1486 ok(errno == EINVAL, "expected errno to be EINVAL, got %d\n", errno);
1487 ok(buffer[0] == '\0', "expected empty string\n");
1488
1489 /* Test normal string uppercasing. */
1490 wcscpy(buffer, mixedString);
1491 ret = p_wcslwr_s(buffer, ARRAY_SIZE(mixedString));
1492 ok(ret == 0, "expected 0, got %d\n", ret);
1493 ok(!wcscmp(buffer, expectedString), "expected lowercase\n");
1494
1495 /* Test uppercasing with a shorter buffer size count. */
1496 wcscpy(buffer, mixedString);
1497 errno = EBADF;
1498 ret = p_wcslwr_s(buffer, ARRAY_SIZE(mixedString) - 1);
1499 ok(ret == EINVAL, "expected EINVAL, got %d\n", ret);
1500 ok(errno == EINVAL, "expected errno to be EINVAL, got %d\n", errno);
1501 ok(buffer[0] == '\0', "expected empty string\n");
1502
1503 /* Test uppercasing with a longer buffer size count. */
1504 wcscpy(buffer, mixedString);
1505 ret = p_wcslwr_s(buffer, ARRAY_SIZE(buffer));
1506 ok(ret == 0, "expected 0, got %d\n", ret);
1507 ok(!wcscmp(buffer, expectedString), "expected lowercase\n");
1508}
wcscpy
#define L(x)
Definition: resources.c:13
_Check_return_ _CRTIMP int __cdecl wcscmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)

Referenced by START_TEST().

◆ test__wcsnset_s()

static void test__wcsnset_s ( void  )
static

Definition at line 3951 of file string.c.

3952{
3953 wchar_t text[] = L"text";
3954 int r;
3955
3956 if(!p__wcsnset_s) {
3957 win_skip("_wcsnset_s not available\n");
3958 return;
3959 }
3960
3961 r = p__wcsnset_s(NULL, 0, 'a', 0);
3962 ok(r == 0, "r = %d\n", r);
3963
3964 r = p__wcsnset_s(text, 0, 'a', 1);
3965 ok(r == EINVAL, "r = %d\n", r);
3966 ok(text[0] == 't', "text[0] = %d\n", text[0]);
3967
3968 r = p__wcsnset_s(NULL, 2, 'a', 1);
3969 ok(r == EINVAL, "r = %d\n", r);
3970
3971 r = p__wcsnset_s(text, 2, 'a', 3);
3972 ok(r == EINVAL, "r = %d\n", r);
3973 ok(text[0] == 0, "text[0] = %d\n", text[0]);
3974 ok(text[1] == 'e', "text[1] = %d\n", text[1]);
3975
3976 text[0] = 't';
3977 r = p__wcsnset_s(text, 5, 'a', 1);
3978 ok(r == 0, "r = %d\n", r);
3979 ok(text[0] == 'a', "text[0] = %d\n", text[0]);
3980 ok(text[1] == 'e', "text[1] = %d\n", text[1]);
3981
3982 text[1] = 0;
3983 r = p__wcsnset_s(text, 5, 'b', 3);
3984 ok(r == 0, "r = %d\n", r);
3985 ok(text[0] == 'b', "text[0] = %d\n", text[0]);
3986 ok(text[1] == 0, "text[1] = %d\n", text[1]);
3987 ok(text[2] == 'x', "text[2] = %d\n", text[2]);
3988}
const WCHAR * text
Definition: package.c:1794

Referenced by START_TEST().

◆ test__wcsset_s()

static void test__wcsset_s ( void  )
static

Definition at line 3990 of file string.c.

3991{
3992 wchar_t str[10];
3993 int r;
3994
3995 if(!p__wcsset_s) {
3996 win_skip("_wcsset_s not available\n");
3997 return;
3998 }
3999
4000 r = p__wcsset_s(NULL, 0, 'a');
4001 ok(r == EINVAL, "r = %d\n", r);
4002
4003 str[0] = 'a';
4004 r = p__wcsset_s(str, 0, 'a');
4005 ok(r == EINVAL, "r = %d\n", r);
4006 ok(str[0] == 'a', "str[0] = %d\n", str[0]);
4007
4008 str[0] = 'a';
4009 str[1] = 'b';
4010 r = p__wcsset_s(str, 2, 'c');
4011 ok(r == EINVAL, "r = %d\n", r);
4012 ok(!str[0], "str[0] = %d\n", str[0]);
4013 ok(str[1] == 'b', "str[1] = %d\n", str[1]);
4014
4015 str[0] = 'a';
4016 str[1] = 0;
4017 str[2] = 'b';
4018 r = p__wcsset_s(str, 3, 'c');
4019 ok(r == 0, "r = %d\n", r);
4020 ok(str[0] == 'c', "str[0] = %d\n", str[0]);
4021 ok(str[1] == 0, "str[1] = %d\n", str[1]);
4022 ok(str[2] == 'b', "str[2] = %d\n", str[2]);
4023}

Referenced by START_TEST().

◆ test__wcstoi64()

static void test__wcstoi64 ( void  )
static

Definition at line 3620 of file string.c.

3621{
3622 static const struct { WCHAR str[24]; __int64 res; unsigned __int64 ures; int base; } tests[] =
3623 {
3624 { L"9", 9, 9, 10 },
3625 { L" ", 0, 0 },
3626 { L"-1234", -1234, -1234 },
3627 { L"\x09\x0a\x0b\x0c\x0d -123", -123, -123 },
3628 { L"\xa0\x2002\x2003\x2028\x3000 +44", 44, 44 },
3629 { { 0x3231 }, 0, 0 }, /* PARENTHESIZED IDEOGRAPH STOCK */
3630 { { 0x4e00 }, 0, 0 }, /* CJK Ideograph, First */
3631 { { 0x0bef }, 0, 0 }, /* TAMIL DIGIT NINE */
3632 { { 0x0e59 }, 9, 9 }, /* THAI DIGIT NINE */
3633 { { 0xff19 }, 9, 9 }, /* FULLWIDTH DIGIT NINE */
3634 { { 0x00b9 }, 0, 0 }, /* SUPERSCRIPT ONE */
3635 { { '-',0x0e50,'x',0xff19,'1' }, -0x91, -0x91 },
3636 { { '+',0x0e50,0xff17,'1' }, 071, 071 },
3637 { { 0xff19,'f',0x0e59,0xff46 }, 0x9f9, 0x9f9, 16 },
3638 { L"4294967295", 4294967295, 4294967295 },
3639 { L"4294967296", 4294967296, 4294967296 },
3640 { L"9223372036854775807", 9223372036854775807, 9223372036854775807 },
3641 { L"9223372036854775808", _I64_MAX, 9223372036854775808u },
3642 { L"18446744073709551615", _I64_MAX, _UI64_MAX },
3643 { L"18446744073709551616", _I64_MAX, _UI64_MAX },
3644 { L"-4294967295", -4294967295, -4294967295 },
3645 { L"-4294967296", -4294967296, -4294967296 },
3646 { L"-9223372036854775807", -9223372036854775807, -9223372036854775807 },
3647 { L"-9223372036854775808", _I64_MIN, 9223372036854775808u },
3648 { L"-18446744073709551615", _I64_MIN, 1 },
3649 { L"-18446744073709551616", _I64_MIN, 1 },
3650 };
3651 static const WCHAR zeros[] = {
3652 0x660, 0x6f0, 0x966, 0x9e6, 0xa66, 0xae6, 0xb66, 0xc66, 0xce6,
3653 0xd66, 0xe50, 0xed0, 0xf20, 0x1040, 0x17e0, 0x1810, 0xff10
3654 };
3655 int i;
3656
3657 __int64 res;
3658 unsigned __int64 ures;
3659 WCHAR *endpos;
3660
3661 if (!p_wcstoi64 || !p_wcstoui64) {
3662 win_skip("_wcstoi64 or _wcstoui64 not found\n");
3663 return;
3664 }
3665
3666 for (i = 0; i < ARRAY_SIZE(tests); i++)
3667 {
3668#ifdef __REACTOS__
3669 if ((i == 20) && (_winver < 0x600))
3670 {
3671 skip("Skipping test with i = 20, because it fails on Windows 2003\n");
3672 continue;
3673 }
3674#endif // __REACTOS__
3675 res = p_wcstoi64( tests[i].str, &endpos, tests[i].base );
3676 ok( res == tests[i].res, "%u: %s res %s\n",
3678 if (!res) ok( endpos == tests[i].str, "%u: wrong endpos %p/%p\n", i, endpos, tests[i].str );
3679 ures = p_wcstoui64( tests[i].str, &endpos, tests[i].base );
3680 ok( ures == tests[i].ures, "%u: %s res %s\n",
3682 }
3683
3684 /* Test various unicode digits */
3685 for (i = 0; i < ARRAY_SIZE(zeros); ++i) {
3686 WCHAR tmp[] = {zeros[i] + 4, zeros[i], zeros[i] + 5, 0};
3687 res = p_wcstoi64(tmp, NULL, 0);
3688 ok(res == 405, "with zero = U+%04X: got %d, expected 405\n", zeros[i], (int)res);
3689 tmp[1] = zeros[i] + 10;
3690 res = p_wcstoi64(tmp, NULL, 16);
3691 ok(res == 4, "with zero = U+%04X: got %d, expected 4\n", zeros[i], (int)res);
3692 }
3693}
static __inline const char * wine_dbgstr_longlong(ULONGLONG ll)
Definition: compat.h:49
#define wine_dbgstr_w
Definition: kernel32.h:34
unsigned int _winver
Definition: environ.c:14

Referenced by START_TEST().

◆ test__wcstol()

static void test__wcstol ( void  )
static

Definition at line 3695 of file string.c.

3696{
3697 static const struct { WCHAR str[24]; long res; unsigned long ures; int base; } tests[] =
3698 {
3699 { L"9", 9, 9, 10 },
3700 { L" ", 0, 0 },
3701 { L"-1234", -1234, -1234 },
3702 { L"\x09\x0a\x0b\x0c\x0d -123", -123, -123 },
3703 { L"\xa0\x2002\x2003\x2028\x3000 +44", 44, 44 },
3704 { { 0x3231 }, 0, 0 }, /* PARENTHESIZED IDEOGRAPH STOCK */
3705 { { 0x4e00 }, 0, 0 }, /* CJK Ideograph, First */
3706 { { 0x0bef }, 0, 0 }, /* TAMIL DIGIT NINE */
3707 { { 0x0e59 }, 9, 9 }, /* THAI DIGIT NINE */
3708 { { 0xff19 }, 9, 9 }, /* FULLWIDTH DIGIT NINE */
3709 { { 0x00b9 }, 0, 0 }, /* SUPERSCRIPT ONE */
3710 { { '-',0x0e50,'x',0xff19,'1' }, -0x91, -0x91 },
3711 { { '+',0x0e50,0xff17,'1' }, 071, 071 },
3712 { { 0xff19,'f',0x0e59,0xff46 }, 0x9f9, 0x9f9, 16 },
3713 { L"2147483647", 2147483647, 2147483647 },
3714 { L"2147483648", LONG_MAX, 2147483648 },
3715 { L"4294967295", LONG_MAX, 4294967295 },
3716 { L"4294967296", LONG_MAX, ULONG_MAX },
3717 { L"9223372036854775807", LONG_MAX, ULONG_MAX },
3718 { L"-2147483647", -2147483647, -2147483647 },
3719 { L"-2147483648", LONG_MIN, LONG_MIN },
3720 { L"-4294967295", LONG_MIN, 1 },
3721 { L"-4294967296", LONG_MIN, 1 },
3722 { L"-9223372036854775807", LONG_MIN, 1 },
3723 };
3724 static const WCHAR zeros[] = {
3725 0x660, 0x6f0, 0x966, 0x9e6, 0xa66, 0xae6, 0xb66, 0xc66, 0xce6,
3726 0xd66, 0xe50, 0xed0, 0xf20, 0x1040, 0x17e0, 0x1810, 0xff10
3727 };
3728 int i;
3729
3730 long res;
3731 unsigned long ures;
3732 WCHAR *endpos;
3733
3734 for (i = 0; i < ARRAY_SIZE(tests); i++)
3735 {
3736 res = wcstol( tests[i].str, &endpos, tests[i].base );
3737 ok( res == tests[i].res, "%u: %s res %08lx\n",
3738 i, wine_dbgstr_w(tests[i].str), res );
3739 if (!res) ok( endpos == tests[i].str, "%u: wrong endpos %p/%p\n", i, endpos, tests[i].str );
3740 ures = wcstoul( tests[i].str, &endpos, tests[i].base );
3741 ok( ures == tests[i].ures, "%u: %s res %08lx\n",
3742 i, wine_dbgstr_w(tests[i].str), ures );
3743 }
3744
3745 /* Test various unicode digits */
3746 for (i = 0; i < ARRAY_SIZE(zeros); ++i) {
3747 WCHAR tmp[] = {zeros[i] + 4, zeros[i], zeros[i] + 5, 0};
3748 res = wcstol(tmp, NULL, 0);
3749 ok(res == 405, "with zero = U+%04X: got %d, expected 405\n", zeros[i], (int)res);
3750 tmp[1] = zeros[i] + 10;
3751 res = wcstol(tmp, NULL, 16);
3752 ok(res == 4, "with zero = U+%04X: got %d, expected 4\n", zeros[i], (int)res);
3753 }
3754}
#define ULONG_MAX
Definition: intsafe.h:155
#define LONG_MAX
Definition: intsafe.h:154
#define LONG_MIN
Definition: intsafe.h:125
_Check_return_ long __cdecl wcstol(_In_z_ const wchar_t *_Str, _Out_opt_ _Deref_post_z_ wchar_t **_EndPtr, _In_ int _Radix)
_Check_return_ unsigned long __cdecl wcstoul(_In_z_ const wchar_t *_Str, _Out_opt_ _Deref_post_z_ wchar_t **_EndPtr, _In_ int _Radix)

Referenced by START_TEST().

◆ test__wcstombs_s_l()

static void test__wcstombs_s_l ( void  )
static

Definition at line 2437 of file string.c.

2438{
2439 struct test {
2440 const wchar_t *wstr;
2441 size_t wlen;
2442 const char *str;
2443 size_t len;
2444 size_t ret;
2445 int err;
2446 const char *locale;
2447 } tests[] = {
2448 /* wstr str ret err locale */
2449 { L"", 0, NULL, 0, 1, 0, NULL },
2450 { L"\xfffd", 1, NULL, 0, 2, 0, NULL },
2451 { L"\xfffd", 1, "", 1, 0, EILSEQ, NULL },
2452 { L"\xfffd", 1, "", 6, 0, EILSEQ, NULL },
2453 { L"text", _TRUNCATE, "text", 5, 5, 0, NULL },
2454 { L"text", _TRUNCATE, "", 1, 1, STRUNCATE, NULL },
2455 { L"text", 5, "", 3, 0, ERANGE, NULL },
2456
2457 { L"", 0, NULL, 0, 1, 0, "English_United States.1252" },
2458 { L"\xfffd", 1, NULL, 0, 0, EILSEQ, "English_United States.1252" },
2459 { L"\xfffd", 1, "", 1, 0, EILSEQ, "English_United States.1252" },
2460 { L"\xfffd", 1, "", 6, 0, EILSEQ, "English_United States.1252" },
2461 { L"text", _TRUNCATE, "text", 5, 5, 0, "English_United States.1252" },
2462 { L"text", _TRUNCATE, "", 1, 1, STRUNCATE, "English_United States.1252" },
2463 { L"text", 5, "", 3, 0, ERANGE, "English_United States.1252" },
2464 };
2466 char out[6];
2467 size_t ret;
2468 int err;
2469 int i;
2470
2471 if(!p__create_locale) {
2472 win_skip("_create_locale not available\n");
2473 return;
2474 }
2475
2476 for (i = 0; i < ARRAY_SIZE(tests); i++)
2477 {
2478 if(tests[i].locale)
2479 {
2480 locale = p__create_locale(LC_ALL, tests[i].locale);
2481 ok(locale != NULL, "_create_locale failed for %s\n", tests[i].locale);
2482 }
2483 else
2484 locale = NULL;
2485
2486 ret = ~0;
2487 memset(out, 0xcc, sizeof(out));
2488 err = p_wcstombs_s_l(&ret, tests[i].str ? out : NULL, tests[i].len,
2489 tests[i].wstr, tests[i].wlen, locale);
2490 ok(ret == tests[i].ret, "%d: expected ret %Id, got %Id for '%s' in locale %s\n", i, tests[i].ret, ret,
2491 wine_dbgstr_w(tests[i].wstr), tests[i].locale);
2492 ok(err == tests[i].err, "%d: expected err %d, got %d for '%s' in locale %s\n", i, tests[i].err, err,
2493 wine_dbgstr_w(tests[i].wstr), tests[i].locale);
2494 if(tests[i].str)
2495 ok(!memcmp(out, tests[i].str, strlen(tests[i].str)+1),
2496 "%d: expected out %s, got %s for '%s' in locale %s\n", i, tests[i].str, out,
2497 wine_dbgstr_w(tests[i].wstr), tests[i].locale);
2498
2499 p__free_locale(locale);
2500 }
2501}
#define STRUNCATE
Definition: errno.h:110
#define _TRUNCATE
Definition: corecrt.h:278
wchar_t tm const _CrtWcstime_Writes_and_advances_ptr_ count wchar_t ** out
Definition: wcsftime.cpp:383

Referenced by START_TEST().

◆ test__wcsupr_s()

static void test__wcsupr_s ( void  )
static

Definition at line 1342 of file string.c.

1343{
1344 static const WCHAR mixedString[] = L"MiXeDlowerUPPER";
1345 static const WCHAR expectedString[] = L"MIXEDLOWERUPPER";
1346 WCHAR testBuffer[2*ARRAY_SIZE(mixedString)];
1347 int ret;
1348
1349 if (!p_wcsupr_s)
1350 {
1351 win_skip("_wcsupr_s not found\n");
1352 return;
1353 }
1354
1355 /* Test NULL input string and invalid size. */
1356 errno = EBADF;
1357 ret = p_wcsupr_s(NULL, 0);
1358 ok(ret == EINVAL, "Expected _wcsupr_s to fail with EINVAL, got %d\n", ret);
1359 ok(errno == EINVAL, "Expected errno to be EINVAL, got %d\n", errno);
1360
1361 /* Test NULL input string and valid size. */
1362 errno = EBADF;
1363 ret = p_wcsupr_s(NULL, ARRAY_SIZE(testBuffer));
1364 ok(ret == EINVAL, "Expected _wcsupr_s to fail with EINVAL, got %d\n", ret);
1365 ok(errno == EINVAL, "Expected errno to be EINVAL, got %d\n", errno);
1366
1367 /* Test empty string with zero size. */
1368 errno = EBADF;
1369 testBuffer[0] = '\0';
1370 ret = p_wcsupr_s(testBuffer, 0);
1371 ok(ret == EINVAL, "Expected _wcsupr_s to fail with EINVAL, got %d\n", ret);
1372 ok(errno == EINVAL, "Expected errno to be EINVAL, got %d\n", errno);
1373 ok(testBuffer[0] == '\0', "Expected the buffer to be unchanged\n");
1374
1375 /* Test empty string with size of one. */
1376 testBuffer[0] = '\0';
1377 ret = p_wcsupr_s(testBuffer, 1);
1378 ok(ret == 0, "Expected _wcsupr_s to succeed, got %d\n", ret);
1379 ok(testBuffer[0] == '\0', "Expected the buffer to be unchanged\n");
1380
1381 /* Test one-byte buffer with zero size. */
1382 errno = EBADF;
1383 testBuffer[0] = 'x';
1384 ret = p_wcsupr_s(testBuffer, 0);
1385 ok(ret == EINVAL, "Expected _wcsupr_s to fail with EINVAL, got %d\n", ret);
1386 ok(errno == EINVAL, "Expected errno to be EINVAL, got %d\n", errno);
1387 ok(testBuffer[0] == '\0', "Expected the first buffer character to be null\n");
1388
1389 /* Test one-byte buffer with size of one. */
1390 errno = EBADF;
1391 testBuffer[0] = 'x';
1392 ret = p_wcsupr_s(testBuffer, 1);
1393 ok(ret == EINVAL, "Expected _wcsupr_s to fail with EINVAL, got %d\n", ret);
1394 ok(errno == EINVAL, "Expected errno to be EINVAL, got %d\n", errno);
1395 ok(testBuffer[0] == '\0', "Expected the first buffer character to be null\n");
1396
1397 /* Test invalid size. */
1398 wcscpy(testBuffer, mixedString);
1399 errno = EBADF;
1400 ret = p_wcsupr_s(testBuffer, 0);
1401 ok(ret == EINVAL, "Expected _wcsupr_s to fail with EINVAL, got %d\n", ret);
1402 ok(errno == EINVAL, "Expected errno to be EINVAL, got %d\n", errno);
1403 ok(testBuffer[0] == '\0', "Expected the first buffer character to be null\n");
1404
1405 /* Test normal string uppercasing. */
1406 wcscpy(testBuffer, mixedString);
1407 ret = p_wcsupr_s(testBuffer, ARRAY_SIZE(mixedString));
1408 ok(ret == 0, "Expected _wcsupr_s to succeed, got %d\n", ret);
1409 ok(!wcscmp(testBuffer, expectedString), "Expected the string to be fully upper-case\n");
1410
1411 /* Test uppercasing with a shorter buffer size count. */
1412 wcscpy(testBuffer, mixedString);
1413 errno = EBADF;
1414 ret = p_wcsupr_s(testBuffer, ARRAY_SIZE(mixedString) - 1);
1415 ok(ret == EINVAL, "Expected _wcsupr_s to fail with EINVAL, got %d\n", ret);
1416 ok(errno == EINVAL, "Expected errno to be EINVAL, got %d\n", errno);
1417 ok(testBuffer[0] == '\0', "Expected the first buffer character to be null\n");
1418
1419 /* Test uppercasing with a longer buffer size count. */
1420 wcscpy(testBuffer, mixedString);
1421 ret = p_wcsupr_s(testBuffer, ARRAY_SIZE(testBuffer));
1422 ok(ret == 0, "Expected _wcsupr_s to succeed, got %d\n", ret);
1423 ok(!wcscmp(testBuffer, expectedString), "Expected the string to be fully upper-case\n");
1424}

Referenced by START_TEST().

◆ test_atof()

static void test_atof ( void  )
static

Definition at line 3790 of file string.c.

3791{
3792 double d;
3793
3794 d = atof("0.0");
3795 ok(d == 0.0, "d = %lf\n", d);
3796
3797 d = atof("1.0");
3798 ok(d == 1.0, "d = %lf\n", d);
3799
3800 d = atof("-1.0");
3801 ok(d == -1.0, "d = %lf\n", d);
3802
3803 if (!p__atof_l)
3804 {
3805 win_skip("_atof_l not found\n");
3806 return;
3807 }
3808
3809 errno = EBADF;
3810 d = atof(NULL);
3811 ok(d == 0.0, "d = %lf\n", d);
3812 ok(errno == EINVAL, "errno = %x\n", errno);
3813
3814 errno = EBADF;
3815 d = p__atof_l(NULL, NULL);
3816 ok(d == 0.0, "d = %lf\n", d);
3817 ok(errno == EINVAL, "errno = %x\n", errno);
3818}
double atof()

Referenced by START_TEST().

◆ test_atoi()

static void test_atoi ( void  )
static

Definition at line 3756 of file string.c.

3757{
3758 int r;
3759
3760 r = atoi("0");
3761 ok(r == 0, "atoi(0) = %d\n", r);
3762
3763 r = atoi("-1");
3764 ok(r == -1, "atoi(-1) = %d\n", r);
3765
3766 r = atoi("1");
3767 ok(r == 1, "atoi(1) = %d\n", r);
3768
3769 r = atoi("4294967296");
3770 ok(r == 0, "atoi(4294967296) = %d\n", r);
3771}
_Check_return_ int __cdecl atoi(_In_z_ const char *_Str)

Referenced by START_TEST().

◆ test_atol()

static void test_atol ( void  )
static

Definition at line 3773 of file string.c.

3774{
3775 int r;
3776
3777 r = atol("0");
3778 ok(r == 0, "atol(0) = %d\n", r);
3779
3780 r = atol("-1");
3781 ok(r == -1, "atol(-1) = %d\n", r);
3782
3783 r = atol("1");
3784 ok(r == 1, "atol(1) = %d\n", r);
3785
3786 r = atol("4294967296");
3787 ok(r == 0, "atol(4294967296) = %d\n", r);
3788}
_Check_return_ long __cdecl atol(_In_z_ const char *_Str)

Referenced by START_TEST().

◆ test_btowc()

static void test_btowc ( void  )
static

Definition at line 3180 of file string.c.

3181{
3182 wint_t ret;
3183 int cp = _getmbcp();
3184
3185 if(!p_btowc || !setlocale(LC_ALL, "chinese-traditional")) {
3186 win_skip("Skipping btowc tests\n");
3187 return;
3188 }
3189
3190 ret = p_btowc(EOF);
3191 ok(ret == WEOF, "ret = %x\n", ret);
3192
3193 ret = p_btowc(0x61);
3194 ok(ret == 0x61, "ret = %x\n", ret);
3195
3196 ret = p_btowc(0x81);
3197 ok(ret == WEOF, "ret = %x\n", ret);
3198
3199 ret = p_btowc(0xe0);
3200 ok(ret == WEOF, "ret = %x\n", ret);
3201
3202 _setmbcp(1250);
3203 ret = p_btowc(0x61);
3204 ok(ret == 0x61, "ret = %x\n", ret);
3205
3206 ret = p_btowc(0x81);
3207 ok(ret == WEOF, "ret = %x\n", ret);
3208
3209 ret = p_btowc(0xe0);
3210 ok(ret == WEOF, "ret = %x\n", ret);
3211
3212 if(!setlocale(LC_CTYPE, ".1250")) {
3213 win_skip("No codepage 1250 support\n");
3214 setlocale(LC_ALL, "C");
3215 _setmbcp(cp);
3216 return;
3217 }
3218
3219 ret = p_btowc(0x61);
3220 ok(ret == 0x61, "ret = %x\n", ret);
3221
3222 ret = p_btowc(0x81);
3223 ok(ret == 0x81, "ret = %x\n", ret);
3224
3225 ret = p_btowc(0xe0);
3226 ok(ret == 0x155, "ret = %x\n", ret);
3227
3228 ret = p_btowc(0x100);
3229 ok(ret == 0x00, "ret = %x\n", ret);
3230
3231 ret = p_btowc(0x1e0);
3232 ok(ret == 0x155, "ret = %x\n", ret);
3233
3234 setlocale(LC_ALL, "C");
3235 ret = p_btowc(0x61);
3236 ok(ret == 0x61, "ret = %x\n", ret);
3237
3238 ret = p_btowc(0x81);
3239 ok(ret == 0x81, "ret = %x\n", ret);
3240
3241 ret = p_btowc(0x9f);
3242 ok(ret == 0x9f, "ret = %x\n", ret);
3243
3244 ret = p_btowc(0xe0);
3245 ok(ret == 0xe0, "ret = %x\n", ret);
3246
3247 ret = p_btowc(0x100);
3248 ok(ret == 0x00, "ret = %x\n", ret);
3249
3250 ret = p_btowc(0x1e0);
3251 ok(ret == 0xe0, "ret = %x\n", ret);
3252
3253 _setmbcp(cp);
3254}
int wint_t
Definition: _apple.h:38
#define LC_CTYPE
Definition: locale.h:19
#define EOF
Definition: stdio.h:24
#define WEOF
Definition: conio.h:185

Referenced by START_TEST().

◆ test_C_locale()

static void test_C_locale ( void  )
static

Definition at line 4541 of file string.c.

4542{
4543 int i, j;
4544 wint_t ret, exp;
4546 static const char *locales[] = { NULL, "C" };
4547
4548 /* C locale only converts case for [a-zA-Z] */
4549 setlocale(LC_ALL, "C");
4550 for (i = 0; i <= 0xffff; i++)
4551 {
4552 ret = p_towlower(i);
4553 if (i >= 'A' && i <= 'Z')
4554 {
4555 exp = i + 'a' - 'A';
4556 ok(ret == exp, "expected %x, got %x for C locale\n", exp, ret);
4557 }
4558 else
4559 ok(ret == i, "expected self %x, got %x for C locale\n", i, ret);
4560
4561 ret = p_towupper(i);
4562 if (i >= 'a' && i <= 'z')
4563 {
4564 exp = i + 'A' - 'a';
4565 ok(ret == exp, "expected %x, got %x for C locale\n", exp, ret);
4566 }
4567 else
4568 ok(ret == i, "expected self %x, got %x for C locale\n", i, ret);
4569 }
4570
4571 if (!p__towlower_l || !p__towupper_l || !p__create_locale)
4572 {
4573 win_skip("_towlower_l/_towupper_l/_create_locale not available\n");
4574 return;
4575 }
4576
4577 for (i = 0; i < ARRAY_SIZE(locales); i++) {
4578 locale = locales[i] ? p__create_locale(LC_ALL, locales[i]) : NULL;
4579
4580 for (j = 0; j <= 0xffff; j++) {
4581 ret = p__towlower_l(j, locale);
4582 if (j >= 'A' && j <= 'Z')
4583 {
4584 exp = j + 'a' - 'A';
4585 ok(ret == exp, "expected %x, got %x for C locale\n", exp, ret);
4586 }
4587 else
4588 ok(ret == j, "expected self %x, got %x for C locale\n", j, ret);
4589
4590 ret = p__towupper_l(j, locale);
4591 if (j >= 'a' && j <= 'z')
4592 {
4593 exp = j + 'A' - 'a';
4594 ok(ret == exp, "expected %x, got %x for C locale\n", exp, ret);
4595 }
4596 else
4597 ok(ret == j, "expected self %x, got %x for C locale\n", j, ret);
4598 }
4599
4600 p__free_locale(locale);
4601 }
4602}

Referenced by START_TEST().

◆ test_cp_table()

static void test_cp_table ( int  cp,
int result 
)
static

Definition at line 241 of file string.c.

242{
243 int i;
244 int count = 0;
245 int curr = 0;
246 _setmbcp(cp);
247 for (i = 0; i < 256; i++)
248 {
249 if (count == 0)
250 {
251 curr = result[0];
252 count = result[1];
253 result += 2;
254 }
255 ok(p_mbctype[i] == curr, "CP%d: Mismatch in ctype for character %d - %d instead of %d\n", cp, i-1, p_mbctype[i], curr);
256 count--;
257 }
258}
GLuint64EXT * result
Definition: glext.h:11304

◆ test_gcvt()

static void test_gcvt ( void  )
static

Definition at line 2503 of file string.c.

2504{
2505 char buf[1024], *res;
2506 errno_t err;
2507
2508 if(!p_gcvt_s) {
2509 win_skip("Skipping _gcvt tests\n");
2510 return;
2511 }
2512
2513 errno = 0;
2514 res = _gcvt(1.2, -1, buf);
2515 ok(res == NULL, "res != NULL\n");
2516 ok(errno == ERANGE, "errno = %d\n", errno);
2517
2518 errno = 0;
2519 res = _gcvt(1.2, 5, NULL);
2520 ok(res == NULL, "res != NULL\n");
2521 ok(errno == EINVAL, "errno = %d\n", errno);
2522
2523 res = gcvt(1.2, 5, buf);
2524 ok(res == buf, "res != buf\n");
2525 ok(!strcmp(buf, "1.2"), "buf = %s\n", buf);
2526
2527 buf[0] = 'x';
2528 err = p_gcvt_s(buf, 5, 1.2, 10);
2529 ok(err == ERANGE, "err = %d\n", err);
2530 ok(buf[0] == '\0', "buf[0] = %c\n", buf[0]);
2531
2532 buf[0] = 'x';
2533 err = p_gcvt_s(buf, 4, 123456, 2);
2534 ok(err == ERANGE, "err = %d\n", err);
2535 ok(buf[0] == '\0', "buf[0] = %c\n", buf[0]);
2536}
_CRTIMP char *__cdecl gcvt(_In_ double _Val, _In_ int _NumOfDigits, _Pre_notnull_ _Post_z_ char *_DstBuf)
_CRTIMP char *__cdecl _gcvt(_In_ double _Val, _In_ int _NumOfDigits, _Pre_notnull_ _Post_z_ char *_DstBuf)

Referenced by START_TEST().

◆ test_ismbckata()

static void test_ismbckata ( void  )
static

Definition at line 1671 of file string.c.

1671 {
1672 struct katakana_pair {
1673 UINT c;
1674 BOOL exp;
1675 };
1676 static const struct katakana_pair tests[] = {
1677 {0x8152, FALSE}, {0x8153, FALSE}, {0x8154, FALSE}, {0x8155, FALSE},
1678 {0x82a0, FALSE}, {0x833f, FALSE}, {0x8340, TRUE }, {0x837e, TRUE },
1679 {0x837f, FALSE}, {0x8380, TRUE }, {0x8396, TRUE }, {0x8397, FALSE},
1680 {0xa5, FALSE}, {0xb0, FALSE}, {0xdd, FALSE}
1681 };
1682 unsigned int prev_cp = _getmbcp();
1683 int ret;
1684 unsigned int i;
1685
1687 for (i = 0; i < ARRAY_SIZE(tests); i++) {
1688 ret = _ismbckata(tests[i].c);
1689 ok(!ret, "expected 0, got %d for %04x\n", ret, tests[i].c);
1690 }
1691
1692 _setmbcp(932);
1693 for (i = 0; i < ARRAY_SIZE(tests); i++) {
1694 ret = _ismbckata(tests[i].c);
1695 ok(!!ret == tests[i].exp, "expected %d, got %d for %04x\n",
1696 tests[i].exp, !!ret, tests[i].c);
1697 }
1698
1699 _setmbcp(prev_cp);
1700}
#define FALSE
Definition: types.h:117
_Check_return_ _CRTIMP int __cdecl _ismbckata(_In_ unsigned int _Ch)
#define _MB_CP_SBCS
Definition: msvcrt.h:828
unsigned int UINT
Definition: ndis.h:50

Referenced by START_TEST().

◆ test_ismbclegal()

static void test_ismbclegal ( void  )
static

Definition at line 1702 of file string.c.

1702 {
1703 unsigned int prev_cp = _getmbcp();
1704 int ret, exp, err;
1705 unsigned int i;
1706
1707 _setmbcp(932); /* Japanese */
1708 err = 0;
1709 for(i = 0; i < 0x10000; i++) {
1710 ret = _ismbclegal(i);
1711 exp = ((HIBYTE(i) >= 0x81 && HIBYTE(i) <= 0x9F) ||
1712 (HIBYTE(i) >= 0xE0 && HIBYTE(i) <= 0xFC)) &&
1713 ((LOBYTE(i) >= 0x40 && LOBYTE(i) <= 0x7E) ||
1714 (LOBYTE(i) >= 0x80 && LOBYTE(i) <= 0xFC));
1715 if(ret != exp) {
1716 err = 1;
1717 break;
1718 }
1719 }
1720 ok(!err, "_ismbclegal (932) : Expected 0x%x, got 0x%x (0x%x)\n", exp, ret, i);
1721 _setmbcp(936); /* Chinese (GBK) */
1722 err = 0;
1723 for(i = 0; i < 0x10000; i++) {
1724 ret = _ismbclegal(i);
1725 exp = HIBYTE(i) >= 0x81 && HIBYTE(i) <= 0xFE &&
1726 LOBYTE(i) >= 0x40 && LOBYTE(i) <= 0xFE;
1727 if(ret != exp) {
1728 err = 1;
1729 break;
1730 }
1731 }
1732 ok(!err, "_ismbclegal (936) : Expected 0x%x, got 0x%x (0x%x)\n", exp, ret, i);
1733 _setmbcp(949); /* Korean */
1734 err = 0;
1735 for(i = 0; i < 0x10000; i++) {
1736 ret = _ismbclegal(i);
1737 exp = HIBYTE(i) >= 0x81 && HIBYTE(i) <= 0xFE &&
1738 LOBYTE(i) >= 0x41 && LOBYTE(i) <= 0xFE;
1739 if(ret != exp) {
1740 err = 1;
1741 break;
1742 }
1743 }
1744 ok(!err, "_ismbclegal (949) : Expected 0x%x, got 0x%x (0x%x)\n", exp, ret, i);
1745 _setmbcp(950); /* Chinese (Big5) */
1746 err = 0;
1747 for(i = 0; i < 0x10000; i++) {
1748 ret = _ismbclegal(i);
1749 exp = HIBYTE(i) >= 0x81 && HIBYTE(i) <= 0xFE &&
1750 ((LOBYTE(i) >= 0x40 && LOBYTE(i) <= 0x7E) ||
1751 (LOBYTE(i) >= 0xA1 && LOBYTE(i) <= 0xFE));
1752 if(ret != exp) {
1753 err = 1;
1754 break;
1755 }
1756 }
1757 ok(!err, "_ismbclegal (950) : Expected 0x%x, got 0x%x (0x%x)\n", exp, ret, i);
1758 _setmbcp(1361); /* Korean (Johab) */
1759 err = 0;
1760 for(i = 0; i < 0x10000; i++) {
1761 ret = _ismbclegal(i);
1762 exp = ((HIBYTE(i) >= 0x81 && HIBYTE(i) <= 0xD3) ||
1763 (HIBYTE(i) >= 0xD8 && HIBYTE(i) <= 0xF9)) &&
1764 ((LOBYTE(i) >= 0x31 && LOBYTE(i) <= 0x7E) ||
1765 (LOBYTE(i) >= 0x81 && LOBYTE(i) <= 0xFE)) &&
1766 HIBYTE(i) != 0xDF;
1767 if(ret != exp) {
1768 err = 1;
1769 break;
1770 }
1771 }
1772 todo_wine ok(!err, "_ismbclegal (1361) : Expected 0x%x, got 0x%x (0x%x)\n", exp, ret, i);
1773
1774 _setmbcp(prev_cp);
1775}
_Check_return_ _CRTIMP int __cdecl _ismbclegal(_In_ unsigned int _Ch)
#define LOBYTE(W)
Definition: jmemdos.c:487
#define HIBYTE(W)
Definition: jmemdos.c:486
#define todo_wine
Definition: custom.c:89

Referenced by START_TEST().

◆ test_iswdigit()

static void test_iswdigit ( void  )
static

Definition at line 4637 of file string.c.

4638{
4639 static const struct {
4640 WCHAR c;
4641 int r;
4642 } tests[] = {
4643 { '0', C1_DIGIT },
4644 { '9', C1_DIGIT },
4645 { 'a', 0 },
4646 { 0xff16, C1_DIGIT },
4647 { 0x0660, C1_DIGIT },
4648 { 0x0ce6, C1_DIGIT }
4649 };
4650 int i, r;
4651
4652 for (i = 0; i < ARRAY_SIZE(tests); i++)
4653 {
4654 r = iswdigit(tests[i].c);
4655 ok(r == tests[i].r, "iswdigit returned %x for %x\n", r, tests[i].c);
4656 }
4657}
#define C1_DIGIT
Definition: unicode.h:33
#define iswdigit(_c)
Definition: ctype.h:667

Referenced by START_TEST().

◆ test_mbbtombc()

static void test_mbbtombc ( void  )
static

Definition at line 1623 of file string.c.

1624{
1625 static const unsigned int mbbmbc[][2] = {
1626 {0x1f, 0x1f}, {0x20, 0x8140}, {0x39, 0x8258}, {0x40, 0x8197},
1627 {0x41, 0x8260}, {0x5e, 0x814f}, {0x7e, 0x8150}, {0x7f, 0x7f},
1628 {0x80, 0x80}, {0x81, 0x81}, {0xa0, 0xa0}, {0xa7, 0x8340},
1629 {0xb0, 0x815b}, {0xd1, 0x8380}, {0xff, 0xff}, {0,0}};
1630 int cp[] = { 932, 936, 939, 950, 1361, _MB_CP_SBCS };
1631 int i, j;
1632 int prev_cp = _getmbcp();
1633
1634 for (i = 0; i < ARRAY_SIZE(cp); i++)
1635 {
1636 _setmbcp(cp[i]);
1637 for (j = 0; mbbmbc[j][0] != 0; j++)
1638 {
1639 unsigned int exp, ret;
1640 ret = _mbbtombc(mbbmbc[j][0]);
1641 exp = (cp[i] == 932) ? mbbmbc[j][1] : mbbmbc[j][0];
1642 ok(ret == exp, "Expected 0x%x, got 0x%x (0x%x, codepage %d)\n",
1643 exp, ret, mbbmbc[j][0], cp[i]);
1644 }
1645 }
1646 _setmbcp(prev_cp);
1647}
_Check_return_ _CRTIMP unsigned int __cdecl _mbbtombc(_In_ unsigned int _Ch)

Referenced by START_TEST().

◆ test_mbcjisjms()

static void test_mbcjisjms ( void  )
static

Definition at line 1510 of file string.c.

1511{
1512 /* List of value-pairs to test. The test assumes the last pair to be {0, ..} */
1513 unsigned int jisjms[][2] = { {0x2020, 0}, {0x2021, 0}, {0x2120, 0}, {0x2121, 0x8140},
1514 {0x7f7f, 0}, {0x7f7e, 0}, {0x7e7f, 0}, {0x7e7e, 0xeffc},
1515 {0x255f, 0x837e}, {0x2560, 0x8380}, {0x2561, 0x8381},
1516 {0x2121FFFF, 0}, {0x2223, 0x81a1}, {0x237e, 0x829e}, {0, 0}};
1517 int cp[] = { 932, 936, 939, 950, 1361, _MB_CP_SBCS };
1518 unsigned int i, j;
1519 int prev_cp = _getmbcp();
1520
1521 for (i = 0; i < ARRAY_SIZE(cp); i++)
1522 {
1523 _setmbcp(cp[i]);
1524 for (j = 0; jisjms[j][0] != 0; j++)
1525 {
1526 unsigned int ret, exp;
1527 ret = _mbcjistojms(jisjms[j][0]);
1528 exp = (cp[i] == 932) ? jisjms[j][1] : jisjms[j][0];
1529 ok(ret == exp, "Expected 0x%x, got 0x%x (0x%x, codepage=%d)\n",
1530 exp, ret, jisjms[j][0], cp[i]);
1531 }
1532 }
1533 _setmbcp(prev_cp);
1534}
_Check_return_ _CRTIMP unsigned int __cdecl _mbcjistojms(_In_ unsigned int _Ch)

Referenced by START_TEST().

◆ test_mbcjmsjis()

static void test_mbcjmsjis ( void  )
static

Definition at line 1536 of file string.c.

1537{
1538 /* List of value-pairs to test. The test assumes the last pair to be {0, ..} */
1539 unsigned int jmsjis[][2] = { {0x80fc, 0}, {0x813f, 0}, {0x8140, 0x2121},
1540 {0x817e, 0x215f}, {0x817f, 0}, {0x8180, 0x2160},
1541 {0x819e, 0x217e}, {0x819f, 0x2221}, {0x81fc, 0x227e},
1542 {0x81fd, 0}, {0x9ffc, 0x5e7e}, {0x9ffd, 0},
1543 {0xa040, 0}, {0xdffc, 0}, {0xe040, 0x5f21},
1544 {0xeffc, 0x7e7e}, {0xf040, 0}, {0x21, 0}, {0, 0}};
1545 int cp[] = { 932, 936, 939, 950, 1361, _MB_CP_SBCS };
1546 unsigned int i, j;
1547 int prev_cp = _getmbcp();
1548
1549 for (i = 0; i < ARRAY_SIZE(cp); i++)
1550 {
1551 _setmbcp(cp[i]);
1552 for (j = 0; jmsjis[j][0] != 0; j++)
1553 {
1554 unsigned int ret, exp;
1555 ret = _mbcjmstojis(jmsjis[j][0]);
1556 exp = (cp[i] == 932) ? jmsjis[j][1] : jmsjis[j][0];
1557 ok(ret == exp, "Expected 0x%x, got 0x%x (0x%x, codepage=%d)\n",
1558 exp, ret, jmsjis[j][0], cp[i]);
1559 }
1560 }
1561 _setmbcp(prev_cp);
1562}
_Check_return_ _CRTIMP unsigned int __cdecl _mbcjmstojis(_In_ unsigned int _Ch)

Referenced by START_TEST().

◆ test_mbcp()

static void test_mbcp ( void  )
static

Definition at line 264 of file string.c.

265{
266 int mb_orig_max = *p__mb_cur_max;
267 int curr_mbcp = _getmbcp();
268 unsigned char *mbstring = (unsigned char *)"\xb0\xb1\xb2 \xb3\xb4 \xb5"; /* incorrect string */
269 unsigned char *mbstring2 = (unsigned char *)"\xb0\xb1\xb2\xb3Q\xb4\xb5"; /* correct string */
270 unsigned char *mbsonlylead = (unsigned char *)"\xb0\0\xb1\xb2 \xb3";
271 unsigned char buf[16];
272 unsigned char *ret;
273 int step;
275
276 /* _mbtype tests */
277
278 /* An SBCS codepage test. The ctype of characters on e.g. CP1252 or CP1250 differs slightly
279 * between versions of Windows. Also Windows 9x seems to ignore the codepage and always uses
280 * CP1252 (or the ACP?) so we test only a few ASCII characters */
281 _setmbcp(1252);
282 expect_eq(p_mbctype[10], 0, char, "%x");
283 expect_eq(p_mbctype[50], 0, char, "%x");
284 expect_eq(p_mbctype[66], _SBUP, char, "%x");
285 expect_eq(p_mbctype[100], _SBLOW, char, "%x");
286 expect_eq(p_mbctype[128], 0, char, "%x");
287 _setmbcp(1250);
288 expect_eq(p_mbctype[10], 0, char, "%x");
289 expect_eq(p_mbctype[50], 0, char, "%x");
290 expect_eq(p_mbctype[66], _SBUP, char, "%x");
291 expect_eq(p_mbctype[100], _SBLOW, char, "%x");
292 expect_eq(p_mbctype[128], 0, char, "%x");
293
294 /* double byte code pages */
295 test_codepage(932);
296 test_codepage(936);
297 test_codepage(949);
298 test_codepage(950);
299
300 _setmbcp(936);
301 ok(*p__mb_cur_max == mb_orig_max, "__mb_cur_max shouldn't be updated (is %d != %d)\n", *p__mb_cur_max, mb_orig_max);
302 ok(_ismbblead('\354'), "\354 should be a lead byte\n");
303 ok(_ismbblead(' ') == FALSE, "' ' should not be a lead byte\n");
304 ok(_ismbblead(0x1234b0), "0x1234b0 should not be a lead byte\n");
305 ok(_ismbblead(0x123420) == FALSE, "0x123420 should not be a lead byte\n");
306 ok(_ismbbtrail('\xb0'), "\xa0 should be a trail byte\n");
307 ok(_ismbbtrail(' ') == FALSE, "' ' should not be a trail byte\n");
308
309 /* _ismbslead */
310 expect_eq(_ismbslead(mbstring, &mbstring[0]), -1, int, "%d");
311 expect_eq(_ismbslead(mbstring, &mbstring[1]), FALSE, int, "%d");
312 expect_eq(_ismbslead(mbstring, &mbstring[2]), -1, int, "%d");
313 expect_eq(_ismbslead(mbstring, &mbstring[3]), FALSE, int, "%d");
314 expect_eq(_ismbslead(mbstring, &mbstring[4]), -1, int, "%d");
315 expect_eq(_ismbslead(mbstring, &mbstring[5]), FALSE, int, "%d");
316 expect_eq(_ismbslead(mbstring, &mbstring[6]), FALSE, int, "%d");
317 expect_eq(_ismbslead(mbstring, &mbstring[7]), -1, int, "%d");
318 expect_eq(_ismbslead(mbstring, &mbstring[8]), FALSE, int, "%d");
319
320 expect_eq(_ismbslead(mbsonlylead, &mbsonlylead[0]), -1, int, "%d");
321 expect_eq(_ismbslead(mbsonlylead, &mbsonlylead[1]), FALSE, int, "%d");
322 expect_eq(_ismbslead(mbsonlylead, &mbsonlylead[2]), FALSE, int, "%d");
323 expect_eq(_ismbslead(mbsonlylead, &mbsonlylead[5]), FALSE, int, "%d");
324
325 /* _ismbstrail */
326 expect_eq(_ismbstrail(mbstring, &mbstring[0]), FALSE, int, "%d");
327 expect_eq(_ismbstrail(mbstring, &mbstring[1]), -1, int, "%d");
328 expect_eq(_ismbstrail(mbstring, &mbstring[2]), FALSE, int, "%d");
329 expect_eq(_ismbstrail(mbstring, &mbstring[3]), -1, int, "%d");
330 expect_eq(_ismbstrail(mbstring, &mbstring[4]), FALSE, int, "%d");
331 expect_eq(_ismbstrail(mbstring, &mbstring[5]), -1, int, "%d");
332 expect_eq(_ismbstrail(mbstring, &mbstring[6]), FALSE, int, "%d");
333 expect_eq(_ismbstrail(mbstring, &mbstring[7]), FALSE, int, "%d");
334 expect_eq(_ismbstrail(mbstring, &mbstring[8]), -1, int, "%d");
335
336 expect_eq(_ismbstrail(mbsonlylead, &mbsonlylead[0]), FALSE, int, "%d");
337 expect_eq(_ismbstrail(mbsonlylead, &mbsonlylead[1]), -1, int, "%d");
338 expect_eq(_ismbstrail(mbsonlylead, &mbsonlylead[2]), FALSE, int, "%d");
339 expect_eq(_ismbstrail(mbsonlylead, &mbsonlylead[3]), FALSE, int, "%d");
340 expect_eq(_ismbstrail(mbsonlylead, &mbsonlylead[4]), FALSE, int, "%d");
341 expect_eq(_ismbstrail(mbsonlylead, &mbsonlylead[5]), FALSE, int, "%d");
342
343 /* _mbsbtype */
345 expect_eq(_mbsbtype(mbstring, 0), _MBC_LEAD, int, "%d");
346 expect_eq(_mbsbtype(mbstring, 1), _MBC_TRAIL, int, "%d");
347 expect_eq(_mbsbtype(mbstring, 2), _MBC_LEAD, int, "%d");
348 expect_eq(_mbsbtype(mbstring, 3), _MBC_ILLEGAL, int, "%d");
349 expect_eq(_mbsbtype(mbstring, 4), _MBC_LEAD, int, "%d");
350 expect_eq(_mbsbtype(mbstring, 5), _MBC_TRAIL, int, "%d");
351 expect_eq(_mbsbtype(mbstring, 6), _MBC_SINGLE, int, "%d");
352 expect_eq(_mbsbtype(mbstring, 7), _MBC_LEAD, int, "%d");
353 expect_eq(_mbsbtype(mbstring, 8), _MBC_ILLEGAL, int, "%d");
354
355 expect_eq(_mbsbtype(mbsonlylead, 0), _MBC_LEAD, int, "%d");
356 expect_eq(_mbsbtype(mbsonlylead, 1), _MBC_ILLEGAL, int, "%d");
357 expect_eq(_mbsbtype(mbsonlylead, 2), _MBC_ILLEGAL, int, "%d");
358 expect_eq(_mbsbtype(mbsonlylead, 3), _MBC_ILLEGAL, int, "%d");
359 expect_eq(_mbsbtype(mbsonlylead, 4), _MBC_ILLEGAL, int, "%d");
360 expect_eq(_mbsbtype(mbsonlylead, 5), _MBC_ILLEGAL, int, "%d");
361
362 /* _mbsnextc */
363 expect_eq(_mbsnextc(mbstring), 0xb0b1, int, "%x");
364 expect_eq(_mbsnextc(&mbstring[2]), 0xb220, int, "%x"); /* lead + invalid tail */
365 expect_eq(_mbsnextc(&mbstring[3]), 0x20, int, "%x"); /* single char */
366
367 if (!p_mbsnextc_l)
368 win_skip("_mbsnextc_l tests\n");
369 else
370 expect_eq(p_mbsnextc_l(mbstring, NULL), 0xb0b1, int, "%x");
371
372 /* _mbclen/_mbslen */
373 expect_eq(_mbclen(mbstring), 2, int, "%d");
374 expect_eq(_mbclen(&mbstring[2]), 2, int, "%d");
375 expect_eq(_mbclen(&mbstring[3]), 1, int, "%d");
376 expect_eq(_mbclen(mbsonlylead), 1, int, "%d");
377 expect_eq(_mbslen(mbstring2), 4, int, "%d");
378 expect_eq(_mbslen(mbsonlylead), 0, int, "%d"); /* lead + NUL not counted as character */
379 expect_eq(_mbslen(mbstring), 4, int, "%d"); /* lead + invalid trail counted */
380
381 if(!p__mbsnlen) {
382 win_skip("_mbsnlen tests\n");
383 }else {
384 expect_eq(p__mbsnlen(mbstring, 8), 8, int, "%d");
385 expect_eq(p__mbsnlen(mbstring, 9), 4, int, "%d");
386 expect_eq(p__mbsnlen(mbstring, 10), 4, int, "%d");
387 expect_eq(p__mbsnlen(mbsonlylead, 0), 0, int, "%d");
388 expect_eq(p__mbsnlen(mbsonlylead, 1), 1, int, "%d");
389 expect_eq(p__mbsnlen(mbsonlylead, 2), 0, int, "%d");
390 expect_eq(p__mbsnlen(mbstring2, 7), 7, int, "%d");
391 expect_eq(p__mbsnlen(mbstring2, 8), 4, int, "%d");
392 expect_eq(p__mbsnlen(mbstring2, 9), 4, int, "%d");
393 }
394
395 /* mbrlen */
396 if(!setlocale(LC_ALL, ".936") || !p_mbrlen) {
397 win_skip("mbrlen tests\n");
398 }else {
399 mbstate_t state = 0;
400 expect_eq(p_mbrlen((const char*)mbstring, 2, NULL), 2, int, "%d");
401 expect_eq(p_mbrlen((const char*)&mbstring[2], 2, NULL), 2, int, "%d");
402 expect_eq(p_mbrlen((const char*)&mbstring[3], 2, NULL), 1, int, "%d");
403 expect_eq(p_mbrlen((const char*)mbstring, 1, NULL), -2, int, "%d");
404 expect_eq(p_mbrlen((const char*)mbstring, 1, &state), -2, int, "%d");
405 ok(state == mbstring[0], "incorrect state value (%x)\n", state);
406 expect_eq(p_mbrlen((const char*)&mbstring[1], 1, &state), 2, int, "%d");
407 }
408
409 /* mbrtowc */
410 if(!setlocale(LC_ALL, ".936") || !p_mbrtowc) {
411 win_skip("mbrtowc tests\n");
412 }else {
413 mbstate_t state = 0;
414 wchar_t dst;
415 expect_eq(p_mbrtowc(&dst, (const char*)mbstring, 2, NULL), 2, int, "%d");
416 ok(dst == 0x6c28, "dst = %x, expected 0x6c28\n", dst);
417 expect_eq(p_mbrtowc(&dst, (const char*)mbstring+2, 2, NULL), 2, int, "%d");
418 ok(dst == 0x3f, "dst = %x, expected 0x3f\n", dst);
419 expect_eq(p_mbrtowc(&dst, (const char*)mbstring+3, 2, NULL), 1, int, "%d");
420 ok(dst == 0x20, "dst = %x, expected 0x20\n", dst);
421 expect_eq(p_mbrtowc(&dst, (const char*)mbstring, 1, NULL), -2, int, "%d");
422 ok(dst == 0, "dst = %x, expected 0\n", dst);
423 expect_eq(p_mbrtowc(&dst, (const char*)mbstring, 1, &state), -2, int, "%d");
424 ok(dst == 0, "dst = %x, expected 0\n", dst);
425 ok(state == mbstring[0], "incorrect state value (%x)\n", state);
426 expect_eq(p_mbrtowc(&dst, (const char*)mbstring+1, 1, &state), 2, int, "%d");
427 ok(dst == 0x6c28, "dst = %x, expected 0x6c28\n", dst);
428 ok(state == 0, "incorrect state value (%x)\n", state);
429 }
430 setlocale(LC_ALL, "C");
431
432 /* _mbccpy/_mbsncpy */
433 memset(buf, 0xff, sizeof(buf));
434 _mbccpy(buf, mbstring);
435 expect_bin(buf, "\xb0\xb1\xff", 3);
436
437 if(!p__mbccpy_s) {
438 win_skip("_mbccpy_s tests\n");
439 }else {
440 int err, copied;
441
442 memset(buf, 0xff, sizeof(buf));
443 copied = -1;
444 err = p__mbccpy_s(buf, 0, &copied, mbstring);
445 ok(err == EINVAL, "_mbccpy_s returned %d\n", err);
446 ok(!copied, "copied = %d\n", copied);
447 ok(buf[0] == 0xff, "buf[0] = %x\n", buf[0]);
448
449 memset(buf, 0xff, sizeof(buf));
450 copied = -1;
451 err = p__mbccpy_s(buf, 1, &copied, mbstring);
452 ok(err == ERANGE, "_mbccpy_s returned %d\n", err);
453 ok(!copied, "copied = %d\n", copied);
454 ok(!buf[0], "buf[0] = %x\n", buf[0]);
455
456 memset(buf, 0xff, sizeof(buf));
457 copied = -1;
458 err = p__mbccpy_s(buf, 2, &copied, mbstring);
459 ok(!err, "_mbccpy_s returned %d\n", err);
460 ok(copied == 2, "copied = %d\n", copied);
461 expect_bin(buf, "\xb0\xb1\xff", 3);
462
463 memset(buf, 0xff, sizeof(buf));
464 copied = -1;
465 err = p__mbccpy_s(buf, 2, &copied, (unsigned char *)"\xb0");
466 ok(err == EILSEQ, "_mbccpy_s returned %d\n", err);
467 ok(copied == 1, "copied = %d\n", copied);
468 expect_bin(buf, "\x00\xff", 2);
469 }
470
472 errno = 0xdeadbeef;
473 ret = _mbsncpy(NULL, mbstring, 1);
474 ok(ret == NULL, "_mbsncpy returned %p, expected NULL\n", ret);
475 ok(errno == EINVAL, "_mbsncpy returned %d\n", errno);
476
477 memset(buf, 0xff, sizeof(buf));
478 errno = 0xdeadbeef;
479 ret = _mbsncpy(buf, NULL, 1);
480 ok(ret == NULL, "_mbsncpy returned %p, expected NULL\n", ret);
481 ok(errno == EINVAL, "_mbsncpy returned %d\n", errno);
482 expect_bin(buf, "\xff\xff\xff", 3);
483 }
484
485 errno = 0xdeadbeef;
486 ret = _mbsncpy(NULL, mbstring, 0);
487 ok(ret == NULL, "_mbsncpy returned %p, expected NULL\n", ret);
488 ok(errno == 0xdeadbeef, "_mbsncpy should not change errno\n");
489
490 memset(buf, 0xff, sizeof(buf));
491 errno = 0xdeadbeef;
492 ret = _mbsncpy(buf, NULL, 0);
493 ok(ret == buf, "_mbsncpy returned %p, expected %sp\n", ret, buf);
494 ok(errno == 0xdeadbeef, "_mbsncpy should not change errno\n");
495
497 memset(buf, 0xff, sizeof(buf));
498 errno = 0xdeadbeef;
499 ret = _mbsncpy(NULL, mbstring, 1);
500 ok(ret == NULL, "_mbsncpy returned %p, expected NULL\n", ret);
501 ok(errno == EINVAL, "_mbsncpy returned %d\n", errno);
502
503 memset(buf, 0xff, sizeof(buf));
504 errno = 0xdeadbeef;
505 ret = _mbsncpy(buf, NULL, 1);
506 ok(ret == NULL, "_mbsncpy returned %p, expected NULL\n", ret);
507 ok(errno == EINVAL, "_mbsncpy returned %d\n", errno);
508 }
509
510 memset(buf, 0xff, sizeof(buf));
511 ret = _mbsncpy(NULL, mbstring, 0);
512 ok(ret == NULL, "_mbsncpy returned %p, expected %p\n", ret, buf);
513
514 memset(buf, 0xff, sizeof(buf));
515 ret = _mbsncpy(buf, NULL, 0);
516 ok(ret == buf, "_mbsncpy returned %p, expected %sp\n", ret, buf);
517
518 memset(buf, 0xff, sizeof(buf));
519 ret = _mbsncpy(buf, mbstring, 0);
520 ok(ret == buf, "_mbsncpy returned %p, expected %p\n", ret, buf);
521
522 memset(buf, 0xff, sizeof(buf));
523 _mbsncpy(buf, mbstring, 1);
524 expect_bin(buf, "\xb0\xb1\xff", 3);
525 memset(buf, 0xff, sizeof(buf));
526 _mbsncpy(buf, mbstring, 2);
527 expect_bin(buf, "\xb0\xb1\xb2 \xff", 5);
528 memset(buf, 0xff, sizeof(buf));
529 _mbsncpy(buf, mbstring, 3);
530 expect_bin(buf, "\xb0\xb1\xb2 \xb3\xb4\xff", 7);
531 memset(buf, 0xff, sizeof(buf));
532 _mbsncpy(buf, mbstring, 4);
533 expect_bin(buf, "\xb0\xb1\xb2 \xb3\xb4 \xff", 8);
534 memset(buf, 0xff, sizeof(buf));
535 _mbsncpy(buf, mbstring, 5);
536 expect_bin(buf, "\xb0\xb1\xb2 \xb3\xb4 \0\0\xff", 10);
537 memset(buf, 0xff, sizeof(buf));
538 _mbsncpy(buf, mbsonlylead, 6);
539 expect_bin(buf, "\0\0\0\0\0\0\0\xff", 8);
540
541 memset(buf, 0xff, sizeof(buf));
542 _mbsnbcpy(buf, mbstring2, 2);
543 expect_bin(buf, "\xb0\xb1\xff", 3);
544 _mbsnbcpy(buf, mbstring2, 3);
545 expect_bin(buf, "\xb0\xb1\0\xff", 4);
546 _mbsnbcpy(buf, mbstring2, 4);
547 expect_bin(buf, "\xb0\xb1\xb2\xb3\xff", 5);
548 memset(buf, 0xff, sizeof(buf));
549 _mbsnbcpy(buf, mbsonlylead, 5);
550 expect_bin(buf, "\0\0\0\0\0\xff", 6);
551
552 /* _mbsinc/mbsdec */
553 step = _mbsinc(mbstring) - mbstring;
554 ok(step == 2, "_mbsinc adds %d (exp. 2)\n", step);
555 step = _mbsinc(&mbstring[2]) - &mbstring[2]; /* lead + invalid tail */
556 ok(step == 2, "_mbsinc adds %d (exp. 2)\n", step);
557
558 step = _mbsninc(mbsonlylead, 1) - mbsonlylead;
559 ok(step == 0, "_mbsninc adds %d (exp. 0)\n", step);
560 step = _mbsninc(mbsonlylead, 2) - mbsonlylead; /* lead + NUL byte + lead + char */
561 ok(step == 0, "_mbsninc adds %d (exp. 0)\n", step);
562 step = _mbsninc(mbstring2, 0) - mbstring2;
563 ok(step == 0, "_mbsninc adds %d (exp. 2)\n", step);
564 step = _mbsninc(mbstring2, 1) - mbstring2;
565 ok(step == 2, "_mbsninc adds %d (exp. 2)\n", step);
566 step = _mbsninc(mbstring2, 2) - mbstring2;
567 ok(step == 4, "_mbsninc adds %d (exp. 4)\n", step);
568 step = _mbsninc(mbstring2, 3) - mbstring2;
569 ok(step == 5, "_mbsninc adds %d (exp. 5)\n", step);
570 step = _mbsninc(mbstring2, 4) - mbstring2;
571 ok(step == 7, "_mbsninc adds %d (exp. 7)\n", step);
572 step = _mbsninc(mbstring2, 5) - mbstring2;
573 ok(step == 7, "_mbsninc adds %d (exp. 7)\n", step);
574 step = _mbsninc(mbstring2, 17) - mbstring2;
575 ok(step == 7, "_mbsninc adds %d (exp. 7)\n", step);
576
577 /* functions that depend on locale codepage, not mbcp.
578 * we hope the current locale to be SBCS because setlocale(LC_ALL, ".1252") seems not to work yet
579 * (as of Wine 0.9.43)
580 */
582 if (cp_info.MaxCharSize == 1)
583 {
584 expect_eq(mblen((char *)mbstring, 3), 1, int, "%x");
585 expect_eq(_mbstrlen((char *)mbstring2), 7, int, "%d");
586 }
587 else
588 skip("Current locale has double-byte charset - could lead to false positives\n");
589
590 _setmbcp(1361);
591 expect_eq(_ismbblead(0x80), 0, int, "%d");
592 todo_wine {
593 expect_eq(_ismbblead(0x81), 1, int, "%d");
594 expect_eq(_ismbblead(0x83), 1, int, "%d");
595 }
596 expect_eq(_ismbblead(0x84), 1, int, "%d");
597 expect_eq(_ismbblead(0xd3), 1, int, "%d");
598 expect_eq(_ismbblead(0xd7), 0, int, "%d");
599 expect_eq(_ismbblead(0xd8), 1, int, "%d");
600 expect_eq(_ismbblead(0xd9), 1, int, "%d");
601
602 expect_eq(_ismbbtrail(0x30), 0, int, "%d");
603 expect_eq(_ismbbtrail(0x31), 1, int, "%d");
604 expect_eq(_ismbbtrail(0x7e), 1, int, "%d");
605 expect_eq(_ismbbtrail(0x7f), 0, int, "%d");
606 expect_eq(_ismbbtrail(0x80), 0, int, "%d");
607 expect_eq(_ismbbtrail(0x81), 1, int, "%d");
608 expect_eq(_ismbbtrail(0xfe), 1, int, "%d");
609 expect_eq(_ismbbtrail(0xff), 0, int, "%d");
610
611 _setmbcp(curr_mbcp);
612}
static int state
Definition: maze.c:121
_Check_return_ _CRTIMP int __cdecl _ismbslead(_In_reads_z_(_Pos - _Str+1) const unsigned char *_Str, _In_z_ const unsigned char *_Pos)
UINT WINAPI GetACP(void)
Definition: locale.c:2023
BOOL WINAPI GetCPInfo(UINT codepage, LPCPINFO cpinfo)
Definition: locale.c:2146
_CRTIMP unsigned char *__cdecl _mbsncpy(_Pre_notnull_ _Out_writes_(2 *_Count) _Post_maybez_ unsigned char *_Dest, _In_z_ const unsigned char *_Source, _In_ size_t _Count)
_Check_return_ _CRTIMP unsigned int __cdecl _mbsnextc(_In_z_ const unsigned char *_Str)
_Check_return_ _CRTIMP unsigned char *__cdecl _mbsninc(_In_reads_bytes_(_Count) _Pre_z_ const unsigned char *_Str, _In_ size_t _Count)
_CRTIMP int __cdecl _mbsbtype(_In_reads_bytes_(_Pos) _Pre_z_ const unsigned char *_Str, _In_ size_t _Pos)
_CRTIMP unsigned char *__cdecl _mbsnbcpy(_Out_writes_(_Count) _Post_maybez_ unsigned char *_Dest, _In_z_ const unsigned char *_Source, _In_ size_t _Count)
_Check_return_ _CRTIMP size_t __cdecl _mbslen(_In_z_ const unsigned char *_Str)
_Check_return_ _CRTIMP unsigned char *__cdecl _mbsinc(_In_z_ const unsigned char *_Ptr)
_CRTIMP void __cdecl _mbccpy(_Out_writes_bytes_(2) unsigned char *_Dst, _In_z_ const unsigned char *_Src)
_Check_return_ _CRTIMP size_t __cdecl _mbclen(_In_z_ const unsigned char *_Str)
int __cdecl _ismbstrail(const unsigned char *start, const unsigned char *str)
Definition: ismbtrl.c:32
#define _SBLOW
Definition: msvcrt.h:821
#define _SBUP
Definition: msvcrt.h:820
#define expect_bin(buf, value, len)
Definition: string.c:59
#define test_codepage(num)
Definition: string.c:260
#define expect_eq(expr, value, type, format)
Definition: string.c:58
_Check_return_ _CRTIMP size_t __cdecl _mbstrlen(_In_z_ const char *_Str)
_Check_return_ int __cdecl mblen(_In_reads_bytes_opt_(_MaxCount) _Pre_opt_z_ const char *_Ch, _In_ size_t _MaxCount)
#define skip_2k3_crash
Definition: test.h:190

Referenced by START_TEST().

◆ test_mbctohira()

static void test_mbctohira ( void  )
static

Definition at line 1564 of file string.c.

1565{
1566 static const unsigned int mbchira_932[][2] = {
1567 {0x8152, 0x8152}, {0x8153, 0x8153}, {0x8154, 0x8154}, {0x8155, 0x8155},
1568 {0x82a0, 0x82a0}, {0x833f, 0x833f}, {0x8340, 0x829f}, {0x837e, 0x82dd},
1569 {0x837f, 0x837f}, {0x8380, 0x82de}, {0x8393, 0x82f1}, {0x8394, 0x8394},
1570 {0x8396, 0x8396}, {0x8397, 0x8397},
1571 {0xa5, 0xa5}, {0xb0, 0xb0}, {0xdd, 0xdd} };
1572 unsigned int i;
1573 unsigned int prev_cp = _getmbcp();
1574
1576 for (i = 0; i < ARRAY_SIZE(mbchira_932); i++)
1577 {
1578 int ret, exp = mbchira_932[i][0];
1579 ret = _mbctohira(mbchira_932[i][0]);
1580 ok(ret == exp, "Expected 0x%x, got 0x%x\n", exp, ret);
1581 }
1582
1583 _setmbcp(932);
1584 for (i = 0; i < ARRAY_SIZE(mbchira_932); i++)
1585 {
1586 unsigned int ret, exp;
1587 ret = _mbctohira(mbchira_932[i][0]);
1588 exp = mbchira_932[i][1];
1589 ok(ret == exp, "Expected 0x%x, got 0x%x\n", exp, ret);
1590 }
1591 _setmbcp(prev_cp);
1592}
_Check_return_ _CRTIMP unsigned int __cdecl _mbctohira(_In_ unsigned int _Ch)

Referenced by START_TEST().

◆ test_mbctokata()

static void test_mbctokata ( void  )
static

Definition at line 1594 of file string.c.

1595{
1596 static const unsigned int mbckata_932[][2] = {
1597 {0x8152, 0x8152}, {0x8153, 0x8153}, {0x8154, 0x8154}, {0x8155, 0x8155},
1598 {0x833f, 0x833f}, {0x829f, 0x8340}, {0x82dd, 0x837e}, {0x837f, 0x837f},
1599 {0x82de, 0x8380}, {0x8394, 0x8394}, {0x8397, 0x8397},
1600 {0xa5, 0xa5}, {0xb0, 0xb0}, {0xdd, 0xdd} };
1601 unsigned int i;
1602 unsigned int prev_cp = _getmbcp();
1603
1605 for (i = 0; i < ARRAY_SIZE(mbckata_932); i++)
1606 {
1607 int ret, exp = mbckata_932[i][0];
1608 ret = _mbctokata(mbckata_932[i][0]);
1609 ok(ret == exp, "Expected 0x%x, got 0x%x\n", exp, ret);
1610 }
1611
1612 _setmbcp(932);
1613 for (i = 0; i < ARRAY_SIZE(mbckata_932); i++)
1614 {
1615 unsigned int ret, exp;
1616 ret = _mbctokata(mbckata_932[i][0]);
1617 exp = mbckata_932[i][1];
1618 ok(ret == exp, "Expected 0x%x, got 0x%x\n", exp, ret);
1619 }
1620 _setmbcp(prev_cp);
1621}
_Check_return_ _CRTIMP unsigned int __cdecl _mbctokata(_In_ unsigned int _Ch)

Referenced by START_TEST().

◆ test_mbctombb()

static void test_mbctombb ( void  )
static

Definition at line 1649 of file string.c.

1650{
1651 static const unsigned int mbcmbb_932[][2] = {
1652 {0x829e, 0x829e}, {0x829f, 0xa7}, {0x82f1, 0xdd}, {0x82f2, 0x82f2},
1653 {0x833f, 0x833f}, {0x8340, 0xa7}, {0x837e, 0xd0}, {0x837f, 0x837f},
1654 {0x8380, 0xd1}, {0x8396, 0xb9}, {0x8397, 0x8397}, {0x813f, 0x813f},
1655 {0x8140, 0x20}, {0x814c, 0x814c}, {0x814f, 0x5e}, {0x8197, 0x40},
1656 {0x8198, 0x8198}, {0x8258, 0x39}, {0x8259, 0x8259}, {0x825f, 0x825f},
1657 {0x8260, 0x41}, {0x82f1, 0xdd}, {0x82f2, 0x82f2}, {0,0}};
1658 unsigned int exp, ret, i;
1659 unsigned int prev_cp = _getmbcp();
1660
1661 _setmbcp(932);
1662 for (i = 0; mbcmbb_932[i][0] != 0; i++)
1663 {
1664 ret = _mbctombb(mbcmbb_932[i][0]);
1665 exp = mbcmbb_932[i][1];
1666 ok(ret == exp, "Expected 0x%x, got 0x%x\n", exp, ret);
1667 }
1668 _setmbcp(prev_cp);
1669}
_Check_return_ _CRTIMP unsigned int __cdecl _mbctombb(_In_ unsigned int _Ch)

Referenced by START_TEST().

◆ test_mbsrev()

static void test_mbsrev ( void  )
static

Definition at line 4879 of file string.c.

4880{
4881 unsigned char buf[64], *ret;
4882 int cp = _getmbcp();
4883
4884 _setmbcp(932);
4885
4886 strcpy((char *)buf, "\x36\x8c\x8e");
4887 ret = _mbsrev(buf);
4888 ok(ret == buf, "ret = %p, expected %p\n", ret, buf);
4889 ok(!memcmp(buf, "\x8c\x8e\x36", 4), "buf = %s\n", wine_dbgstr_a((char *)buf));
4890
4891 /* test string that ends with leading byte */
4892 strcpy((char *)buf, "\x36\x8c");
4893 ret = _mbsrev(buf);
4894 ok(ret == buf, "ret = %p, expected %p\n", ret, buf);
4895 skip_2k3_fail ok(!memcmp(buf, "\x36", 2), "buf = %s\n", wine_dbgstr_a((char *)buf));
4896
4897 _setmbcp(cp);
4898}
_CRTIMP unsigned char *__cdecl _mbsrev(_Inout_z_ unsigned char *_Str)
const char int int int static __inline const char * wine_dbgstr_a(const char *s)
Definition: debug.h:187

Referenced by START_TEST().

◆ test_mbsspn()

static void test_mbsspn ( void  )
static

Definition at line 614 of file string.c.

615{
616 unsigned char str1[]="cabernet";
617 unsigned char str2[]="shiraz";
618 unsigned char set[]="abc";
619 unsigned char empty[]="";
620 unsigned char mbstr[]=" 2019\x94\x4e" "6\x8c\x8e" "29\x93\xfa";
621 unsigned char mbset1[]="0123456789 \x94\x4e";
622 unsigned char mbset2[]=" \x94\x4e\x8c\x8e";
623 unsigned char mbset3[]="\x8e";
624 int ret, cp = _getmbcp();
625
626 ret=_mbsspn( str1, set);
627 ok( ret==3, "_mbsspn returns %d should be 3\n", ret);
628 ret=_mbsspn( str2, set);
629 ok( ret==0, "_mbsspn returns %d should be 0\n", ret);
630 ret=_mbsspn( str1, empty);
631 ok( ret==0, "_mbsspn returns %d should be 0\n", ret);
632
633 ret=_mbscspn( str1, set);
634 ok( ret==0, "_mbscspn returns %d should be 0\n", ret);
635 ret=_mbscspn( str2, set);
636 ok( ret==4, "_mbscspn returns %d should be 4\n", ret);
637 ret=_mbscspn( str1, empty);
638 ok( ret==8, "_mbscspn returns %d should be 8\n", ret);
639
640 _setmbcp( 932);
641 ret=_mbsspn( mbstr, mbset1);
642 ok( ret==8, "_mbsspn returns %d should be 8\n", ret);
643 ret=_mbsspn( mbstr, mbset2);
644 ok( ret==1, "_mbsspn returns %d should be 1\n", ret);
645 ret=_mbsspn( mbstr+8, mbset1);
646 ok( ret==0, "_mbsspn returns %d should be 0\n", ret);
647 ret=_mbsspn( mbstr+8, mbset2);
648 ok( ret==2, "_mbsspn returns %d should be 2\n", ret);
649 ret=_mbsspn( mbstr, mbset3);
650 ok( ret==14, "_mbsspn returns %d should be 14\n", ret);
651
652 ret=_mbscspn( mbstr, mbset1);
653 ok( ret==0, "_mbscspn returns %d should be 0\n", ret);
654 ret=_mbscspn( mbstr, mbset2);
655 ok( ret==0, "_mbscspn returns %d should be 0\n", ret);
656 ret=_mbscspn( mbstr+8, mbset1);
657 ok( ret==2, "_mbscspn returns %d should be 2\n", ret);
658 ret=_mbscspn( mbstr+8, mbset2);
659 ok( ret==0, "_mbscspn returns %d should be 0\n", ret);
660 ret=_mbscspn( mbstr, mbset3);
661 ok( ret==0, "_mbscspn returns %d should be 0\n", ret);
662
663 _setmbcp( cp);
664}
Definition: _set.h:50
static const WCHAR empty[]
Definition: main.c:47
_Check_return_ _CRTIMP size_t __cdecl _mbscspn(_In_z_ const unsigned char *_Str, _In_z_ const unsigned char *_Control)
_Check_return_ _CRTIMP size_t __cdecl _mbsspn(_In_z_ const unsigned char *_Str, _In_z_ const unsigned char *_Control)

Referenced by START_TEST().

◆ test_mbsspnp()

static void test_mbsspnp ( void  )
static

Definition at line 666 of file string.c.

667{
668 unsigned char str1[]="cabernet";
669 unsigned char str2[]="shiraz";
670 unsigned char set[]="abc";
671 unsigned char empty[]="";
672 unsigned char full[]="abcenrt";
673 unsigned char mbstr[]=" 2019\x94\x4e" "6\x8c\x8e" "29\x93\xfa";
674 unsigned char mbset1[]="0123456789 \x94\x4e";
675 unsigned char mbset2[]=" \x94\x4e\x8c\x8e";
676 unsigned char* ret;
677 int cp = _getmbcp();
678
679 ret=_mbsspnp( str1, set);
680 ok( ret[0]=='e', "_mbsspnp returns %c should be e\n", ret[0]);
681 ret=_mbsspnp( str2, set);
682 ok( ret[0]=='s', "_mbsspnp returns %c should be s\n", ret[0]);
683 ret=_mbsspnp( str1, empty);
684 ok( ret[0]=='c', "_mbsspnp returns %c should be c\n", ret[0]);
685 ret=_mbsspnp( str1, full);
686 ok( ret==NULL, "_mbsspnp returns %p should be NULL\n", ret);
687
688 _setmbcp( 932);
689 ret=_mbsspnp( mbstr, mbset1);
690 ok( ret==mbstr+8, "_mbsspnp returns %p should be %p\n", ret, mbstr+8);
691 ret=_mbsspnp( mbstr, mbset2);
692 ok( ret==mbstr+1, "_mbsspnp returns %p should be %p\n", ret, mbstr+1);
693 ret=_mbsspnp( mbstr+8, mbset1);
694 ok( ret==mbstr+8, "_mbsspnp returns %p should be %p\n", ret, mbstr+8);
695 ret=_mbsspnp( mbstr+8, mbset2);
696 ok( ret==mbstr+10, "_mbsspnp returns %p should be %p\n", ret, mbstr+10);
697
698 _setmbcp( cp);
699}
_Check_return_ _CRTIMP unsigned char *__cdecl _mbsspnp(_In_z_ const unsigned char *_Str1, _In_z_ const unsigned char *_Str2)

Referenced by START_TEST().

◆ test_mbstowcs()

static void test_mbstowcs ( void  )
static

Definition at line 2185 of file string.c.

2186{
2187 static const wchar_t wSimple[] = L"text";
2188 static const wchar_t wHiragana[] = L"\x3042\x3043";
2189 static const char mSimple[] = "text";
2190 static const char mHiragana[] = { 0x82,0xa0,0x82,0xa1,0 };
2191
2192 const wchar_t *pwstr;
2193 wchar_t wOut[6];
2194 char mOut[6];
2195 size_t ret;
2196 int err;
2197 const char *pmbstr;
2199
2200 wOut[4] = '!'; wOut[5] = '\0';
2201 mOut[4] = '!'; mOut[5] = '\0';
2202
2203 if(pmbstowcs_s) {
2204 /* crashes on some systems */
2205 errno = 0xdeadbeef;
2206 ret = mbstowcs(wOut, NULL, 4);
2207 ok(ret == -1, "mbstowcs did not return -1\n");
2208 ok(errno == EINVAL, "errno = %d\n", errno);
2209 }
2210
2211 ret = mbstowcs(NULL, mSimple, 0);
2212 ok(ret == 4, "mbstowcs did not return 4\n");
2213
2214 ret = mbstowcs(wOut, mSimple, 4);
2215 ok(ret == 4, "mbstowcs did not return 4\n");
2216 ok(!memcmp(wOut, wSimple, 4*sizeof(wchar_t)), "wOut = %s\n", wine_dbgstr_w(wOut));
2217 ok(wOut[4] == '!', "wOut[4] != \'!\'\n");
2218
2219 ret = mbstowcs(NULL, "", 1);
2220 ok(ret == 0, "mbstowcs did not return 0, got %d\n", (int)ret);
2221
2222 ret = mbstowcs(wOut, "", 1);
2223 ok(ret == 0, "mbstowcs did not return 0, got %d\n", (int)ret);
2224 ok(!wOut[0], "wOut = %s\n", wine_dbgstr_w(wOut));
2225
2226 ret = wcstombs(NULL, wSimple, 0);
2227 ok(ret == 4, "wcstombs did not return 4\n");
2228
2229 ret = wcstombs(mOut, wSimple, 6);
2230 ok(ret == 4, "wcstombs did not return 4\n");
2231 ok(!memcmp(mOut, mSimple, 5*sizeof(char)), "mOut = %s\n", mOut);
2232
2233 ret = wcstombs(mOut, wSimple, 2);
2234 ok(ret == 2, "wcstombs did not return 2\n");
2235 ok(!memcmp(mOut, mSimple, 5*sizeof(char)), "mOut = %s\n", mOut);
2236
2237 ret = wcstombs(NULL, L"", 1);
2238 ok(ret == 0, "wcstombs did not return 0, got %d\n", (int)ret);
2239
2240 ret = wcstombs(mOut, L"", 1);
2241 ok(ret == 0, "wcstombs did not return 0, got %d\n", (int)ret);
2242 ok(!mOut[0], "mOut = %s\n", mOut);
2243
2244 if(pwcsrtombs) {
2245 pwstr = wSimple;
2246 err = -3;
2247 ret = pwcsrtombs(mOut, &pwstr, 4, &err);
2248 ok(ret == 4, "wcsrtombs did not return 4\n");
2249 ok(err == 0, "err = %d\n", err);
2250 ok(pwstr == wSimple+4, "pwstr = %p (wszSimple = %p)\n", pwstr, wSimple);
2251 ok(!memcmp(mOut, mSimple, ret), "mOut = %s\n", mOut);
2252
2253 pwstr = wSimple;
2254 ret = pwcsrtombs(mOut, &pwstr, 5, NULL);
2255 ok(ret == 4, "wcsrtombs did not return 4\n");
2256 ok(pwstr == NULL, "pwstr != NULL\n");
2257 ok(!memcmp(mOut, mSimple, sizeof(mSimple)), "mOut = %s\n", mOut);
2258 }
2259
2260 if(!setlocale(LC_ALL, "Japanese_Japan.932")) {
2261 win_skip("Japanese_Japan.932 locale not available\n");
2262 return;
2263 }
2264
2265 ret = mbstowcs(wOut, mHiragana, 6);
2266 ok(ret == 2, "mbstowcs did not return 2\n");
2267 ok(!memcmp(wOut, wHiragana, sizeof(wHiragana)), "wOut = %s\n", wine_dbgstr_w(wOut));
2268
2269 ret = mbstowcs(wOut, "", 6);
2270 ok(ret == 0, "mbstowcs did not return 0, got %d\n", (int)ret);
2271 ok(!wOut[0], "wOut = %s\n", wine_dbgstr_w(wOut));
2272
2273 errno = 0xdeadbeef;
2274 ret = mbstowcs(wOut, mHiragana+1, 5);
2275 ok(ret == -1, "mbstowcs did not return -1\n");
2276 ok(errno == EILSEQ, "errno = %d\n", errno);
2277
2278 ret = wcstombs(mOut, wHiragana, 6);
2279 ok(ret == 4, "wcstombs did not return 4\n");
2280 ok(!memcmp(mOut, mHiragana, sizeof(mHiragana)), "mOut = %s\n", mOut);
2281
2282 ret = wcstombs(mOut, L"", 6);
2283 ok(ret == 0, "wcstombs did not return 0, got %d\n", (int)ret);
2284 ok(!mOut[0], "mOut = %s\n", mOut);
2285
2286 if(!pmbstowcs_s || !pwcstombs_s) {
2287 setlocale(LC_ALL, "C");
2288 win_skip("mbstowcs_s or wcstombs_s not available\n");
2289 return;
2290 }
2291
2292 err = pmbstowcs_s(&ret, wOut, 1, mSimple, _TRUNCATE);
2293 ok(err == STRUNCATE, "err = %d\n", err);
2294 ok(ret == 1, "mbstowcs_s did not return 0\n");
2295 ok(!wOut[0], "wOut[0] = %d\n", wOut[0]);
2296
2297 err = pmbstowcs_s(&ret, wOut, 6, mSimple, _TRUNCATE);
2298 ok(err == 0, "err = %d\n", err);
2299 ok(ret == 5, "mbstowcs_s did not return 5\n");
2300 ok(!memcmp(wOut, wSimple, sizeof(wSimple)), "wOut = %s\n", wine_dbgstr_w(wOut));
2301
2302 err = pmbstowcs_s(&ret, wOut, 6, mHiragana, _TRUNCATE);
2303 ok(err == 0, "err = %d\n", err);
2304 ok(ret == 3, "mbstowcs_s did not return 3\n");
2305 ok(!memcmp(wOut, wHiragana, sizeof(wHiragana)), "wOut = %s\n", wine_dbgstr_w(wOut));
2306
2307 err = pmbstowcs_s(&ret, wOut, 6, "", _TRUNCATE);
2308 ok(err == 0, "err = %d\n", err);
2309 ok(ret == 1, "mbstowcs_s did not return 1, got %d\n", (int)ret);
2310 ok(!wOut[0], "wOut = %s\n", wine_dbgstr_w(wOut));
2311
2312 err = pmbstowcs_s(&ret, NULL, 0, mHiragana, 1);
2313 ok(err == 0, "err = %d\n", err);
2314 ok(ret == 3, "mbstowcs_s did not return 3\n");
2315
2316 err = pwcstombs_s(&ret, mOut, 6, wSimple, _TRUNCATE);
2317 ok(err == 0, "err = %d\n", err);
2318 ok(ret == 5, "wcstombs_s did not return 5\n");
2319 ok(!memcmp(mOut, mSimple, sizeof(mSimple)), "mOut = %s\n", mOut);
2320
2321 err = pwcstombs_s(&ret, mOut, 6, wHiragana, _TRUNCATE);
2322 ok(err == 0, "err = %d\n", err);
2323 ok(ret == 5, "wcstombs_s did not return 5\n");
2324 ok(!memcmp(mOut, mHiragana, sizeof(mHiragana)), "mOut = %s\n", mOut);
2325
2326 err = pwcstombs_s(&ret, mOut, 6, L"", _TRUNCATE);
2327 ok(err == 0, "err = %d\n", err);
2328 ok(ret == 1, "wcstombs_s did not return 1, got %d\n", (int)ret);
2329 ok(!mOut[0], "mOut = %s\n", mOut);
2330
2331 err = pwcstombs_s(&ret, NULL, 0, wHiragana, 1);
2332 ok(err == 0, "err = %d\n", err);
2333 ok(ret == 5, "wcstombs_s did not return 5\n");
2334
2335 if(!pwcsrtombs) {
2336 setlocale(LC_ALL, "C");
2337 win_skip("wcsrtombs not available\n");
2338 return;
2339 }
2340
2341 pwstr = wSimple;
2342 err = -3;
2343 ret = pwcsrtombs(mOut, &pwstr, 4, &err);
2344 ok(ret == 4, "wcsrtombs did not return 4\n");
2345 ok(err == 0, "err = %d\n", err);
2346 ok(pwstr == wSimple+4, "pwstr = %p (wszSimple = %p)\n", pwstr, wSimple);
2347 ok(!memcmp(mOut, mSimple, ret), "mOut = %s\n", mOut);
2348
2349 pwstr = wSimple;
2350 ret = pwcsrtombs(mOut, &pwstr, 5, NULL);
2351 ok(ret == 4, "wcsrtombs did not return 4\n");
2352 ok(pwstr == NULL, "pwstr != NULL\n");
2353 ok(!memcmp(mOut, mSimple, sizeof(mSimple)), "mOut = %s\n", mOut);
2354
2355 if(!p_mbsrtowcs) {
2356 setlocale(LC_ALL, "C");
2357 win_skip("mbsrtowcs not available\n");
2358 return;
2359 }
2360
2361 pmbstr = mHiragana;
2362 ret = p_mbsrtowcs(NULL, &pmbstr, 6, NULL);
2363 ok(ret == 2, "mbsrtowcs did not return 2\n");
2364 ok(pmbstr == mHiragana, "pmbstr = %p, expected %p\n", pmbstr, mHiragana);
2365
2366 pmbstr = mHiragana;
2367 ret = p_mbsrtowcs(wOut, &pmbstr, 6, NULL);
2368 ok(ret == 2, "mbsrtowcs did not return 2\n");
2369 ok(!memcmp(wOut, wHiragana, sizeof(wHiragana)), "wOut = %s\n", wine_dbgstr_w(wOut));
2370 ok(!pmbstr, "pmbstr != NULL\n");
2371
2372 state = mHiragana[0];
2373 pmbstr = mHiragana+1;
2374 ret = p_mbsrtowcs(wOut, &pmbstr, 6, &state);
2375 ok(ret == 2, "mbsrtowcs did not return 2\n");
2376 ok(wOut[0] == 0x3042, "wOut[0] = %x\n", wOut[0]);
2377 ok(wOut[1] == 0xff61, "wOut[1] = %x\n", wOut[1]);
2378 ok(wOut[2] == 0, "wOut[2] = %x\n", wOut[2]);
2379 ok(!pmbstr, "pmbstr != NULL\n");
2380
2381 errno = EBADF;
2382 ret = p_mbsrtowcs(wOut, NULL, 6, &state);
2383 ok(ret == -1, "mbsrtowcs did not return -1\n");
2384 ok(errno == EINVAL, "Expected errno to be EINVAL, got %d\n", errno);
2385
2386 if(!p_mbsrtowcs_s) {
2387 setlocale(LC_ALL, "C");
2388 win_skip("mbsrtowcs_s not available\n");
2389 return;
2390 }
2391
2392 pmbstr = mHiragana;
2393 err = p_mbsrtowcs_s(&ret, NULL, 0, NULL, 6, NULL);
2394 ok(ret == -1, "mbsrtowcs_s did not return -1\n");
2395 ok(err == EINVAL, "err = %d\n", err);
2396 err = p_mbsrtowcs_s(&ret, NULL, 1, &pmbstr, 6, NULL);
2397 ok(ret == -1, "mbsrtowcs_s did not return -1\n");
2398 ok(err == EINVAL, "err = %d\n", err);
2399 err = p_mbsrtowcs_s(&ret, wOut, 0, &pmbstr, 6, NULL);
2400 ok(ret == -1, "mbsrtowcs_s did not return -1\n");
2401 ok(err == EINVAL, "err = %d\n", err);
2402
2403 pmbstr = mHiragana;
2404 errno = 0;
2405 err = p_mbsrtowcs_s(&ret, NULL, 0, &pmbstr, 6, NULL);
2406 ok(ret == 3, "mbsrtowcs_s did not return 3\n");
2407 ok(err == 0, "err = %d\n", err);
2408 ok(pmbstr == mHiragana, "pmbstr = %p, expected %p\n", pmbstr, mHiragana);
2409 ok(errno == 0, "errno = %d\n", errno);
2410
2411 pmbstr = mHiragana;
2412 err = p_mbsrtowcs_s(&ret, wOut, 1, &pmbstr, 6, NULL);
2413 ok(ret == 2, "mbsrtowcs_s did not return 2\n");
2414 ok(err == 0, "err = %d\n", err);
2415 ok(!wOut[0], "wOut[0] = '%c'\n", wOut[0]);
2416 ok(pmbstr == mHiragana+2, "pmbstr = %p, expected %p\n", pmbstr, mHiragana+2);
2417 ok(errno == 0, "errno = %d\n", errno);
2418
2419 pmbstr = mHiragana;
2420 err = p_mbsrtowcs_s(&ret, wOut, 2, &pmbstr, 6, NULL);
2421 ok(ret == 3, "mbsrtowcs_s did not return 3\n");
2422 ok(err == 0, "err = %d\n", err);
2423 ok(!wOut[0], "wOut[0] = '%c'\n", wOut[0]);
2424 ok(pmbstr == mHiragana+4, "pmbstr = %p, expected %p\n", pmbstr, mHiragana+4);
2425 ok(errno == 0, "errno = %d\n", errno);
2426
2427 pmbstr = mHiragana;
2428 err = p_mbsrtowcs_s(&ret, wOut, 3, &pmbstr, 6, NULL);
2429 ok(ret == 3, "mbsrtowcs_s did not return 3\n");
2430 ok(err == 0, "err = %d\n", err);
2431 ok(!pmbstr, "pmbstr != NULL\n");
2432 ok(errno == 0, "errno = %d\n", errno);
2433
2434 setlocale(LC_ALL, "C");
2435}
wcstombs
Definition: stdlib.h:1013

Referenced by START_TEST().

◆ test_memcpy_s()

static void test_memcpy_s ( void  )
static

Definition at line 880 of file string.c.

881{
882 static char dest[8], buf[32];
883 static const char tiny[] = {'T',0,'I','N','Y',0};
884 static const char big[] = {'a','t','o','o','l','o','n','g','s','t','r','i','n','g',0};
885 int ret;
886 if (!p_memcpy_s) {
887 win_skip("memcpy_s not found\n");
888 return;
889 }
890
891 /* Normal */
892 memset(dest, 'X', sizeof(dest));
893 ret = p_memcpy_s(dest, ARRAY_SIZE(dest), tiny, ARRAY_SIZE(tiny));
894 ok(ret == 0, "Copying a buffer into a big enough destination returned %d, expected 0\n", ret);
895 okchars(dest, tiny[0], tiny[1], tiny[2], tiny[3], tiny[4], tiny[5], 'X', 'X');
896
897 /* Vary source size */
898 errno = 0xdeadbeef;
899 memset(dest, 'X', sizeof(dest));
900 ret = p_memcpy_s(dest, ARRAY_SIZE(dest), big, ARRAY_SIZE(big));
901 ok(ret == ERANGE, "Copying a big buffer to a small destination returned %d, expected ERANGE\n", ret);
902 ok(errno == ERANGE, "errno is %d, expected ERANGE\n", errno);
903 okchars(dest, 0, 0, 0, 0, 0, 0, 0, 0);
904
905 /* Replace source with NULL */
906 errno = 0xdeadbeef;
907 memset(dest, 'X', sizeof(dest));
908 ret = p_memcpy_s(dest, ARRAY_SIZE(dest), NULL, ARRAY_SIZE(tiny));
909 ok(ret == EINVAL, "Copying a NULL source buffer returned %d, expected EINVAL\n", ret);
910 ok(errno == EINVAL, "errno is %d, expected EINVAL\n", errno);
911 okchars(dest, 0, 0, 0, 0, 0, 0, 0, 0);
912
913 /* Vary dest size */
914 errno = 0xdeadbeef;
915 memset(dest, 'X', sizeof(dest));
916 ret = p_memcpy_s(dest, 0, tiny, ARRAY_SIZE(tiny));
917 ok(ret == ERANGE, "Copying into a destination of size 0 returned %d, expected ERANGE\n", ret);
918 ok(errno == ERANGE, "errno is %d, expected ERANGE\n", errno);
919 okchars(dest, 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X');
920
921 /* Replace dest with NULL */
922 errno = 0xdeadbeef;
923 ret = p_memcpy_s(NULL, ARRAY_SIZE(dest), tiny, ARRAY_SIZE(tiny));
924 ok(ret == EINVAL, "Copying a tiny buffer to a big NULL destination returned %d, expected EINVAL\n", ret);
925 ok(errno == EINVAL, "errno is %d, expected EINVAL\n", errno);
926
927 /* Combinations */
928 errno = 0xdeadbeef;
929 memset(dest, 'X', sizeof(dest));
930 ret = p_memcpy_s(dest, 0, NULL, ARRAY_SIZE(tiny));
931 ok(ret == EINVAL, "Copying a NULL buffer into a destination of size 0 returned %d, expected EINVAL\n", ret);
932 ok(errno == EINVAL, "errno is %d, expected EINVAL\n", errno);
933 okchars(dest, 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X');
934
935 ret = p_memcpy_s(buf, ARRAY_SIZE(buf), big, ARRAY_SIZE(big));
936 ok(!ret, "memcpy_s returned %d\n", ret);
937 ok(!memcmp(buf, big, sizeof(big)), "unexpected buf\n");
938
939 ret = p_memcpy_s(buf + 1, ARRAY_SIZE(buf) - 1, buf, ARRAY_SIZE(big));
940 ok(!ret, "memcpy_s returned %d\n", ret);
941 ok(!memcmp(buf + 1, big, sizeof(big)), "unexpected buf\n");
942
943 ret = p_memcpy_s(buf, ARRAY_SIZE(buf), buf + 1, ARRAY_SIZE(big));
944 ok(!ret, "memcpy_s returned %d\n", ret);
945 ok(!memcmp(buf, big, sizeof(big)), "unexpected buf\n");
946}
#define okchars(dst, b0, b1, b2, b3, b4, b5, b6, b7)
Definition: string.c:874

Referenced by START_TEST().

◆ test_memmove_s()

static void test_memmove_s ( void  )
static

Definition at line 948 of file string.c.

949{
950 static char dest[8];
951 static const char tiny[] = {'T',0,'I','N','Y',0};
952 static const char big[] = {'a','t','o','o','l','o','n','g','s','t','r','i','n','g',0};
953 int ret;
954 if (!p_memmove_s) {
955 win_skip("memmove_s not found\n");
956 return;
957 }
958
959 /* Normal */
960 memset(dest, 'X', sizeof(dest));
961 ret = p_memmove_s(dest, ARRAY_SIZE(dest), tiny, ARRAY_SIZE(tiny));
962 ok(ret == 0, "Moving a buffer into a big enough destination returned %d, expected 0\n", ret);
963 okchars(dest, tiny[0], tiny[1], tiny[2], tiny[3], tiny[4], tiny[5], 'X', 'X');
964
965 /* Overlapping */
966 memcpy(dest, big, sizeof(dest));
967 ret = p_memmove_s(dest+1, ARRAY_SIZE(dest)-1, dest, ARRAY_SIZE(dest)-1);
968 ok(ret == 0, "Moving a buffer up one char returned %d, expected 0\n", ret);
969 okchars(dest, big[0], big[0], big[1], big[2], big[3], big[4], big[5], big[6]);
970
971 /* Vary source size */
972 errno = 0xdeadbeef;
973 memset(dest, 'X', sizeof(dest));
974 ret = p_memmove_s(dest, ARRAY_SIZE(dest), big, ARRAY_SIZE(big));
975 ok(ret == ERANGE, "Moving a big buffer to a small destination returned %d, expected ERANGE\n", ret);
976 ok(errno == ERANGE, "errno is %d, expected ERANGE\n", errno);
977 okchars(dest, 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X');
978
979 /* Replace source with NULL */
980 errno = 0xdeadbeef;
981 memset(dest, 'X', sizeof(dest));
982 ret = p_memmove_s(dest, ARRAY_SIZE(dest), NULL, ARRAY_SIZE(tiny));
983 ok(ret == EINVAL, "Moving a NULL source buffer returned %d, expected EINVAL\n", ret);
984 ok(errno == EINVAL, "errno is %d, expected EINVAL\n", errno);
985 okchars(dest, 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X');
986
987 /* Vary dest size */
988 errno = 0xdeadbeef;
989 memset(dest, 'X', sizeof(dest));
990 ret = p_memmove_s(dest, 0, tiny, ARRAY_SIZE(tiny));
991 ok(ret == ERANGE, "Moving into a destination of size 0 returned %d, expected ERANGE\n", ret);
992 ok(errno == ERANGE, "errno is %d, expected ERANGE\n", errno);
993 okchars(dest, 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X');
994
995 /* Replace dest with NULL */
996 errno = 0xdeadbeef;
997 ret = p_memmove_s(NULL, ARRAY_SIZE(dest), tiny, ARRAY_SIZE(tiny));
998 ok(ret == EINVAL, "Moving a tiny buffer to a big NULL destination returned %d, expected EINVAL\n", ret);
999 ok(errno == EINVAL, "errno is %d, expected EINVAL\n", errno);
1000
1001 /* Combinations */
1002 errno = 0xdeadbeef;
1003 memset(dest, 'X', sizeof(dest));
1004 ret = p_memmove_s(dest, 0, NULL, ARRAY_SIZE(tiny));
1005 ok(ret == EINVAL, "Moving a NULL buffer into a destination of size 0 returned %d, expected EINVAL\n", ret);
1006 ok(errno == EINVAL, "errno is %d, expected EINVAL\n", errno);
1007 okchars(dest, 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X');
1008}

Referenced by START_TEST().

◆ test_SpecialCasing()

static void test_SpecialCasing ( void  )
static

Definition at line 4730 of file string.c.

4731{
4732 int i;
4733 wint_t ret, exp;
4735 struct test {
4736 const char *lang;
4737 wint_t ch;
4738 wint_t exp;
4739 };
4740
4741 struct test ucases[] = {
4742 {"English", 'I', 'i'}, /* LATIN CAPITAL LETTER I */
4743 {"English", 0x0130}, /* LATIN CAPITAL LETTER I WITH DOT ABOVE */
4744
4745 {"Turkish", 'I', 'i'}, /* LATIN CAPITAL LETTER I */
4746 {"Turkish", 0x0130}, /* LATIN CAPITAL LETTER I WITH DOT ABOVE */
4747 };
4748 struct test lcases[] = {
4749 {"English", 'i', 'I'}, /* LATIN SMALL LETTER I */
4750 {"English", 0x0131}, /* LATIN SMALL LETTER DOTLESS I */
4751
4752 {"Turkish", 'i', 'I'}, /* LATIN SMALL LETTER I */
4753 {"Turkish", 0x0131}, /* LATIN SMALL LETTER DOTLESS I */
4754 };
4755
4756 for (i = 0; i < ARRAY_SIZE(ucases); i++) {
4757 if (!setlocale(LC_ALL, ucases[i].lang)) {
4758 win_skip("skipping special case tests for %s\n", ucases[i].lang);
4759 continue;
4760 }
4761
4762 ret = p_towlower(ucases[i].ch);
4763 exp = ucases[i].exp ? ucases[i].exp : ucases[i].ch;
4764 ok(ret == exp, "expected lowercase %x, got %x for locale %s\n", exp, ret, ucases[i].lang);
4765 }
4766
4767 for (i = 0; i < ARRAY_SIZE(lcases); i++) {
4768 if (!setlocale(LC_ALL, lcases[i].lang)) {
4769 win_skip("skipping special case tests for %s\n", lcases[i].lang);
4770 continue;
4771 }
4772
4773 ret = p_towupper(lcases[i].ch);
4774 exp = lcases[i].exp ? lcases[i].exp : lcases[i].ch;
4775 ok(ret == exp, "expected uppercase %x, got %x for locale %s\n", exp, ret, lcases[i].lang);
4776 }
4777
4778 setlocale(LC_ALL, "C");
4779
4780 if (!p__towlower_l || !p__towupper_l || !p__create_locale)
4781 {
4782 win_skip("_towlower_l/_towupper_l/_create_locale not available\n");
4783 return;
4784 }
4785
4786 /* test _towlower_l creating locale */
4787 for (i = 0; i < ARRAY_SIZE(ucases); i++) {
4788 if (!(locale = p__create_locale(LC_ALL, ucases[i].lang))) {
4789 win_skip("locale %s not available. skipping\n", ucases[i].lang);
4790 continue;
4791 }
4792
4793 ret = p__towlower_l(ucases[i].ch, locale);
4794 exp = ucases[i].exp ? ucases[i].exp : ucases[i].ch;
4795 ok(ret == exp, "expected lowercase %x, got %x for locale %s\n", exp, ret, ucases[i].lang);
4796
4797 p__free_locale(locale);
4798 }
4799
4800 /* test _towupper_l creating locale */
4801 for (i = 0; i < ARRAY_SIZE(lcases); i++) {
4802 if (!(locale = p__create_locale(LC_ALL, lcases[i].lang))) {
4803 win_skip("locale %s not available. skipping\n", lcases[i].lang);
4804 continue;
4805 }
4806
4807 ret = p__towupper_l(lcases[i].ch, locale);
4808 exp = lcases[i].exp ? lcases[i].exp : lcases[i].ch;
4809 ok(ret == exp, "expected uppercase %x, got %x for locale %s\n", exp, ret, lcases[i].lang);
4810
4811 p__free_locale(locale);
4812 }
4813}
static const WCHAR lang[]
Definition: wbemdisp.c:287

Referenced by START_TEST().

◆ test_strcat_s()

static void test_strcat_s ( void  )
static

Definition at line 1010 of file string.c.

1011{
1012 char dest[8];
1013 const char *small = "sma";
1014 int ret;
1015
1016 if(!pstrcat_s)
1017 {
1018 win_skip("strcat_s not found\n");
1019 return;
1020 }
1021
1022 memset(dest, 'X', sizeof(dest));
1023 dest[0] = '\0';
1024 ret = pstrcat_s(dest, sizeof(dest), small);
1025 ok(ret == 0, "strcat_s: Copying a string into a big enough destination returned %d, expected 0\n", ret);
1026 ok(dest[0] == 's' && dest[1] == 'm' && dest[2] == 'a' && dest[3] == '\0'&&
1027 dest[4] == 'X' && dest[5] == 'X' && dest[6] == 'X' && dest[7] == 'X',
1028 "Unexpected return data from strcpy_s: 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x\n",
1029 dest[0], dest[1], dest[2], dest[3], dest[4], dest[5], dest[6], dest[7]);
1030 ret = pstrcat_s(dest, sizeof(dest), small);
1031 ok(ret == 0, "strcat_s: Attaching a string to a big enough destination returned %d, expected 0\n", ret);
1032 ok(dest[0] == 's' && dest[1] == 'm' && dest[2] == 'a' && dest[3] == 's' &&
1033 dest[4] == 'm' && dest[5] == 'a' && dest[6] == '\0'&& dest[7] == 'X',
1034 "Unexpected return data from strcpy_s: 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x\n",
1035 dest[0], dest[1], dest[2], dest[3], dest[4], dest[5], dest[6], dest[7]);
1036
1037 ret = pstrcat_s(dest, sizeof(dest), small);
1038 ok(ret == ERANGE, "strcat_s: Attaching a string to a filled up destination returned %d, expected ERANGE\n", ret);
1039 ok(dest[0] == '\0'&& dest[1] == 'm' && dest[2] == 'a' && dest[3] == 's' &&
1040 dest[4] == 'm' && dest[5] == 'a' && dest[6] == 's' && dest[7] == 'm',
1041 "Unexpected return data from strcpy_s: 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x\n",
1042 dest[0], dest[1], dest[2], dest[3], dest[4], dest[5], dest[6], dest[7]);
1043
1044 memset(dest, 'X', sizeof(dest));
1045 dest[0] = 'a';
1046 dest[1] = '\0';
1047
1048 ret = pstrcat_s(dest, 0, small);
1049 ok(ret == EINVAL, "strcat_s: Source len = 0 returned %d, expected EINVAL\n", ret);
1050 ok(dest[0] == 'a' && dest[1] == '\0'&& dest[2] == 'X' && dest[3] == 'X' &&
1051 dest[4] == 'X' && dest[5] == 'X' && dest[6] == 'X' && dest[7] == 'X',
1052 "Unexpected return data from strcpy_s: 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x\n",
1053 dest[0], dest[1], dest[2], dest[3], dest[4], dest[5], dest[6], dest[7]);
1054
1055 ret = pstrcat_s(dest, 0, NULL);
1056 ok(ret == EINVAL, "strcat_s: len = 0 and src = NULL returned %d, expected EINVAL\n", ret);
1057 ok(dest[0] == 'a' && dest[1] == '\0'&& dest[2] == 'X' && dest[3] == 'X' &&
1058 dest[4] == 'X' && dest[5] == 'X' && dest[6] == 'X' && dest[7] == 'X',
1059 "Unexpected return data from strcpy_s: 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x\n",
1060 dest[0], dest[1], dest[2], dest[3], dest[4], dest[5], dest[6], dest[7]);
1061
1062 ret = pstrcat_s(dest, sizeof(dest), NULL);
1063 ok(ret == EINVAL, "strcat_s: Sourcing from NULL returned %d, expected EINVAL\n", ret);
1064 ok(dest[0] == '\0'&& dest[1] == '\0'&& dest[2] == 'X' && dest[3] == 'X' &&
1065 dest[4] == 'X' && dest[5] == 'X' && dest[6] == 'X' && dest[7] == 'X',
1066 "Unexpected return data from strcpy_s: 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x\n",
1067 dest[0], dest[1], dest[2], dest[3], dest[4], dest[5], dest[6], dest[7]);
1068
1069 ret = pstrcat_s(NULL, sizeof(dest), small);
1070 ok(ret == EINVAL, "strcat_s: Writing to a NULL string returned %d, expected EINVAL\n", ret);
1071}

Referenced by START_TEST().

◆ test_strcmp()

static void test_strcmp ( void  )
static

Definition at line 719 of file string.c.

720{
721 int ret = p_strcmp( "abc", "abcd" );
722 ok( ret == -1, "wrong ret %d\n", ret );
723 ret = p_strcmp( "", "abc" );
724 ok( ret == -1, "wrong ret %d\n", ret );
725 ret = p_strcmp( "abc", "ab\xa0" );
726 ok( ret == -1, "wrong ret %d\n", ret );
727 ret = p_strcmp( "ab\xb0", "ab\xa0" );
728 ok( ret == 1, "wrong ret %d\n", ret );
729 ret = p_strcmp( "ab\xc2", "ab\xc2" );
730 ok( ret == 0, "wrong ret %d\n", ret );
731
732 ret = p_strncmp( "abc", "abcd", 3 );
733 ok( ret == 0, "wrong ret %d\n", ret );
735#ifdef _WIN64
736 ret = p_strncmp( "", "abc", 3 );
737 ok( ret == -1, "wrong ret %d\n", ret );
738 ret = p_strncmp( "abc", "ab\xa0", 4 );
739 ok( ret == -1, "wrong ret %d\n", ret );
740 ret = p_strncmp( "ab\xb0", "ab\xa0", 3 );
741 ok( ret == 1, "wrong ret %d\n", ret );
742#else
743 ret = p_strncmp( "", "abc", 3 );
744 ok( ret == 0 - 'a', "wrong ret %d\n", ret );
745 ret = p_strncmp( "abc", "ab\xa0", 4 );
746 ok( ret == 'c' - 0xa0, "wrong ret %d\n", ret );
747 ret = p_strncmp( "ab\xb0", "ab\xa0", 3 );
748 ok( ret == 0xb0 - 0xa0, "wrong ret %d\n", ret );
749#endif
750 }
751 ret = p_strncmp( "ab\xb0", "ab\xa0", 2 );
752 ok( ret == 0, "wrong ret %d\n", ret );
753 ret = p_strncmp( "ab\xc2", "ab\xc2", 3 );
754 ok( ret == 0, "wrong ret %d\n", ret );
755 ret = p_strncmp( "abc", "abd", 0 );
756 ok( ret == 0, "wrong ret %d\n", ret );
757 ret = p_strncmp( "abc", "abc", 12 );
758 ok( ret == 0, "wrong ret %d\n", ret );
759}

Referenced by START_TEST().

◆ test_strcpy_s()

static void test_strcpy_s ( void  )
static

Definition at line 761 of file string.c.

762{
763 char dest[8];
764 const char small[] = "small";
765 const char big[] = "atoolongstringforthislittledestination";
766 int ret;
767
768 if(!pstrcpy_s)
769 {
770 win_skip("strcpy_s not found\n");
771 return;
772 }
773
774 memset(dest, 'X', sizeof(dest));
775 ret = pstrcpy_s(dest, sizeof(dest), small);
776 ok(ret == 0, "Copying a string into a big enough destination returned %d, expected 0\n", ret);
777 ok(dest[0] == 's' && dest[1] == 'm' && dest[2] == 'a' && dest[3] == 'l' &&
778 dest[4] == 'l' && dest[5] == '\0'&& dest[6] == 'X' && dest[7] == 'X',
779 "Unexpected return data from strcpy_s: 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x\n",
780 dest[0], dest[1], dest[2], dest[3], dest[4], dest[5], dest[6], dest[7]);
781
782 memset(dest, 'X', sizeof(dest));
783 ret = pstrcpy_s(dest, 0, big);
784 ok(ret == EINVAL, "Copying into a destination of size 0 returned %d, expected EINVAL\n", ret);
785 ok(dest[0] == 'X' && dest[1] == 'X' && dest[2] == 'X' && dest[3] == 'X' &&
786 dest[4] == 'X' && dest[5] == 'X' && dest[6] == 'X' && dest[7] == 'X',
787 "Unexpected return data from strcpy_s: 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x\n",
788 dest[0], dest[1], dest[2], dest[3], dest[4], dest[5], dest[6], dest[7]);
789 ret = pstrcpy_s(dest, 0, NULL);
790 ok(ret == EINVAL, "Copying into a destination of size 0 returned %d, expected EINVAL\n", ret);
791 ok(dest[0] == 'X' && dest[1] == 'X' && dest[2] == 'X' && dest[3] == 'X' &&
792 dest[4] == 'X' && dest[5] == 'X' && dest[6] == 'X' && dest[7] == 'X',
793 "Unexpected return data from strcpy_s: 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x\n",
794 dest[0], dest[1], dest[2], dest[3], dest[4], dest[5], dest[6], dest[7]);
795
796 memset(dest, 'X', sizeof(dest));
797 ret = pstrcpy_s(dest, sizeof(dest), big);
798 ok(ret == ERANGE, "Copying a big string in a small location returned %d, expected ERANGE\n", ret);
799 ok(dest[0] == '\0'&& dest[1] == 't' && dest[2] == 'o' && dest[3] == 'o' &&
800 dest[4] == 'l' && dest[5] == 'o' && dest[6] == 'n' && dest[7] == 'g',
801 "Unexpected return data from strcpy_s: 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x\n",
802 dest[0], dest[1], dest[2], dest[3], dest[4], dest[5], dest[6], dest[7]);
803
804 memset(dest, 'X', sizeof(dest));
805 ret = pstrcpy_s(dest, sizeof(dest), NULL);
806 ok(ret == EINVAL, "Copying from a NULL source string returned %d, expected EINVAL\n", ret);
807 ok(dest[0] == '\0'&& dest[1] == 'X' && dest[2] == 'X' && dest[3] == 'X' &&
808 dest[4] == 'X' && dest[5] == 'X' && dest[6] == 'X' && dest[7] == 'X',
809 "Unexpected return data from strcpy_s: 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x\n",
810 dest[0], dest[1], dest[2], dest[3], dest[4], dest[5], dest[6], dest[7]);
811
812 ret = pstrcpy_s(NULL, sizeof(dest), small);
813 ok(ret == EINVAL, "Copying a big string a NULL dest returned %d, expected EINVAL\n", ret);
814
815 /* strcpy overlapping buffers test */
816 memset(dest, 'X', sizeof(dest));
817 memcpy(dest+1, small, sizeof(small));
818 p_strcpy(dest, dest+1);
819 ok(dest[0] == 's' && dest[1] == 'm' && dest[2] == 'a' && dest[3] == 'l' &&
820 dest[4] == 'l' && dest[5] == '\0' && dest[6] == '\0' && dest[7] == 'X',
821 "Unexpected return data from strcpy: 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x\n",
822 dest[0], dest[1], dest[2], dest[3], dest[4], dest[5], dest[6], dest[7]);
823
824 if(!p_strncpy_s)
825 {
826 win_skip("strncpy_s not found\n");
827 return;
828 }
829
830 ret = p_strncpy_s(NULL, 18, big, ARRAY_SIZE(big));
831 ok(ret == EINVAL, "p_strncpy_s expect EINVAL got %d\n", ret);
832
833 dest[0] = 'A';
834 ret = p_strncpy_s(dest, 8, NULL, 1);
835 ok(ret == EINVAL, "expected EINVAL got %d\n", ret);
836 ok(dest[0] == 0, "dest[0] not 0\n");
837
838 dest[0] = 'A';
839 ret = p_strncpy_s(dest, 8, NULL, 0);
840 ok(ret == 0, "expected ERROR_SUCCESS got %d\n", ret);
841 ok(dest[0] == 0, "dest[0] not 0\n");
842
843 dest[0] = 'A';
844 ret = p_strncpy_s(dest, 0, big, ARRAY_SIZE(big));
845 ok(ret == ERANGE || ret == EINVAL, "expected ERANGE/EINVAL got %d\n", ret);
846 ok(dest[0] == 0 || ret == EINVAL, "dest[0] not 0\n");
847
848 ret = p_strncpy_s(dest, 8, small, ARRAY_SIZE(small));
849 ok(ret == 0, "expected 0 got %d\n", ret);
850 ok(!strcmp(dest, small), "dest != small\n");
851
852 dest[0] = 'A';
853 ret = p_strncpy_s(dest, 8, big, ARRAY_SIZE(big));
854 ok(ret == ERANGE || ret == EINVAL, "expected ERANGE/EINVAL got %d\n", ret);
855 ok(dest[0] == 0, "dest[0] not 0\n");
856
857 dest[0] = 'A';
858 ret = p_strncpy_s(dest, 5, big, -1);
859 ok(ret == STRUNCATE, "expected STRUNCATE got %d\n", ret);
860 ok(dest[4] == 0, "dest[4] not 0\n");
861 ok(!memcmp(dest, big, 4), "dest = %s\n", wine_dbgstr_a(dest));
862
863 ret = p_strncpy_s(NULL, 0, (void*)0xdeadbeef, 0);
864 ok(ret == 0, "ret = %d\n", ret);
865
866 dest[0] = '1';
867 dest[1] = 0;
868 ret = p_strncpy_s(dest+1, 4, dest, -1);
869 ok(ret == STRUNCATE, "expected ERROR_SUCCESS got %d\n", ret);
870 ok(dest[0]=='1' && dest[1]=='1' && dest[2]=='1' && dest[3]=='1',
871 "dest = %s\n", wine_dbgstr_a(dest));
872}

Referenced by START_TEST().

◆ test_strcspn()

static void test_strcspn ( void  )
static

Definition at line 180 of file string.c.

181{
182 static const struct {
183 const char *str;
184 const char *rej;
185 int ret;
186 } tests[] = {
187 { "test", "a", 4 },
188 { "test", "e", 1 },
189 { "test", "", 4 },
190 { "", "a", 0 },
191 { "a\xf1", "\xf1", 1 }
192 };
193 int r, i;
194
195 for (i = 0; i < ARRAY_SIZE(tests); i++)
196 {
197 r = strcspn(tests[i].str, tests[i].rej);
198 ok(r == tests[i].ret, "strcspn(\"%s\", \"%s\") = %d, expected %d\n",
199 tests[i].str, tests[i].rej, r, tests[i].ret);
200 }
201}
_Check_return_ _CRTIMP size_t __cdecl strcspn(_In_z_ const char *_Str, _In_z_ const char *_Control)

Referenced by START_TEST().

◆ test_strdup()

static void test_strdup ( void  )
static

Definition at line 701 of file string.c.

702{
703 char *str;
704 errno = 0xdeadbeef;
705 str = strdup(0);
706 ok(str == 0, "strdup returned %s, expected NULL\n", wine_dbgstr_a(str));
707 ok(errno == 0xdeadbeef, "errno is %d, expected 0xdeadbeef\n", errno);
708}
_Check_return_ _CRTIMP char *__cdecl strdup(_In_opt_z_ const char *_Src)

Referenced by START_TEST().

◆ test_strncat_s()

static void test_strncat_s ( void  )
static

Definition at line 2694 of file string.c.

2695{
2696 int ret;
2697 char dst[4];
2698 char src[4];
2699
2700 if (!p_wcsncat_s)
2701 {
2702 win_skip("skipping wcsncat_s tests\n");
2703 return;
2704 }
2705
2706 strcpy(src, "abc");
2707 strcpy(dst, "a");
2708 ret = p_strncat_s(NULL, 4, src, 4);
2709 ok(ret == EINVAL, "err = %d\n", ret);
2710 ret = p_strncat_s(dst, 0, src, 4);
2711 ok(ret == EINVAL, "err = %d\n", ret);
2712 ok(dst[0] == 'a', "dst %x\n", dst[0]);
2713 ret = p_strncat_s(dst, 0, src, _TRUNCATE);
2714 ok(ret == EINVAL, "err = %d\n", ret);
2715 ret = p_strncat_s(dst, 4, NULL, 1);
2716 ok(ret == EINVAL, "err = %d\n", ret);
2717 ok(!dst[0], "dst %x\n", dst[0]);
2718 ret = p_strncat_s(NULL, 4, src, 0);
2719 ok(ret == EINVAL, "err = %d\n", ret);
2720 strcpy(dst, "a");
2721 ret = p_strncat_s(dst, 4, NULL, 0);
2722 ok(ret == 0, "err = %d\n", ret);
2723 ok(dst[0] == 'a', "dst %x\n", dst[0]);
2724
2725 dst[0] = 0;
2726 ret = p_strncat_s(dst, 2, src, 4);
2727 ok(ret == ERANGE, "err = %d\n", ret);
2728
2729 dst[0] = 0;
2730 ret = p_strncat_s(dst, 2, src, _TRUNCATE);
2731 ok(ret == STRUNCATE, "err = %d\n", ret);
2732 ok(dst[0] == 'a' && dst[1] == 0, "dst is %s\n", wine_dbgstr_a(dst));
2733
2734 strcpy(dst, "abc");
2735 dst[3] = 'd';
2736 ret = p_strncat_s(dst, 4, src, 4);
2737 ok(ret == EINVAL, "err = %d\n", ret);
2738 ok(!dst[0], "dst %x\n", dst[0]);
2739}

Referenced by START_TEST().

◆ test_strncpy()

static void test_strncpy ( void  )
static

Definition at line 3820 of file string.c.

3821{
3822#define TEST_STRNCPY_LEN 10
3823 /* use function pointer to bypass gcc builtin */
3824 char *(__cdecl *p_strncpy)(char*,const char*,size_t);
3825 char *ret;
3826 char dst[TEST_STRNCPY_LEN + 1];
3827 char not_null_terminated[] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '0'};
3828
3829 p_strncpy = (void *)GetProcAddress( GetModuleHandleA("msvcrt.dll"), "strncpy");
3830
3831 /* strlen(src) > TEST_STRNCPY_LEN */
3832 ret = p_strncpy(dst, "01234567890123456789", TEST_STRNCPY_LEN);
3833 ok(ret == dst, "ret != dst\n");
3834 ok(!strncmp(dst, "0123456789", TEST_STRNCPY_LEN), "dst != 0123456789\n");
3835
3836 /* without null-terminated */
3837 ret = p_strncpy(dst, not_null_terminated, TEST_STRNCPY_LEN);
3838 ok(ret == dst, "ret != dst\n");
3839 ok(!strncmp(dst, "0123456789", TEST_STRNCPY_LEN), "dst != 0123456789\n");
3840
3841 /* strlen(src) < TEST_STRNCPY_LEN */
3842 strcpy(dst, "0123456789");
3843 ret = p_strncpy(dst, "012345", TEST_STRNCPY_LEN);
3844 ok(ret == dst, "ret != dst\n");
3845 ok(!strcmp(dst, "012345"), "dst != 012345\n");
3846 ok(dst[TEST_STRNCPY_LEN - 1] == '\0', "dst[TEST_STRNCPY_LEN - 1] != 0\n");
3847
3848 /* strlen(src) == TEST_STRNCPY_LEN */
3849 ret = p_strncpy(dst, "0123456789", TEST_STRNCPY_LEN);
3850 ok(ret == dst, "ret != dst\n");
3851 ok(!strncmp(dst, "0123456789", TEST_STRNCPY_LEN), "dst != 0123456789\n");
3852}
int strncmp(const char *String1, const char *String2, ACPI_SIZE Count)
Definition: utclib.c:534
#define __cdecl
Definition: accygwin.h:79
#define TEST_STRNCPY_LEN

Referenced by START_TEST().

◆ test_strnlen()

static void test_strnlen ( void  )
static

Definition at line 1897 of file string.c.

1898{
1899 static const char str[] = "string";
1900 size_t res;
1901
1902 if(!p_strnlen) {
1903 win_skip("strnlen not found\n");
1904 return;
1905 }
1906
1907 res = p_strnlen(str, 20);
1908 ok(res == 6, "Returned length = %d\n", (int)res);
1909
1910 res = p_strnlen(str, 3);
1911 ok(res == 3, "Returned length = %d\n", (int)res);
1912
1913 res = p_strnlen(NULL, 0);
1914 ok(res == 0, "Returned length = %d\n", (int)res);
1915}

Referenced by START_TEST().

◆ test_strstr()

static void test_strstr ( void  )
static

Definition at line 4604 of file string.c.

4605{
4606 static char long_str[1024];
4607 const struct {
4608 const char *haystack;
4609 const char *needle;
4610 int off;
4611 } tests[] = {
4612 { "", "", 0 },
4613 { "", "a", -1 },
4614 { "a", "", 0 },
4615 { "aabc", "abc", 1 },
4616 { "aaaa", "aaaa", 0 },
4617 { "simple", "simple", 0 },
4618 { "aaaaxaaaaxaaaa", "aaaaa", -1 },
4619 { "aaaaxaaaaxaaaaa", "aaaaa", 10 },
4620 { "abcabcdababcdabcdabde", "abcdabd", 13 },
4621 { "abababababcabababcababbba", "abababcaba", 4 },
4622 { long_str, long_str+1, 0 }
4623 };
4624 const char *r, *exp;
4625 int i;
4626
4627 memset(long_str, 'a', sizeof(long_str)-1);
4628
4629 for (i=0; i<ARRAY_SIZE(tests); i++)
4630 {
4631 r = strstr(tests[i].haystack, tests[i].needle);
4632 exp = tests[i].off == -1 ? NULL : tests[i].haystack + tests[i].off;
4633 ok(r == exp, "%d) strstr returned %p, expected %p\n", i, r, exp);
4634 }
4635}
char * strstr(char *String1, char *String2)
Definition: utclib.c:653
static const char haystack[]
Definition: editor.c:190

Referenced by START_TEST().

◆ test_strtok()

static void test_strtok ( void  )
static

Definition at line 1794 of file string.c.

1795{
1796 int i;
1797 char *strret;
1798 char teststr[100];
1799 for( i = 0; testcases_strtok[i].string; i++){
1800 strcpy( teststr, testcases_strtok[i].string);
1801 strret = strtok( teststr, testcases_strtok[i].delimiter);
1802 ok( (int)(strret - teststr) == testcases_strtok[i].exp_offsetret1 ||
1803 (!strret && testcases_strtok[i].exp_offsetret1 == -1),
1804 "string (%p) \'%s\' return %p\n",
1805 teststr, testcases_strtok[i].string, strret);
1806 if( !strret) continue;
1807 strret = strtok( NULL, testcases_strtok[i].delimiter);
1808 ok( (int)(strret - teststr) == testcases_strtok[i].exp_offsetret2 ||
1809 (!strret && testcases_strtok[i].exp_offsetret2 == -1),
1810 "second call string (%p) \'%s\' return %p\n",
1811 teststr, testcases_strtok[i].string, strret);
1812 if( !strret) continue;
1813 strret = strtok( NULL, testcases_strtok[i].delimiter);
1814 ok( (int)(strret - teststr) == testcases_strtok[i].exp_offsetret3 ||
1815 (!strret && testcases_strtok[i].exp_offsetret3 == -1),
1816 "third call string (%p) \'%s\' return %p\n",
1817 teststr, testcases_strtok[i].string, strret);
1818 }
1819
1820 strcpy( teststr, "test a=b" );
1821 strret = strtok( teststr, " " );
1822 ok( strret == teststr, "strret = %p, expected %p\n", strret, teststr );
1823 strret = strtok( NULL, "ab=" );
1824 ok( !strret, "strret = %p, expected NULL\n", strret );
1825 strret = strtok( NULL, "=" );
1826 ok( !strret, "strret = %p, expected NULL\n", strret );
1827}
int exp_offsetret1
Definition: string.c:1780
int exp_offsetret3
Definition: string.c:1784
static const struct @1816 testcases_strtok[]
const char * delimiter
Definition: string.c:1779
int exp_offsetret2
Definition: string.c:1782

Referenced by START_TEST().

◆ test_strtol()

static void test_strtol ( void  )
static

Definition at line 1829 of file string.c.

1830{
1831 static char neg[] = "-0x";
1832
1833 char* e;
1834 LONG l;
1835 ULONG ul;
1836
1837 /* errno is only set in case of error, so reset errno to EBADF to check for errno modification */
1838 /* errno is modified on W2K8+ */
1839 errno = EBADF;
1840 l = strtol("-1234", &e, 0);
1841 ok(l==-1234, "wrong value %ld\n", l);
1842 ok(errno == EBADF || broken(errno == 0), "wrong errno %d\n", errno);
1843 errno = EBADF;
1844 ul = strtoul("1234", &e, 0);
1845 ok(ul==1234, "wrong value %lu\n", ul);
1846 ok(errno == EBADF || broken(errno == 0), "wrong errno %d\n", errno);
1847
1848 errno = EBADF;
1849 l = strtol("2147483647L", &e, 0);
1850 ok(l==2147483647, "wrong value %ld\n", l);
1851 ok(errno == EBADF || broken(errno == 0), "wrong errno %d\n", errno);
1852 errno = EBADF;
1853 l = strtol("-2147483648L", &e, 0);
1854 ok(l==-2147483647L - 1, "wrong value %ld\n", l);
1855 ok(errno == EBADF || broken(errno == 0), "wrong errno %d\n", errno);
1856 errno = EBADF;
1857 ul = strtoul("4294967295UL", &e, 0);
1858 ok(ul==4294967295ul, "wrong value %lu\n", ul);
1859 ok(errno == EBADF || broken(errno == 0), "wrong errno %d\n", errno);
1860
1861 errno = 0;
1862 l = strtol("9223372036854775807L", &e, 0);
1863 ok(l==2147483647, "wrong value %ld\n", l);
1864 ok(errno == ERANGE, "wrong errno %d\n", errno);
1865 errno = 0;
1866 ul = strtoul("9223372036854775807L", &e, 0);
1867 ok(ul==4294967295ul, "wrong value %lu\n", ul);
1868 ok(errno == ERANGE, "wrong errno %d\n", errno);
1869
1870 errno = 0;
1871 ul = strtoul("-2", NULL, 0);
1872 ok(ul == -2, "wrong value %lu\n", ul);
1873 ok(errno == 0, "wrong errno %d\n", errno);
1874
1875 errno = 0;
1876 ul = strtoul("-4294967294", NULL, 0);
1877 ok(ul == 2, "wrong value %lu\n", ul);
1878 ok(errno == 0, "wrong errno %d\n", errno);
1879
1880 errno = 0;
1881 ul = strtoul("-4294967295", NULL, 0);
1882 ok(ul==1, "wrong value %lu\n", ul);
1883 ok(errno == 0, "wrong errno %d\n", errno);
1884
1885 errno = 0;
1886 ul = strtoul("-4294967296", NULL, 0);
1887 ok(ul == 1, "wrong value %lu\n", ul);
1888 ok(errno == ERANGE, "wrong errno %d\n", errno);
1889
1890 errno = 0;
1891 l = strtol(neg, &e, 0);
1892 ok(l == 0, "wrong value %ld\n", l);
1893 ok(errno == 0, "wrong errno %d\n", errno);
1894 ok(e == neg, "e = %p, neg = %p\n", e, neg);
1895}
UINT32 strtoul(const char *String, char **Terminator, UINT32 Base)
Definition: utclib.c:696
r l[0]
Definition: byte_order.h:168
long LONG
Definition: pedump.c:60
_Check_return_ long __cdecl strtol(_In_z_ const char *_Str, _Out_opt_ _Deref_post_z_ char **_EndPtr, _In_ int _Radix)
uint32_t ULONG
Definition: typedefs.h:59

Referenced by START_TEST().

◆ test_strxfrm()

static void test_strxfrm ( void  )
static

Definition at line 3854 of file string.c.

3855{
3856 char dest[256];
3857 size_t ret;
3858
3859 /* crashes on old version of msvcrt */
3860 if(p__atodbl_l) {
3861 errno = 0xdeadbeef;
3862 ret = strxfrm(NULL, "src", 1);
3863 ok(ret == INT_MAX, "ret = %d\n", (int)ret);
3864 ok(errno == EINVAL, "errno = %d\n", errno);
3865
3866 errno = 0xdeadbeef;
3867 ret = strxfrm(dest, NULL, 100);
3868 ok(ret == INT_MAX, "ret = %d\n", (int)ret);
3869 ok(errno == EINVAL, "errno = %d\n", errno);
3870 }
3871
3872 ret = strxfrm(NULL, "src", 0);
3873 ok(ret == 3, "ret = %d\n", (int)ret);
3874 dest[0] = 'a';
3875 ret = strxfrm(dest, "src", 0);
3876 ok(ret == 3, "ret = %d\n", (int)ret);
3877 ok(dest[0] == 'a', "dest[0] = %d\n", dest[0]);
3878
3879 dest[3] = 'a';
3880 ret = strxfrm(dest, "src", 5);
3881 ok(ret == 3, "ret = %d\n", (int)ret);
3882 ok(!strcmp(dest, "src"), "dest = %s\n", dest);
3883
3884 errno = 0xdeadbeef;
3885 dest[1] = 'a';
3886 ret = strxfrm(dest, "src", 1);
3887 ok(ret == 3, "ret = %d\n", (int)ret);
3888 ok(dest[0] == 's', "dest[0] = %d\n", dest[0]);
3889 ok(dest[1] == 'a', "dest[1] = %d\n", dest[1]);
3890 ok(errno == 0xdeadbeef, "errno = %d\n", errno);
3891
3892 ret = strxfrm(dest, "", 5);
3893 ok(ret == 0, "ret = %d\n", (int)ret);
3894 ok(!dest[0], "dest[0] = %d\n", dest[0]);
3895
3896 if(!setlocale(LC_ALL, "polish")) {
3897 win_skip("stxfrm tests\n");
3898 return;
3899 }
3900
3901 ret = strxfrm(NULL, "src", 0);
3902 ok(ret < sizeof(dest)-1, "ret = %d\n", (int)ret);
3903 dest[0] = 'a';
3904 ret = strxfrm(dest, "src", 0);
3905 ok(ret < sizeof(dest)-1, "ret = %d\n", (int)ret);
3906 ok(dest[0] == 'a', "dest[0] = %d\n", dest[0]);
3907
3908 ret = strxfrm(dest, "src", ret+1);
3909 ok(ret < sizeof(dest)-1, "ret = %d\n", (int)ret);
3910 ok(dest[0], "dest[0] = 0\n");
3911
3912 errno = 0xdeadbeef;
3913 dest[0] = 'a';
3914 ret = strxfrm(dest, "src", 5);
3915 ok(ret>5 && ret<sizeof(dest)-1, "ret = %d\n", (int)ret);
3916 ok(!dest[0] || broken(!p__atodbl_l && dest[0]=='a'), "dest[0] = %d\n", dest[0]);
3917
3918 setlocale(LC_ALL, "C");
3919}
_Check_return_opt_ _CRTIMP size_t __cdecl strxfrm(_Out_writes_opt_(_MaxCount) _Post_maybez_ char *_Dst, _In_z_ const char *_Src, _In_ size_t _MaxCount)

Referenced by START_TEST().

◆ test_swab()

static void test_swab ( void  )
static

Definition at line 136 of file string.c.

136 {
137 char original[] = "BADCFEHGJILKNMPORQTSVUXWZY@#";
138 char expected1[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ@#";
139 char expected2[] = "ABCDEFGHIJKLMNOPQRSTUVWX$";
140 char expected3[] = "$";
141
142 char from[30];
143 char to[30];
144
145 int testsize;
146
147 /* Test 1 - normal even case */
148 memset(to,'$', sizeof(to));
149 memset(from,'@', sizeof(from));
150 testsize = 26;
151 memcpy(from, original, testsize);
152 _swab( from, to, testsize );
153 ok(memcmp(to,expected1,testsize) == 0, "Testing even size %d returned '%*.*s'\n", testsize, testsize, testsize, to);
154
155 /* Test 2 - uneven case */
156 memset(to,'$', sizeof(to));
157 memset(from,'@', sizeof(from));
158 testsize = 25;
159 memcpy(from, original, testsize);
160 _swab( from, to, testsize );
161 ok(memcmp(to,expected2,testsize) == 0, "Testing odd size %d returned '%*.*s'\n", testsize, testsize, testsize, to);
162
163 /* Test 3 - from = to */
164 memset(to,'$', sizeof(to));
165 memset(from,'@', sizeof(from));
166 testsize = 26;
167 memcpy(to, original, testsize);
168 _swab( to, to, testsize );
169 ok(memcmp(to,expected1,testsize) == 0, "Testing overlapped size %d returned '%*.*s'\n", testsize, testsize, testsize, to);
170
171 /* Test 4 - 1 bytes */
172 memset(to,'$', sizeof(to));
173 memset(from,'@', sizeof(from));
174 testsize = 1;
175 memcpy(from, original, testsize);
176 _swab( from, to, testsize );
177 ok(memcmp(to,expected3,testsize) == 0, "Testing small size %d returned '%*.*s'\n", testsize, testsize, testsize, to);
178}
_CRTIMP void __cdecl _swab(_Inout_updates_(_SizeInBytes) _Post_readable_size_(_SizeInBytes) char *_Buf1, _Inout_updates_(_SizeInBytes) _Post_readable_size_(_SizeInBytes) char *_Buf2, int _SizeInBytes)
CardRegion * from
Definition: spigame.cpp:19

Referenced by START_TEST().

◆ test_tolower()

static void test_tolower ( void  )
static

Definition at line 3333 of file string.c.

3334{
3335 WCHAR chw, lower;
3336 char ch, lch;
3337 int ret, len;
3338
3339 /* test C locale when locale was never changed */
3340 ret = p_tolower(0x41);
3341 ok(ret == 0x61, "ret = %x\n", ret);
3342
3343 ret = p_tolower(0xF4);
3344 ok(ret == 0xF4, "ret = %x\n", ret);
3345
3346 errno = 0xdeadbeef;
3347 ret = p_tolower((char)0xF4);
3348 ok(ret == (char)0xF4, "ret = %x\n", ret);
3349 ok(errno == 0xdeadbeef, "errno = %d\n", errno);
3350
3351 errno = 0xdeadbeef;
3352 ret = p_tolower((char)0xD0);
3353 ok(ret == (char)0xD0, "ret = %x\n", ret);
3354 ok(errno == 0xdeadbeef, "errno = %d\n", errno);
3355
3356 setlocale(LC_ALL, "C");
3357 errno = 0xdeadbeef;
3358 ret = p_tolower((char)0xF4);
3359 ok(ret == (char)0xF4, "ret = %x\n", ret);
3360 ok(errno == 0xdeadbeef, "errno = %d\n", errno);
3361
3362 /* test C locale after setting locale */
3363 if(!setlocale(LC_ALL, "us")) {
3364 win_skip("skipping tolower tests that depends on locale\n");
3365 return;
3366 }
3367 setlocale(LC_ALL, "C");
3368
3369 ch = 0xF4;
3370 errno = 0xdeadbeef;
3371 ret = p_tolower((signed char)ch);
3372 if(!MultiByteToWideChar(CP_ACP, MB_ERR_INVALID_CHARS, &ch, 1, &chw, 1) ||
3373 LCMapStringW(CP_ACP, LCMAP_LOWERCASE, &chw, 1, &lower, 1) != 1 ||
3374 (len = WideCharToMultiByte(CP_ACP, 0, &lower, 1, &lch, 1, NULL, NULL)) != 1)
3375 len = 0;
3376 if(len)
3377 ok(ret==(unsigned char)lch || broken(ret==ch)/*WinXP-*/, "ret = %x\n", ret);
3378 else
3379 ok(ret == ch, "ret = %x\n", ret);
3380 if(!len || ret==(unsigned char)lch)
3381 ok(errno == EILSEQ, "errno = %d\n", errno);
3382
3383 ch = 0xD0;
3384 errno = 0xdeadbeef;
3385 ret = p_tolower((signed char)ch);
3386 if(!MultiByteToWideChar(CP_ACP, MB_ERR_INVALID_CHARS, &ch, 1, &chw, 1) ||
3387 LCMapStringW(CP_ACP, LCMAP_LOWERCASE, &chw, 1, &lower, 1) != 1 ||
3388 (len = WideCharToMultiByte(CP_ACP, 0, &lower, 1, &lch, 1, NULL, NULL)) != 1)
3389 len = 0;
3390 if(len)
3391 ok(ret==(unsigned char)lch || broken(ret==ch)/*WinXP-*/, "ret = %x\n", ret);
3392 else
3393 ok(ret == ch, "ret = %x\n", ret);
3394 if(!len || ret==(unsigned char)lch)
3395 ok(errno == EILSEQ, "errno = %d\n", errno);
3396
3397 ret = p_tolower((unsigned char)0xD0);
3398 ok(ret == 0xD0, "ret = %x\n", ret);
3399
3400 ok(setlocale(LC_ALL, "us") != NULL, "setlocale failed\n");
3401
3402 ret = p_tolower((signed char)0xD0);
3403 ok(ret == 0xF0, "ret = %x\n", ret);
3404
3405 ret = p_tolower((unsigned char)0xD0);
3406 ok(ret == 0xF0, "ret = %x\n", ret);
3407
3409 ok(setlocale(LC_ALL, "Japanese_Japan.932") != NULL, "setlocale failed.\n");
3410 errno = 0xdeadbeef;
3411 ret = p_tolower((signed char)0xd0);
3412 ok(ret == 0xd0, "Got %#x.\n", ret);
3413 ok(errno == EILSEQ, "Got errno %d.\n", errno);
3414 errno = 0xdeadbeef;
3415 ret = p_tolower(0xd0);
3416 ok(ret == 0xd0, "Got %#x.\n", ret);
3417 ok(errno == 0xdeadbeef, "Got errno %d.\n", errno);
3418
3419 ok(setlocale(LC_ALL, "Chinese_China.936") != NULL, "setlocale failed.\n");
3420 errno = 0xdeadbeef;
3421 ret = p_tolower((signed char)0xd0);
3422 ok(ret == (signed char)0xd0, "Got %#x.\n", ret);
3423 ok(errno == EILSEQ, "Got errno %d.\n", errno);
3424 errno = 0xdeadbeef;
3425 ret = p_tolower(0xd0);
3426 ok(ret == 0xd0, "Got %#x.\n", ret);
3427 ok(errno == 0xdeadbeef, "Got errno %d.\n", errno);
3428
3429 ok(setlocale(LC_ALL, "Korean_Korea.949") != NULL, "setlocale failed.\n");
3430 errno = 0xdeadbeef;
3431 ret = p_tolower((signed char)0xd0);
3432 ok(ret == (signed char)0xd0, "Got %#x.\n", ret);
3433 ok(errno == EILSEQ, "Got errno %d.\n", errno);
3434 errno = 0xdeadbeef;
3435 ret = p_tolower(0xd0);
3436 ok(ret == 0xd0, "Got %#x.\n", ret);
3437 ok(errno == 0xdeadbeef, "Got errno %d.\n", errno);
3438
3439 ok(setlocale(LC_ALL, "Chinese_Taiwan.950") != NULL, "setlocale failed.\n");
3440 errno = 0xdeadbeef;
3441 ret = p_tolower((signed char)0xd0);
3442 ok(ret == (signed char)0xd0, "Got %#x.\n", ret);
3443 ok(errno == EILSEQ, "Got errno %d.\n", errno);
3444 errno = 0xdeadbeef;
3445 ret = p_tolower(0xd0);
3446 ok(ret == 0xd0, "Got %#x.\n", ret);
3447 ok(errno == 0xdeadbeef, "Got errno %d.\n", errno);
3448 }
3449
3450 setlocale(LC_ALL, "C");
3451}
#define CP_ACP
Definition: compat.h:109
#define WideCharToMultiByte
Definition: compat.h:111
#define MultiByteToWideChar
Definition: compat.h:110
INT WINAPI LCMapStringW(LCID lcid, DWORD flags, LPCWSTR src, INT srclen, LPWSTR dst, INT dstlen)
Definition: locale.c:3808
#define MB_ERR_INVALID_CHARS
Definition: unicode.h:41
#define LCMAP_LOWERCASE
Definition: winnls.h:197

Referenced by START_TEST().

◆ test_toupper()

static void test_toupper ( void  )
static

Definition at line 5005 of file string.c.

5006{
5007 int ret;
5008
5009 ok(setlocale(LC_ALL, "English_United States") != NULL, "setlocale failed.\n");
5010 errno = 0xdeadbeef;
5011 ret = p_toupper((signed char)0xf0);
5012 ok(ret == 0xd0, "Got %#x.\n", ret);
5013 skip_2k3_fail ok(errno == EILSEQ, "Got errno %d.\n", errno);
5014 errno = 0xdeadbeef;
5015 ret = p_toupper(0xf0);
5016 ok(ret == 0xd0, "Got %#x.\n", ret);
5017 ok(errno == 0xdeadbeef, "Got errno %d.\n", errno);
5018
5019 ok(setlocale(LC_ALL, "Polish") != NULL, "setlocale failed.\n");
5020 errno = 0xdeadbeef;
5021 ret = p_toupper((signed char)0xa5);
5022 ok(ret == 0xa5, "Got %#x.\n", ret);
5023 skip_2k3_fail ok(errno == EILSEQ, "Got errno %d.\n", errno);
5024 errno = 0xdeadbeef;
5025 ret = p_toupper((signed char)0xb9);
5026 ok(ret == 0xa5, "Got %#x.\n", ret);
5027 skip_2k3_fail ok(errno == EILSEQ, "Got errno %d.\n", errno);
5028
5030 ok(setlocale(LC_ALL, "Japanese_Japan.932") != NULL, "setlocale failed.\n");
5031 errno = 0xdeadbeef;
5032 ret = p_toupper((signed char)0xf0);
5033 ok(ret == (signed char)0xf0, "Got %#x.\n", ret);
5034 ok(errno == EILSEQ, "Got errno %d.\n", errno);
5035 errno = 0xdeadbeef;
5036 ret = p_toupper(0xf0);
5037 ok(ret == 0xf0, "Got %#x.\n", ret);
5038 ok(errno == 0xdeadbeef, "Got errno %d.\n", errno);
5039
5040 ok(setlocale(LC_ALL, "Chinese_China.936") != NULL, "setlocale failed.\n");
5041 errno = 0xdeadbeef;
5042 ret = p_toupper((signed char)0xf0);
5043 ok(ret == (signed char)0xf0, "Got %#x.\n", ret);
5044 ok(errno == EILSEQ, "Got errno %d.\n", errno);
5045 errno = 0xdeadbeef;
5046 ret = p_toupper(0xf0);
5047 ok(ret == 0xf0, "Got %#x.\n", ret);
5048 ok(errno == 0xdeadbeef, "Got errno %d.\n", errno);
5049 }
5050
5051 setlocale(LC_ALL, "C");
5052}

Referenced by START_TEST().

◆ test_wcscmp()

static void test_wcscmp ( void  )
static

Definition at line 4659 of file string.c.

4660{
4661 int r;
4662
4663 r = wcscmp(L"a", L"z");
4664 ok(r == -1, "wcscmp returned %d\n", r);
4665
4666 r = wcscmp(L"z", L"a");
4667 ok(r == 1, "wcscmp returned %d\n", r);
4668
4669 r = wcscmp(L"f", L"f");
4670 ok(!r, "wcscmp returned %d\n", r);
4671}

Referenced by START_TEST().

◆ test_wcscpy_s()

static void test_wcscpy_s ( void  )
static

Definition at line 1236 of file string.c.

1237{
1238 static const WCHAR szLongText[] = L"ThisALongstring";
1239 static WCHAR szDest[18];
1240 static WCHAR szDestShort[8];
1241 int ret;
1242
1243 if(!p_wcscpy_s)
1244 {
1245 win_skip("wcscpy_s not found\n");
1246 return;
1247 }
1248
1249 /* Test NULL Dest */
1250 errno = EBADF;
1251 ret = p_wcscpy_s(NULL, 18, szLongText);
1252 ok(ret == EINVAL, "p_wcscpy_s expect EINVAL got %d\n", ret);
1253 ok(errno == EINVAL, "expected errno EINVAL got %d\n", errno);
1254
1255 /* Test NULL Source */
1256 errno = EBADF;
1257 szDest[0] = 'A';
1258 ret = p_wcscpy_s(szDest, 18, NULL);
1259 ok(ret == EINVAL, "expected EINVAL got %d\n", ret);
1260 ok(errno == EINVAL, "expected errno EINVAL got %d\n", errno);
1261 ok(szDest[0] == 0, "szDest[0] not 0, got %c\n", szDest[0]);
1262
1263 /* Test invalid size */
1264 errno = EBADF;
1265 szDest[0] = 'A';
1266 ret = p_wcscpy_s(szDest, 0, szLongText);
1267 /* Later versions changed the return value for this case to EINVAL,
1268 * and don't modify the result if the dest size is 0.
1269 */
1270 ok(ret == ERANGE || ret == EINVAL, "expected ERANGE/EINVAL got %d\n", ret);
1271 ok(errno == ERANGE || errno == EINVAL, "expected errno ERANGE/EINVAL got %d\n", errno);
1272 ok(szDest[0] == 0 || ret == EINVAL, "szDest[0] not 0\n");
1273
1274 /* Copy same buffer size */
1275 ret = p_wcscpy_s(szDest, 18, szLongText);
1276 ok(ret == 0, "expected 0 got %d\n", ret);
1277 ok(lstrcmpW(szDest, szLongText) == 0, "szDest != szLongText\n");
1278
1279 /* dest == source */
1280 ret = p_wcscpy_s(szDest, 18, szDest);
1281 ok(ret == 0, "expected 0 got %d\n", ret);
1282 ok(lstrcmpW(szDest, szLongText) == 0, "szDest != szLongText\n");
1283
1284 /* Copy smaller buffer size */
1285 errno = EBADF;
1286 szDest[0] = 'A';
1287 ret = p_wcscpy_s(szDestShort, 8, szLongText);
1288 ok(ret == ERANGE || ret == EINVAL, "expected ERANGE/EINVAL got %d\n", ret);
1289 ok(errno == ERANGE || errno == EINVAL, "expected errno ERANGE/EINVAL got %d\n", errno);
1290 ok(szDestShort[0] == 0, "szDestShort[0] not 0\n");
1291
1292 if(!p_wcsncpy_s)
1293 {
1294 win_skip("wcsncpy_s not found\n");
1295 return;
1296 }
1297
1298 ret = p_wcsncpy_s(NULL, 18, szLongText, ARRAY_SIZE(szLongText));
1299 ok(ret == EINVAL, "p_wcsncpy_s expect EINVAL got %d\n", ret);
1300
1301 szDest[0] = 'A';
1302 ret = p_wcsncpy_s(szDest, 18, NULL, 1);
1303 ok(ret == EINVAL, "expected EINVAL got %d\n", ret);
1304 ok(szDest[0] == 0, "szDest[0] not 0\n");
1305
1306 szDest[0] = 'A';
1307 ret = p_wcsncpy_s(szDest, 18, NULL, 0);
1308 ok(ret == 0, "expected ERROR_SUCCESS got %d\n", ret);
1309 ok(szDest[0] == 0, "szDest[0] not 0\n");
1310
1311 szDest[0] = 'A';
1312 ret = p_wcsncpy_s(szDest, 0, szLongText, ARRAY_SIZE(szLongText));
1313 ok(ret == ERANGE || ret == EINVAL, "expected ERANGE/EINVAL got %d\n", ret);
1314 ok(szDest[0] == 0 || ret == EINVAL, "szDest[0] not 0\n");
1315
1316 ret = p_wcsncpy_s(szDest, 18, szLongText, ARRAY_SIZE(szLongText));
1317 ok(ret == 0, "expected 0 got %d\n", ret);
1318 ok(lstrcmpW(szDest, szLongText) == 0, "szDest != szLongText\n");
1319
1320 szDest[0] = 'A';
1321 ret = p_wcsncpy_s(szDestShort, 8, szLongText, ARRAY_SIZE(szLongText));
1322 ok(ret == ERANGE || ret == EINVAL, "expected ERANGE/EINVAL got %d\n", ret);
1323 ok(szDestShort[0] == 0, "szDestShort[0] not 0\n");
1324
1325 szDest[0] = 'A';
1326 ret = p_wcsncpy_s(szDest, 5, szLongText, -1);
1327 ok(ret == STRUNCATE, "expected STRUNCATE got %d\n", ret);
1328 ok(szDest[4] == 0, "szDest[4] not 0\n");
1329 ok(!memcmp(szDest, szLongText, 4*sizeof(WCHAR)), "szDest = %s\n", wine_dbgstr_w(szDest));
1330
1331 ret = p_wcsncpy_s(NULL, 0, (void*)0xdeadbeef, 0);
1332 ok(ret == 0, "ret = %d\n", ret);
1333
1334 szDestShort[0] = '1';
1335 szDestShort[1] = 0;
1336 ret = p_wcsncpy_s(szDestShort+1, 4, szDestShort, -1);
1337 ok(ret == STRUNCATE, "expected ERROR_SUCCESS got %d\n", ret);
1338 ok(szDestShort[0]=='1' && szDestShort[1]=='1' && szDestShort[2]=='1' && szDestShort[3]=='1',
1339 "szDestShort = %s\n", wine_dbgstr_w(szDestShort));
1340}
int WINAPI lstrcmpW(LPCWSTR str1, LPCWSTR str2)
Definition: string.c:66

Referenced by START_TEST().

◆ test_wcsdup()

static void test_wcsdup ( void  )
static

Definition at line 710 of file string.c.

711{
712 WCHAR *str;
713 errno = 0xdeadbeef;
714 str = wcsdup(0);
715 ok(str == 0, "wcsdup returned %s, expected NULL\n", wine_dbgstr_w(str));
716 ok(errno == 0xdeadbeef, "errno is %d, expected 0xdeadbeef\n", errno);
717}
_Check_return_ _CRTIMP wchar_t *__cdecl wcsdup(_In_z_ const wchar_t *_Str)

Referenced by START_TEST().

◆ test_wcsncat_s()

static void test_wcsncat_s ( void  )
static

Definition at line 2741 of file string.c.

2742{
2743 int ret;
2744 wchar_t dst[4];
2745 wchar_t src[4];
2746
2747 if (!p_wcsncat_s)
2748 {
2749 win_skip("skipping wcsncat_s tests\n");
2750 return;
2751 }
2752
2753 wcscpy(src, L"abc");
2754 wcscpy(dst, L"a");
2755 ret = p_wcsncat_s(NULL, 4, src, 4);
2756 ok(ret == EINVAL, "err = %d\n", ret);
2757 ret = p_wcsncat_s(dst, 0, src, 4);
2758 ok(ret == EINVAL, "err = %d\n", ret);
2759 ok(dst[0] == 'a', "dst %x\n", dst[0]);
2760 ret = p_wcsncat_s(dst, 0, src, _TRUNCATE);
2761 ok(ret == EINVAL, "err = %d\n", ret);
2762 ok(dst[0] == 'a', "dst %x\n", dst[0]);
2763 ret = p_wcsncat_s(dst, 4, NULL, 1);
2764 ok(ret == EINVAL, "err = %d\n", ret);
2765 ok(!dst[0], "dst %x\n", dst[0]);
2766 ret = p_wcsncat_s(NULL, 4, src, 0);
2767 ok(ret == EINVAL, "err = %d\n", ret);
2768 wcscpy(dst, L"a");
2769 ret = p_wcsncat_s(dst, 4, NULL, 0);
2770 ok(ret == 0, "err = %d\n", ret);
2771 ok(dst[0] == 'a', "dst %x\n", dst[0]);
2772
2773 dst[0] = 0;
2774 ret = p_wcsncat_s(dst, 2, src, 4);
2775 ok(ret == ERANGE, "err = %d\n", ret);
2776
2777 dst[0] = 0;
2778 ret = p_wcsncat_s(dst, 2, src, _TRUNCATE);
2779 ok(ret == STRUNCATE, "err = %d\n", ret);
2780 ok(dst[0] == 'a' && dst[1] == 0, "dst is %s\n", wine_dbgstr_w(dst));
2781
2782 wcscpy(dst, L"abc");
2783 dst[3] = 'd';
2784 ret = p_wcsncat_s(dst, 4, src, 4);
2785 ok(ret == EINVAL, "err = %d\n", ret);
2786 ok(!dst[0], "dst %x\n", dst[0]);
2787}

Referenced by START_TEST().

◆ test_wcsncpy()

static void test_wcsncpy ( void  )
static

Definition at line 4868 of file string.c.

4869{
4870 wchar_t dst[6], *p;
4871
4872 memset(dst, 0xff, sizeof(dst));
4873 p = wcsncpy(dst, L"1234567", 6);
4874 ok(p == dst, "Unexpected return value.\n");
4875 ok(!memcmp(dst, L"123456", sizeof(dst)), "unexpected buffer %s\n",
4877}
wcsncpy
#define wine_dbgstr_wn
Definition: testlist.c:2

Referenced by START_TEST().

◆ test_wctob()

static void test_wctob ( void  )
static

Definition at line 3142 of file string.c.

3143{
3144 int ret, cp = _getmbcp();
3145
3146 if(!p_wctob || !setlocale(LC_ALL, "chinese-traditional")) {
3147 win_skip("Skipping wctob tests\n");
3148 return;
3149 }
3150
3151 ret = p_wctob(0x8141);
3152 ok(ret == EOF, "ret = %x\n", ret);
3153
3154 ret = p_wctob(0x81);
3155 ok(ret == EOF, "ret = %x\n", ret);
3156
3157 ret = p_wctob(0xe0);
3158 ok(ret == 0x61, "ret = %x\n", ret);
3159
3160 _setmbcp(1250);
3161 ret = p_wctob(0x81);
3162 ok(ret == EOF, "ret = %x\n", ret);
3163
3164 setlocale(LC_ALL, "C");
3165 ret = p_wctob(0x8141);
3166 ok(ret == EOF, "ret = %x\n", ret);
3167
3168 ret = p_wctob(0x81);
3169 ok(ret == (signed char)0x81, "ret = %x\n", ret);
3170
3171 ret = p_wctob(0x9f);
3172 ok(ret == (signed char)0x9f, "ret = %x\n", ret);
3173
3174 ret = p_wctob(0xe0);
3175 ok(ret == (signed char)0xe0, "ret = %x\n", ret);
3176
3177 _setmbcp(cp);
3178}

Referenced by START_TEST().

◆ test_wctomb()

static void test_wctomb ( void  )
static

Definition at line 3256 of file string.c.

3257{
3259 unsigned char dst[10];
3260 size_t ret;
3261 int err;
3262
3263 if(!p_wcrtomb || !setlocale(LC_ALL, "Japanese_Japan.932")) {
3264 win_skip("wcrtomb tests\n");
3265 return;
3266 }
3267
3268 ret = p_wcrtomb(NULL, 0x3042, NULL);
3269 ok(ret == 2, "wcrtomb did not return 2\n");
3270
3271 state = 1;
3272 dst[2] = 'a';
3273 ret = p_wcrtomb((char*)dst, 0x3042, &state);
3274 ok(ret == 2, "wcrtomb did not return 2\n");
3275 ok(state == 0, "state != 0\n");
3276 ok(dst[0] == 0x82, "dst[0] = %x, expected 0x82\n", dst[0]);
3277 ok(dst[1] == 0xa0, "dst[1] = %x, expected 0xa0\n", dst[1]);
3278 ok(dst[2] == 'a', "dst[2] != 'a'\n");
3279
3280 ret = p_wcrtomb((char*)dst, 0x3043, NULL);
3281 ok(ret == 2, "wcrtomb did not return 2\n");
3282 ok(dst[0] == 0x82, "dst[0] = %x, expected 0x82\n", dst[0]);
3283 ok(dst[1] == 0xa1, "dst[1] = %x, expected 0xa1\n", dst[1]);
3284
3285 ret = p_wcrtomb((char*)dst, 0x20, NULL);
3286 ok(ret == 1, "wcrtomb did not return 1\n");
3287 ok(dst[0] == 0x20, "dst[0] = %x, expected 0x20\n", dst[0]);
3288
3289 ret = p_wcrtomb((char*)dst, 0xffff, NULL);
3290 ok(ret == -1, "wcrtomb did not return -1\n");
3291 ok(dst[0] == 0x3f, "dst[0] = %x, expected 0x3f\n", dst[0]);
3292
3293 if(!p_wcrtomb_s) {
3294 win_skip("wcrtomb_s tests\n");
3295 setlocale(LC_ALL, "C");
3296 return;
3297 }
3298
3299 state = 1;
3300 dst[2] = 'a';
3301 err = p_wcrtomb_s(&ret, (char*)dst, sizeof(dst), 0x3042, &state);
3302 ok(!err, "err = %d\n", err);
3303 ok(ret == 2, "ret != 2\n");
3304 ok(!state, "state != 0\n");
3305 ok(dst[0] == 0x82, "dst[0] = %x, expected 0x82\n", dst[0]);
3306 ok(dst[1] == 0xa0, "dst[1] = %x, expected 0xa0\n", dst[1]);
3307 ok(dst[2] == 'a', "dst[2] != 'a'\n");
3308
3309 err = p_wcrtomb_s(&ret, (char*)dst, sizeof(dst), 0x3042, NULL);
3310 ok(!err, "err = %d\n", err);
3311 ok(ret == 2, "ret != 2\n");
3312 ok(!state, "state != 0\n");
3313 ok(dst[0] == 0x82, "dst[0] = %x, expected 0x82\n", dst[0]);
3314 ok(dst[1] == 0xa0, "dst[1] = %x, expected 0xa0\n", dst[1]);
3315
3316 err = p_wcrtomb_s(&ret, (char*)dst, sizeof(dst), 0x20, NULL);
3317 ok(!err, "err = %d\n", err);
3318 ok(ret == 1, "ret != 1\n");
3319 ok(dst[0] == 0x20, "dst[0] = %x, expected 0x20\n", dst[0]);
3320
3321 err = p_wcrtomb_s(&ret, NULL, 0, 0x20, NULL);
3322 ok(!err, "err = %d\n", err);
3323 ok(ret == 1, "ret != 1\n");
3324
3325 err = p_wcrtomb_s(&ret, (char*)dst, sizeof(dst), 0xffff, NULL);
3326 ok(err == EILSEQ, "err = %d\n", err);
3327 ok(ret == -1, "wcrtomb did not return -1\n");
3328 ok(dst[0] == 0x3f, "dst[0] = %x, expected 0x3f\n", dst[0]);
3329
3330 setlocale(LC_ALL, "C");
3331}

Referenced by START_TEST().

◆ void()

static const char *static void ( __cdecl p__free_locale)
static

◆ wint_t()

static wint_t ( __cdecl p_btowc)
static

Variable Documentation

◆ _locale_t

Definition at line 86 of file string.c.

◆ count

Definition at line 70 of file string.c.

◆ delimiter

◆ double

static double

Definition at line 91 of file string.c.

Referenced by __ieee754_jn(), __ieee754_yn(), _TIFFUInt64ToDouble(), _TIFFUInt64ToFloat(), _VarR8FromCy(), _vsnprintf(), AboutDlgProc(), AviMuxIn_Receive(), AVISplitter_Receive(), basetype_arg_size(), c2sx(), c2sy(), CalibrateTest(), CardLib_SetZoomSpeed(), ceil(), check_entropy(), ComplexMarshall(), ComplexUnmarshall(), convert_real_integer(), DECLARE_INTERFACE_(), DSOUND_RecalcVolPan(), Timer::elapsedMilliseconds(), EmbeddedComplexSize(), EMF_Update_MF_Xform(), EnumEnhMetaFile(), FileSize(), FillBuffer(), floor(), FTPUpdateIOTimer(), GetSystemInformation(), guiProgress(), halve1Dimage_uint(), halveImage3D(), halveImage_uint(), halveImageSlice(), hash_table_destroy(), INTERNAL_YDSTOWS(), interp_preinc(), is_int32(), ldexp(), MIDI_ConvertPulseToMS(), MMSYSTEM_MidiStream_Convert(), mpg123_framelength(), mpg123_par(), mpg123_position(), mpg123_tpf(), NdrBaseTypeMemorySize(), operator<<(), QMyMainWindow::paintEvent(), PCM_round(), PerfDataRefresh(), PerformSampleRateConversion(), PRINTDLG_PagePaintProc(), __crt_stdio_input::input_processor< Character, InputAdapter >::process_floating_point_specifier(), PropVariantToDouble(), PrStatBar(), QualityControlRender_DoQOS(), rand_xorshift32(), redraw(), remainder(), remainderf(), ReportTimes(), RGBtoHLS(), RoundTo3Digits(), rpn_and_f(), rpn_ave(), rpn_ave2(), rpn_fact(), rpn_not(), rpn_or_f(), rpn_s_ex(), rpn_xor_f(), SelectSetInit(), Defragment::Start(), START_TEST(), stat_sum2(), StrFormatByteSizeW(), test_GetConsoleFontInfo(), test_iface_wrapping(), test_marshal_LPSAFEARRAY(), test_math_errors(), test_ScCountProps(), Test_SyscallPerformance(), test_UlPropSize(), TIFFDefaultTransferFunction(), TIFFFetchSubjectDistance(), TIFFReadDirEntryCheckedRational(), TIFFReadDirEntryCheckedSrational(), TIFFReadDirEntryDouble(), TIFFReadDirEntryDoubleArray(), __crt_stdio_input::to_floating_point_length(), to_int32(), TRIO_ARGS1(), trio_nan(), trio_pinf(), type_stack_size(), UlPropSize(), upload_stat_number(), VarAdd(), VarCyFromDec(), VarCyMulI8(), VarCyRound(), VARIANT_DataSize(), VarMul(), VarNeg(), VarR4FromCy(), VarR4FromDec(), VarR8FromDec(), wave_out_volume(), xsltFormatNumberConversion(), xsltNumberFormatAlpha(), xsltNumberFormatGetAnyLevel(), xsltNumberFormatGetMultipleLevel(), and CardRegion::ZoomCard().

◆ elem

static size_t elem

Definition at line 71 of file string.c.

Referenced by _doc_get_body(), _elem_attach_event(), _elem_detach_event(), _elem_get_scroll_height(), _elem_get_scroll_left(), _elem_get_scroll_top(), _elem_get_scroll_width(), _get_current_style(), _get_doc_elem(), _get_elem2_iface(), _get_elem3_iface(), _get_elem4_iface(), _get_elem_attr_node(), _get_elem_col_item_idx(), _get_elem_doc(), _get_elem_id(), _get_elem_iface(), _get_frame_content_window(), _insert_adjacent_elem(), _link_put_disabled(), _link_put_href(), _link_put_rel(), _link_put_rev(), _link_put_type(), _set_button_name(), _set_elem_dir(), _set_elem_language(), _set_iframe_height(), _set_iframe_width(), _set_object_name(), _test_anchor_hash(), _test_anchor_search(), _test_button_get_disabled(), _test_button_name(), _test_button_set_disabled(), _test_comment_attrs(), _test_create_elem(), _test_elem_all(), _test_elem_attr(), _test_elem_class(), _test_elem_client_rect(), _test_elem_client_size(), _test_elem_contains(), _test_elem_dir(), _test_elem_disabled(), _test_elem_filters(), _test_elem_get_parent(), _test_elem_getelembytag(), _test_elem_id(), _test_elem_innerhtml(), _test_elem_innertext(), _test_elem_istextedit(), _test_elem_language(), _test_elem_offset(), _test_elem_outerhtml(), _test_elem_put_id(), _test_elem_set_class(), _test_elem_set_innerhtml(), _test_elem_set_innertext(), _test_elem_set_outerhtml(), _test_elem_set_title(), _test_elem_source_index(), _test_elem_tag(), _test_elem_title(), _test_event_fromelem(), _test_event_toelem(), _test_framebase_name(), _test_framebase_put_name(), _test_framebase_src(), _test_iframe_height(), _test_iframe_width(), _test_img_complete(), _test_input_get_form(), _test_link_disabled(), _test_link_href(), _test_link_media(), _test_link_rel(), _test_link_rev(), _test_link_type(), _test_object_name(), _test_range_parent(), _test_readyState(), add_to_array(), attributeDeclDebug(), basic_style_test(), codeview_add_type_array(), XMLStorage::XMLNode::count(), create_all_list(), create_node(), debugstr_xml_elem(), dictionary_insert(), dns_resolve(), DPQ_DECL_DELETECB(), elem_string_attr_getter(), elem_string_attr_setter(), elem_vector_add(), XMLStorage::XMLNode::filter(), get_doc_elem_by_id(), get_dom_element(), get_elem_attr_value_by_dispid(), get_elem_by_id(), get_elem_clsid(), get_elem_source_index(), get_elem_style(), get_elem_window(), get_font_size(), get_src_param(), get_style_from_elem(), get_token(), grow_array(), HTMLAnchorElement_Create(), HTMLAreaElement_Create(), HTMLBodyElement_Create(), HTMLButtonElement_Create(), HTMLCommentElement_Create(), HTMLCurrentStyle_Create(), HTMLDocument3_getElementById(), HTMLDocument5_createComment(), HTMLDocument_createElement(), HTMLDocument_createStyleSheet(), HTMLDocument_get_activeElement(), HTMLDOMAttribute_Create(), HTMLElement2_insertAdjacentElement(), HTMLElement_Create(), HTMLEmbedElement_Create(), HTMLFormElement_Create(), HTMLFrameElement_Create(), HTMLGenericElement_Create(), HTMLHeadElement_Create(), HTMLIFrame_Create(), HTMLImageElementFactory_create(), HTMLImgElement_Create(), HTMLInputElement_Create(), HTMLLabelElement_Create(), HTMLLinkElement_Create(), HTMLMetaElement_Create(), HTMLObjectElement_Create(), HTMLOptionElement_Create(), HTMLScriptElement_Create(), HTMLSelectElement_Create(), HTMLStyle_Create(), HTMLStyleElement_Create(), HTMLTable_Create(), HTMLTable_insertRow(), HTMLTableCell_Create(), HTMLTableRow_Create(), HTMLTableRow_insertCell(), HTMLTextAreaElement_Create(), HTMLTitleElement_Create(), HTMLTxtRange_moveToElementText(), HTMLWindow_invoke(), iframe_onreadystatechange(), in_array(), XMLStorage::XPath::init(), is_elem_id(), is_elem_name(), is_elem_tag(), list_add_after(), list_add_before(), list_add_head(), list_add_tail(), list_next(), list_prev(), list_remove(), mqr_GetMetadataByName(), next_xml_elem(), parse_application_elem(), parse_assembly_elem(), parse_clr_class_elem(), parse_com_class_elem(), parse_compatibility_application_elem(), parse_compatibility_elem(), parse_dependency_elem(), parse_dependent_assembly_elem(), parse_description_elem(), parse_expect_end_elem(), parse_file_elem(), parse_manifest_buffer(), parse_requested_execution_level_elem(), parse_requested_privileges_elem(), parse_security_elem(), parse_settings_elem(), parse_trust_info_elem(), parse_unknown_elem(), parse_window_class_elem(), parse_windows_settings_elem(), put_inner_html(), read_xml_elem(), reader_clear_elements(), ReadStringNode(), remove_child_attr(), runtimestyle_test(), SearchCHM_Storage(), set_elem_style(), set_font_size(), show_context_menu(), si_compar(), sti_compar(), strcat_s(), strcpy_s(), test___std_type_info(), test_appendChild(), test_arg_conv(), test_attr(), test_attr_collection(), test_blocked(), test_button_elem(), test_create_body_range(), test_create_elems(), test_create_stylesheet(), test_createNode(), test_default_arg_conv(), test_defaults(), test_dispex(), test_doc_elem(), test_doc_load_from_path(), test_doscroll(), test_dynamic_properties(), test_elem_from_point(), test_elems(), test_elems2(), test_focus(), test_form_item(), test_frameset(), test_get_attributes(), test_get_set_attr(), test_get_tagName(), test_get_xml(), test_getAttribute(), test_getAttributeNode(), test_getElementsByTagName(), test_iface_wrapping(), test_iframe_elem(), test_imgload(), test_insert_adjacent_elems(), test_label_elem(), test_Load(), test_namedmap_newenum(), test_namespaces_basic(), test_namespaces_change(), test_object_elem(), test_onreadystatechange(), test_put_nodeTypedValue(), test_quirks_mode_offsetHeight(), test_setAttributeNode(), test_style_filters(), test_submit(), test_supporterrorinfo(), test_table_elem(), test_td_elem(), test_tr_elem(), test_tr_modify(), test_xmlns_attribute(), test_XPath(), wchar_comp(), wcscat_s(), wcsncat_s(), WindowDispEx_GetDispID(), write_array_element_type(), write_type_right(), xml_elem_cmp(), xmlAddAttributeDecl(), xmlFreeElement(), xmlFreeElementTableEntry(), xmlGetDtdAttrDesc(), xmlGetDtdQAttrDesc(), xmlIsID(), xmlIsRef(), xmlParseAttribute2(), xmlParseElementChildrenContentDeclPriv(), xmlParseElementMixedContentDecl(), xmlSAX2AttributeDecl(), xmlSAX2ElementDecl(), xsltAddStackElem(), xsltBuildVariable(), xsltCopyNamespace(), xsltCopyNamespaceListInternal(), xsltCopyStackElem(), xsltEvalGlobalVariable(), xsltEvalGlobalVariables(), xsltFreeStackElem(), xsltFreeStackElemList(), xsltGlobalVariableLookup(), xsltProcessUserParamInternal(), xsltRegisterGlobalVariable(), and xsltVariableLookup().

◆ exp_offsetret1

int exp_offsetret1

Definition at line 1780 of file string.c.

Referenced by test_strtok().

◆ exp_offsetret2

int exp_offsetret2

Definition at line 1782 of file string.c.

Referenced by test_strtok().

◆ exp_offsetret3

int exp_offsetret3

Definition at line 1784 of file string.c.

Referenced by test_strtok().

◆ hMsvcrt

HMODULE hMsvcrt
static

Definition at line 134 of file string.c.

Referenced by START_TEST(), and und_name().

◆ int

int

Definition at line 81 of file string.c.

Referenced by _test_strtod_str(), strtolW(), strtoulW(), and vsnprintfW().

◆ len

Definition at line 68 of file string.c.

◆ numberOfElements

static size_t numberOfElements

◆ p__mb_cur_max

int* p__mb_cur_max
static

Definition at line 95 of file string.c.

Referenced by START_TEST(), and test_mbcp().

◆ p_mbctype

unsigned char* p_mbctype
static

Definition at line 96 of file string.c.

Referenced by START_TEST(), test_cp_table(), and test_mbcp().

◆ result_cp_932_mbctype

int result_cp_932_mbctype[]
static
Initial value:
= { 0x0,65, 0x8,1, 0x18,26, 0x8,6, 0x28,26, 0x8,4,
0x0,1, 0x8,1, 0xc,31, 0x8,1, 0xa,5, 0x9,58, 0xc,29, 0,3 }

Definition at line 232 of file string.c.

◆ result_cp_936_mbctype

int result_cp_936_mbctype[]
static
Initial value:
= { 0x0,65, 0x8,1, 0x18,26, 0x8,6, 0x28,26, 0x8,6,
0xc,126, 0,1 }

Definition at line 234 of file string.c.

◆ result_cp_949_mbctype

int result_cp_949_mbctype[]
static
Initial value:
= { 0x0,66, 0x18,26, 0x8,6, 0x28,26, 0x8,6, 0xc,126,
0,1 }

Definition at line 236 of file string.c.

◆ result_cp_950_mbctype

int result_cp_950_mbctype[]
static
Initial value:
= { 0x0,65, 0x8,1, 0x18,26, 0x8,6, 0x28,26, 0x8,4,
0x0,2, 0x4,32, 0xc,94, 0,1 }

Definition at line 238 of file string.c.

◆ size

Definition at line 70 of file string.c.

◆ size_t

Definition at line 62 of file string.c.

◆ src

Definition at line 67 of file string.c.

◆ string

Definition at line 1778 of file string.c.

◆ 

const struct { ... } testcases_strtok[]
Initial value:
= {
{ "red cabernet", " ", 0, 4, -1 },
{ "sparkling white riesling", " ", 0, 10, 16 },
{ " pale cream sherry", "e ", 1, 6, 9 },
{ 0}
}

Referenced by test_strtok().

◆ wchar_t

Definition at line 102 of file string.c.

◆ wcSrc

static size_t const wchar_t * wcSrc

Definition at line 76 of file string.c.

Referenced by Sdbwcscpy(), wcscpy_s(), and wcsncpy_s().