ReactOS 0.4.16-dev-976-g18fc5a1
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 <versionhelpers.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 57 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 56 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 872 of file string.c.

◆ SET

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

Definition at line 130 of file string.c.

◆ SETNOFAIL

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

Definition at line 129 of file string.c.

◆ test_codepage

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

Definition at line 258 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 42 of file string.c.

43{
44 static char buf[2][1024];
45 char *w = buf[nr];
46 int i;
47
48 for (i = 0; i < len; i++)
49 {
50 sprintf(w, "%02x ", (unsigned char)bin[i]);
51 w += strlen(w);
52 }
53 return buf[nr];
54}
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 2060 of file string.c.

2061{
2062 ULONGLONG x = *(ULONGLONG *)&f;
2063 ULONGLONG y = *(ULONGLONG *)&g;
2064
2065 if (f < 0)
2066 x = ~x + 1;
2067 else
2068 x |= ((ULONGLONG)1)<<63;
2069 if (g < 0)
2070 y = ~y + 1;
2071 else
2072 y |= ((ULONGLONG)1)<<63;
2073
2074 return (x>y ? x-y : y-x) <= ulps;
2075}
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 4669 of file string.c.

4670{
4671 static char buf[2 * ARRAY_SIZE(v->ld) + 1];
4672 int i;
4673
4674 for(i=0; i<ARRAY_SIZE(v->ld); i++)
4675 {
4676 buf[2*i] = v->ld[i] / 16 + '0';
4677 if(buf[2*i] > '9') buf[2*i] -= 10 + '0' - 'a';
4678 buf[2*i+1] = v->ld[i] % 16 + '0';
4679 if(buf[2*i+1] > '9') buf[2*i+1] -= 10 + '0' - 'a';
4680 }
4681 buf[2 * ARRAY_SIZE(v->ld)] = 0;
4682 return buf;
4683}
#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 3451 of file string.c.

3452{
3454 BOOL negexp = (exp < 0);
3455 int fpcontrol;
3456 double ret;
3457
3458 if(negexp)
3459 exp = -exp;
3460 fpcontrol = _control87(0, 0);
3461 _control87(fpexcept, 0xffffffff);
3462 ret = pow(10.0, exp);
3463 ret = (negexp ? x/ret : x*ret);
3464 _control87(fpcontrol, 0xffffffff);
3465 return ret;
3466}
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
int ret

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 5050 of file string.c.

5051{
5052 char mem[100];
5053 static const char xilstring[]="c:/xilinx";
5054 int nLen;
5055
5056 hMsvcrt = GetModuleHandleA("msvcrt.dll");
5057 if (!hMsvcrt)
5058 hMsvcrt = GetModuleHandleA("msvcrtd.dll");
5059 ok(hMsvcrt != 0, "GetModuleHandleA failed\n");
5060 SET(pmemcpy,"memcpy");
5061 p_memcpy_s = (void*)GetProcAddress( hMsvcrt, "memcpy_s" );
5062 p_memmove_s = (void*)GetProcAddress( hMsvcrt, "memmove_s" );
5063 SET(pmemcmp,"memcmp");
5064 SET(p_mbctype,"_mbctype");
5065 SET(p__mb_cur_max,"__mb_cur_max");
5066 SET(p_strcpy, "strcpy");
5067 SET(p_strcmp, "strcmp");
5068 SET(p_strncmp, "strncmp");
5069 pstrcpy_s = (void *)GetProcAddress( hMsvcrt,"strcpy_s" );
5070 pstrcat_s = (void *)GetProcAddress( hMsvcrt,"strcat_s" );
5071 p_strncpy_s = (void *)GetProcAddress( hMsvcrt, "strncpy_s" );
5072 p_strncat_s = (void *)GetProcAddress( hMsvcrt, "strncat_s" );
5073 p_mbscat_s = (void*)GetProcAddress( hMsvcrt, "_mbscat_s" );
5074 p_mbsnbcat_s = (void *)GetProcAddress( hMsvcrt,"_mbsnbcat_s" );
5075 p_mbsnbcpy_s = (void *)GetProcAddress( hMsvcrt,"_mbsnbcpy_s" );
5076 p__mbscpy_s = (void *)GetProcAddress( hMsvcrt,"_mbscpy_s" );
5077 p_wcscpy_s = (void *)GetProcAddress( hMsvcrt,"wcscpy_s" );
5078 p_wcsncpy_s = (void *)GetProcAddress( hMsvcrt,"wcsncpy_s" );
5079 p_wcsncat_s = (void *)GetProcAddress( hMsvcrt,"wcsncat_s" );
5080 p_wcsupr_s = (void *)GetProcAddress( hMsvcrt,"_wcsupr_s" );
5081 p_strnlen = (void *)GetProcAddress( hMsvcrt,"strnlen" );
5082 p_strtoi64 = (void *)GetProcAddress(hMsvcrt, "_strtoi64");
5083 p_strtoui64 = (void *)GetProcAddress(hMsvcrt, "_strtoui64");
5084 p_wcstoi64 = (void *)GetProcAddress(hMsvcrt, "_wcstoi64");
5085 p_wcstoui64 = (void *)GetProcAddress(hMsvcrt, "_wcstoui64");
5086 pmbstowcs_s = (void *)GetProcAddress(hMsvcrt, "mbstowcs_s");
5087 pwcstombs_s = (void *)GetProcAddress(hMsvcrt, "wcstombs_s");
5088 p_wcstombs_s_l = (void *)GetProcAddress(hMsvcrt, "_wcstombs_s_l");
5089 pwcsrtombs = (void *)GetProcAddress(hMsvcrt, "wcsrtombs");
5090 p_gcvt_s = (void *)GetProcAddress(hMsvcrt, "_gcvt_s");
5091 p_itoa_s = (void *)GetProcAddress(hMsvcrt, "_itoa_s");
5092 p_strlwr_s = (void *)GetProcAddress(hMsvcrt, "_strlwr_s");
5093 p_ultoa_s = (void *)GetProcAddress(hMsvcrt, "_ultoa_s");
5094 p_wcslwr_s = (void*)GetProcAddress(hMsvcrt, "_wcslwr_s");
5095 p_mbsupr_s = (void*)GetProcAddress(hMsvcrt, "_mbsupr_s");
5096 p_mbslwr_s = (void*)GetProcAddress(hMsvcrt, "_mbslwr_s");
5097 p_btowc = (void*)GetProcAddress(hMsvcrt, "btowc");
5098 p_wctob = (void*)GetProcAddress(hMsvcrt, "wctob");
5099 p_wcrtomb = (void*)GetProcAddress(hMsvcrt, "wcrtomb");
5100 p_wcrtomb_s = (void*)GetProcAddress(hMsvcrt, "wcrtomb_s");
5101 p_tolower = (void*)GetProcAddress(hMsvcrt, "tolower");
5102 p_towlower = (void*)GetProcAddress(hMsvcrt, "towlower");
5103 p__towlower_l = (void*)GetProcAddress(hMsvcrt, "_towlower_l");
5104 p_towupper = (void*)GetProcAddress(hMsvcrt, "towupper");
5105 p__towupper_l = (void*)GetProcAddress(hMsvcrt, "_towupper_l");
5106 p__create_locale = (void*)GetProcAddress(hMsvcrt, "_create_locale");
5107 p__free_locale = (void*)GetProcAddress(hMsvcrt, "_free_locale");
5108 p_mbrlen = (void*)GetProcAddress(hMsvcrt, "mbrlen");
5109 p_mbrtowc = (void*)GetProcAddress(hMsvcrt, "mbrtowc");
5110 p_mbsrtowcs = (void*)GetProcAddress(hMsvcrt, "mbsrtowcs");
5111 p_mbsrtowcs_s = (void*)GetProcAddress(hMsvcrt, "mbsrtowcs_s");
5112 p__atodbl_l = (void*)GetProcAddress(hMsvcrt, "_atodbl_l");
5113 p__atof_l = (void*)GetProcAddress(hMsvcrt, "_atof_l");
5114 p__strtod_l = (void*)GetProcAddress(hMsvcrt, "_strtod_l");
5115 p__strnset_s = (void*)GetProcAddress(hMsvcrt, "_strnset_s");
5116 p__wcsnset_s = (void*)GetProcAddress(hMsvcrt, "_wcsnset_s");
5117 p__wcsset_s = (void*)GetProcAddress(hMsvcrt, "_wcsset_s");
5118 p__mbsnlen = (void*)GetProcAddress(hMsvcrt, "_mbsnlen");
5119 p__mbccpy_s = (void*)GetProcAddress(hMsvcrt, "_mbccpy_s");
5120 p__memicmp = (void*)GetProcAddress(hMsvcrt, "_memicmp");
5121 p__memicmp_l = (void*)GetProcAddress(hMsvcrt, "_memicmp_l");
5122 p___strncnt = (void*)GetProcAddress(hMsvcrt, "__strncnt");
5123 p_mbsnextc_l = (void*)GetProcAddress(hMsvcrt, "_mbsnextc_l");
5124 p_mbscmp_l = (void*)GetProcAddress(hMsvcrt, "_mbscmp_l");
5125 p__strnicmp_l = (void*)GetProcAddress(hMsvcrt, "_strnicmp_l");
5126 p_toupper = (void*)GetProcAddress(hMsvcrt, "toupper");
5127
5128 /* MSVCRT memcpy behaves like memmove for overlapping moves,
5129 MFC42 CString::Insert seems to rely on that behaviour */
5130 strcpy(mem,xilstring);
5131 nLen=strlen(xilstring);
5132 pmemcpy(mem+5, mem,nLen+1);
5133 ok(pmemcmp(mem+5,xilstring, nLen) == 0,
5134 "Got result %s\n",mem+5);
5135
5136 /* run tolower tests first */
5137 test_tolower();
5138 test_swab();
5139 test_strcspn();
5140 test_mbcp();
5141 test_mbsspn();
5142 test_mbsspnp();
5143 test_strdup();
5144 test_wcsdup();
5145 test_strcmp();
5146 test_strcpy_s();
5147 test_memcpy_s();
5149 test_strcat_s();
5158 test_mbbtombc();
5159 test_mbctombb();
5162 test_strtok();
5163 test__mbstok();
5164 test_wcscpy_s();
5166 test_strtol();
5167 test_strnlen();
5169 test__strtod();
5170 test_mbstowcs();
5172 test_gcvt();
5173 test__itoa_s();
5177 test__ultoa_s();
5181 test_wctob();
5182 test_btowc();
5183 test_wctomb();
5184 test__atodbl();
5185 test__stricmp();
5187 test__wcstol();
5188 test_atoi();
5189 test_atol();
5190 test_atof();
5191 test_strncpy();
5192 test_strxfrm();
5196 test__mbscmp();
5197 test__ismbclx();
5198 test__memicmp();
5200 test__strupr();
5202 test__tcscoll();
5205 test_C_locale();
5206 test_strstr();
5207 test_iswdigit();
5208 test_wcscmp();
5211 test__mbbtype();
5212 test_wcsncpy();
5213 test_mbsrev();
5214#ifndef __REACTOS__
5216#endif
5218 test_toupper();
5219}
#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:3850
static void test_strtok(void)
Definition: string.c:1792
static void test__mbsupr_s(void)
Definition: string.c:2914
static void test_strdup(void)
Definition: string.c:699
static void test_mbbtombc(void)
Definition: string.c:1621
static void test__wcsnset_s(void)
Definition: string.c:3947
static void test_C_locale(void)
Definition: string.c:4537
static void test_SpecialCasing(void)
Definition: string.c:4726
static void test_ismbckata(void)
Definition: string.c:1669
static void test_mbctokata(void)
Definition: string.c:1592
static void test_mbcp(void)
Definition: string.c:262
static void test_wcsncpy(void)
Definition: string.c:4864
static void test_tolower(void)
Definition: string.c:3331
static void test___strncnt(void)
Definition: string.c:4502
static void test__strtod(void)
Definition: string.c:2077
static void test_mbcjisjms(void)
Definition: string.c:1508
static void test_strcmp(void)
Definition: string.c:717
static void test_memcpy_s(void)
Definition: string.c:878
static void test_wcscpy_s(void)
Definition: string.c:1234
static void test__memicmp(void)
Definition: string.c:4116
static void test__wcslwr_s(void)
Definition: string.c:1424
static void test_strncat_s(void)
Definition: string.c:2692
static void test__mbsnbcat_s(void)
Definition: string.c:2787
static void test__strtoi64(void)
Definition: string.c:1915
static void test_mbctohira(void)
Definition: string.c:1562
static void test__mbscmp(void)
Definition: string.c:4021
static void test_strtol(void)
Definition: string.c:1827
static void test_strcpy_s(void)
Definition: string.c:759
static void test__strnicmp_l(void)
Definition: string.c:4929
static void test_memmove_s(void)
Definition: string.c:946
static void test_mbsrev(void)
Definition: string.c:4875
#define SET(x, y)
Definition: string.c:130
static void test__wcsset_s(void)
Definition: string.c:3986
static void test_strcat_s(void)
Definition: string.c:1008
static void test__mbscpy_s(void)
Definition: string.c:1198
static HMODULE hMsvcrt
Definition: string.c:132
static void test_mbsspn(void)
Definition: string.c:612
static void test__wcsupr_s(void)
Definition: string.c:1340
static void test_iswdigit(void)
Definition: string.c:4633
static void test_strnlen(void)
Definition: string.c:1895
static void test__tcsncoll(void)
Definition: string.c:4242
static void test__itoa_s(void)
Definition: string.c:2536
static void test_strncpy(void)
Definition: string.c:3816
static void *__cdecl * pmemcpy(void *, const void *, size_t n)
static void test_atoi(void)
Definition: string.c:3752
static void test__wcstol(void)
Definition: string.c:3691
static void test__strnset_s(void)
Definition: string.c:3917
static unsigned char * p_mbctype
Definition: string.c:94
static void test__mbslwr_s(void)
Definition: string.c:2979
static void test__mbscat_s(void)
Definition: string.c:1071
static void test_strstr(void)
Definition: string.c:4600
static void test__wcstoi64(void)
Definition: string.c:3618
static void test__stricmp(void)
Definition: string.c:3540
static void test_wcscmp(void)
Definition: string.c:4655
static void test__tolower_l(void)
Definition: string.c:4897
static void test__memicmp_l(void)
Definition: string.c:4151
static void test___STRINGTOLD(void)
Definition: string.c:4685
static void test_gcvt(void)
Definition: string.c:2501
static void test_btowc(void)
Definition: string.c:3178
static void test_mbctombb(void)
Definition: string.c:1647
static void test__wcstombs_s_l(void)
Definition: string.c:2435
static void test__ismbclx(void)
Definition: string.c:4060
static void test_wctomb(void)
Definition: string.c:3254
static void test__tcscoll(void)
Definition: string.c:4339
static void test__mbsnbcpy_s(void)
Definition: string.c:1151
static void test__atodbl(void)
Definition: string.c:3468
static void test_toupper(void)
Definition: string.c:5001
static int * p__mb_cur_max
Definition: string.c:93
static void test__tcsnicoll(void)
Definition: string.c:4419
static void test__ultoa_s(void)
Definition: string.c:3062
static void test_atof(void)
Definition: string.c:3786
static void test__mbstok(void)
Definition: string.c:3044
static void test_wctob(void)
Definition: string.c:3140
static void test__strupr(void)
Definition: string.c:4194
static void test_wcsdup(void)
Definition: string.c:708
static void test_mbcjmsjis(void)
Definition: string.c:1534
static void test_atol(void)
Definition: string.c:3769
static void test__mbbtype(void)
Definition: string.c:4812
static void test_swab(void)
Definition: string.c:134
static void test__strlwr_s(void)
Definition: string.c:2632
static int *__cdecl * pmemcmp(void *, const void *, size_t n)
static void test_mbstowcs(void)
Definition: string.c:2183
static void test_mbsspnp(void)
Definition: string.c:664
static void test_ismbclegal(void)
Definition: string.c:1700
static void test_strcspn(void)
Definition: string.c:178
static void test_wcsncat_s(void)
Definition: string.c:2739
strcpy
Definition: string.h:131
Definition: mem.c:349

◆ test___STRINGTOLD()

static void test___STRINGTOLD ( void  )
static

Definition at line 4685 of file string.c.

4686{
4687 static const struct {
4688 const char *str;
4689 int endptr;
4690 int r;
4691 _LDOUBLE v;
4692 BOOL todo;
4693 } tests[] = {
4694 { "0", 1 },
4695 { "nan", 0, 4 },
4696 { "inf", 0, 4 },
4697 { "-0.0", 4, 0, {{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80 }} },
4698 { "1e0", 3, 0, {{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xff, 0x3f }} },
4699 { "1.7976931348623158e+308", 23, 0, {{ 0xaf, 0xfb, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0x43 }} },
4700 { "1.7976931348623159e+308", 23, 0, {{ 0xb1, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0x43 }} },
4701 { "3.65e-4951", 10, 0, {{ 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }} },
4702 { "1.82e-4951", 10, 0, {{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }}, TRUE },
4703 { "1e-99999", 8, 1, {{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }} },
4704 { "1.18e+4932", 10, 0, {{ 0x25, 0x75, 0x06, 0x68, 0x8a, 0xf1, 0xe7, 0xfd, 0xfe, 0x7f }} },
4705 { "1.19e+4932", 10, 2, {{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xff, 0x7f }} },
4706 { "1e+99999", 8, 2, {{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xff, 0x7f }} },
4707 };
4708
4709 char *endptr;
4710 _LDOUBLE v;
4711 int i, r;
4712
4713 for(i=0; i<ARRAY_SIZE(tests); i++)
4714 {
4715 errno = 0xdeadbeef;
4716 r = __STRINGTOLD(&v, &endptr, tests[i].str, 0);
4718 ok(r == tests[i].r, "%d) r = %d\n", i, r);
4719 ok(endptr == tests[i].str + tests[i].endptr, "%d) endptr = %p, expected %p\n",
4720 i, endptr, tests[i].str+tests[i].endptr);
4721 ok(!memcmp(&v, &tests[i].v, sizeof(v)), "%d) v = %s\n", i, debugstr_ldouble(&v));
4722 ok(errno == 0xdeadbeef, "%d) errno = %x\n", i, errno);
4723 }
4724}
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:4669
const WCHAR * str
#define errno
Definition: errno.h:18

Referenced by START_TEST().

◆ test___strncnt()

static void test___strncnt ( void  )
static

Definition at line 4502 of file string.c.

4503{
4504 static const struct
4505 {
4506 const char *str;
4507 size_t size;
4508 size_t ret;
4509 }
4510 strncnt_tests[] =
4511 {
4512 { NULL, 0, 0 },
4513 { "a", 0, 0 },
4514 { "a", 1, 1 },
4515 { "a", 10, 1 },
4516 { "abc", 1, 1 },
4517 };
4518 unsigned int i;
4519 size_t ret;
4520
4521 if (!p___strncnt)
4522 {
4523 win_skip("__strncnt() is not available.\n");
4524 return;
4525 }
4526
4527 if (0) /* crashes */
4528 ret = p___strncnt(NULL, 1);
4529
4530 for (i = 0; i < ARRAY_SIZE(strncnt_tests); ++i)
4531 {
4532 ret = p___strncnt(strncnt_tests[i].str, strncnt_tests[i].size);
4533 ok(ret == strncnt_tests[i].ret, "%u: unexpected return value %u.\n", i, (int)ret);
4534 }
4535}
#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 3468 of file string.c.

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

Referenced by START_TEST().

◆ test__ismbclx()

static void test__ismbclx ( void  )
static

Definition at line 4060 of file string.c.

4061{
4062 int ret, cp = _getmbcp();
4063
4064 ret = _ismbcl0(0);
4065 ok(!ret, "got %d\n", ret);
4066
4067 ret = _ismbcl1(0);
4068 ok(!ret, "got %d\n", ret);
4069
4070 ret = _ismbcl2(0);
4071 ok(!ret, "got %d\n", ret);
4072
4073 _setmbcp(1252);
4074
4075 ret = _ismbcl0(0x8140);
4076 ok(!ret, "got %d\n", ret);
4077
4078 ret = _ismbcl1(0x889f);
4079 ok(!ret, "got %d\n", ret);
4080
4081 ret = _ismbcl2(0x989f);
4082 ok(!ret, "got %d\n", ret);
4083
4084 _setmbcp(932);
4085
4086 ret = _ismbcl0(0);
4087 ok(!ret, "got %d\n", ret);
4088
4089 ret = _ismbcl0(0x8140);
4090 ok(ret, "got %d\n", ret);
4091
4092 ret = _ismbcl0(0x817f);
4093 ok(!ret, "got %d\n", ret);
4094
4095 ret = _ismbcl1(0);
4096 ok(!ret, "got %d\n", ret);
4097
4098 ret = _ismbcl1(0x889f);
4099 ok(ret, "got %d\n", ret);
4100
4101 ret = _ismbcl1(0x88fd);
4102 ok(!ret, "got %d\n", ret);
4103
4104 ret = _ismbcl2(0);
4105 ok(!ret, "got %d\n", ret);
4106
4107 ret = _ismbcl2(0x989f);
4108 ok(ret, "got %d\n", ret);
4109
4110 ret = _ismbcl2(0x993f);
4111 ok(!ret, "got %d\n", ret);
4112
4113 _setmbcp(cp);
4114}
_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 2536 of file string.c.

2537{
2538 errno_t ret;
2539 char buffer[33];
2540
2541 if (!p_itoa_s)
2542 {
2543 win_skip("Skipping _itoa_s tests\n");
2544 return;
2545 }
2546
2547 errno = EBADF;
2548 ret = p_itoa_s(0, NULL, 0, 0);
2549 ok(ret == EINVAL, "Expected _itoa_s to return EINVAL, got %d\n", ret);
2550 ok(errno == EINVAL, "Expected errno to be EINVAL, got %d\n", errno);
2551
2552 memset(buffer, 'X', sizeof(buffer));
2553 errno = EBADF;
2554 ret = p_itoa_s(0, buffer, 0, 0);
2555 ok(ret == EINVAL, "Expected _itoa_s to return EINVAL, got %d\n", ret);
2556 ok(errno == EINVAL, "Expected errno to be EINVAL, got %d\n", errno);
2557 ok(buffer[0] == 'X', "Expected the output buffer to be untouched\n");
2558
2559 memset(buffer, 'X', sizeof(buffer));
2560 errno = EBADF;
2561 ret = p_itoa_s(0, buffer, sizeof(buffer), 0);
2562 ok(ret == EINVAL, "Expected _itoa_s to return EINVAL, got %d\n", ret);
2563 ok(errno == EINVAL, "Expected errno to be EINVAL, got %d\n", errno);
2564 ok(buffer[0] == '\0', "Expected the output buffer to be null terminated\n");
2565
2566 memset(buffer, 'X', sizeof(buffer));
2567 errno = EBADF;
2568 ret = p_itoa_s(0, buffer, sizeof(buffer), 64);
2569 ok(ret == EINVAL, "Expected _itoa_s to return EINVAL, got %d\n", ret);
2570 ok(errno == EINVAL, "Expected errno to be EINVAL, got %d\n", errno);
2571 ok(buffer[0] == '\0', "Expected the output buffer to be null terminated\n");
2572
2573 memset(buffer, 'X', sizeof(buffer));
2574 errno = EBADF;
2575 ret = p_itoa_s(12345678, buffer, 4, 10);
2576 ok(ret == ERANGE, "Expected _itoa_s to return ERANGE, got %d\n", ret);
2577 ok(errno == ERANGE, "Expected errno to be ERANGE, got %d\n", errno);
2578 ok(!memcmp(buffer, "\000765", 4),
2579 "Expected the output buffer to be null terminated with truncated output\n");
2580
2581 memset(buffer, 'X', sizeof(buffer));
2582 errno = EBADF;
2583 ret = p_itoa_s(12345678, buffer, 8, 10);
2584 ok(ret == ERANGE, "Expected _itoa_s to return ERANGE, got %d\n", ret);
2585 ok(errno == ERANGE, "Expected errno to be ERANGE, got %d\n", errno);
2586 ok(!memcmp(buffer, "\0007654321", 8),
2587 "Expected the output buffer to be null terminated with truncated output\n");
2588
2589 memset(buffer, 'X', sizeof(buffer));
2590 errno = EBADF;
2591 ret = p_itoa_s(-12345678, buffer, 9, 10);
2592 ok(ret == ERANGE, "Expected _itoa_s to return ERANGE, got %d\n", ret);
2593 ok(errno == ERANGE, "Expected errno to be ERANGE, got %d\n", errno);
2594 ok(!memcmp(buffer, "\00087654321", 9),
2595 "Expected the output buffer to be null terminated with truncated output\n");
2596
2597 ret = p_itoa_s(12345678, buffer, 9, 10);
2598 ok(ret == 0, "Expected _itoa_s to return 0, got %d\n", ret);
2599 ok(!strcmp(buffer, "12345678"),
2600 "Expected output buffer string to be \"12345678\", got \"%s\"\n",
2601 buffer);
2602
2603 ret = p_itoa_s(43690, buffer, sizeof(buffer), 2);
2604 ok(ret == 0, "Expected _itoa_s to return 0, got %d\n", ret);
2605 ok(!strcmp(buffer, "1010101010101010"),
2606 "Expected output buffer string to be \"1010101010101010\", got \"%s\"\n",
2607 buffer);
2608
2609 ret = p_itoa_s(1092009, buffer, sizeof(buffer), 36);
2610 ok(ret == 0, "Expected _itoa_s to return 0, got %d\n", ret);
2611 ok(!strcmp(buffer, "nell"),
2612 "Expected output buffer string to be \"nell\", got \"%s\"\n",
2613 buffer);
2614
2615 ret = p_itoa_s(5704, buffer, sizeof(buffer), 18);
2616 ok(ret == 0, "Expected _itoa_s to return 0, got %d\n", ret);
2617 ok(!strcmp(buffer, "hag"),
2618 "Expected output buffer string to be \"hag\", got \"%s\"\n",
2619 buffer);
2620
2621 ret = p_itoa_s(-12345678, buffer, sizeof(buffer), 10);
2622 ok(ret == 0, "Expected _itoa_s to return 0, got %d\n", ret);
2623 ok(!strcmp(buffer, "-12345678"),
2624 "Expected output buffer string to be \"-12345678\", got \"%s\"\n",
2625 buffer);
2626
2627 itoa(100, buffer, 100);
2628 ok(!strcmp(buffer, "10"),
2629 "Expected output buffer string to be \"10\", got \"%s\"\n", buffer);
2630}
#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 4812 of file string.c.

4813{
4814 static const char *test_locales[] =
4815 {
4816 "Arabic_Algeria",
4817 "Chinese_China",
4818 "English_Australia",
4819 "French_Belgium",
4820 "German_Austria",
4821 "Greek",
4822 "Hindi",
4823 "Japanese",
4824 "Korean",
4825 "Polish",
4826 "Portuguese_Brazil",
4827 "Russian",
4828 "Spanish_Argentina",
4829 "Swedish_Finland",
4830 "Ukrainian",
4831 "Vietnamese",
4832 };
4833
4834 int expected, ret;
4835 unsigned int c, i;
4836
4837 for (i = 0; i < ARRAY_SIZE(test_locales); ++i)
4838 {
4839 setlocale(LC_ALL, test_locales[i]);
4841 for (c = 0; c < 256; ++c)
4842 {
4843 if (_ismbblead(c))
4845 else if (isprint(c))
4847 else
4849
4850 ret = _mbbtype(c, 0);
4851 ok(ret == expected, "test %u, c %#x, got ret %#x, expected %#x.\n", i, c, ret, expected);
4852
4853 if (_ismbbtrail(c))
4855 else
4857
4858 ret = _mbbtype(c, 1);
4859 ok(ret == expected, "test %u, c %#x, got ret %#x, expected %#x.\n", i, c, ret, expected);
4860 }
4861 }
4862}
#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 1071 of file string.c.

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

4022{
4023 static const unsigned char a[] = {'a',0}, b[] = {'b',0};
4024 int ret;
4025
4026 if (!p_mbrlen)
4027 {
4028 win_skip("_mbscmp tests\n");
4029 return;
4030 }
4031
4032 ret = _mbscmp(NULL, NULL);
4033 ok(ret == INT_MAX, "got %d\n", ret);
4034
4035 ret = _mbscmp(a, NULL);
4036 ok(ret == INT_MAX, "got %d\n", ret);
4037
4038 ret = _mbscmp(NULL, a);
4039 ok(ret == INT_MAX, "got %d\n", ret);
4040
4041 ret = _mbscmp(a, a);
4042 ok(!ret, "got %d\n", ret);
4043
4044 ret = _mbscmp(a, b);
4045 ok(ret == -1, "got %d\n", ret);
4046
4047 ret = _mbscmp(b, a);
4048 ok(ret == 1, "got %d\n", ret);
4049
4050 if (!p_mbscmp_l)
4051 {
4052 win_skip("_mbscmp_l tests\n");
4053 return;
4054 }
4055
4056 ret = p_mbscmp_l(a, b, NULL);
4057 ok(ret == -1, "got %d\n", ret);
4058}
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 1198 of file string.c.

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

Referenced by START_TEST().

◆ test__mbslwr_s()

static void test__mbslwr_s ( void  )
static

Definition at line 2979 of file string.c.

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

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

Referenced by START_TEST().

◆ test__mbsnbcpy_s()

static void test__mbsnbcpy_s ( void  )
static

Definition at line 1151 of file string.c.

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

Referenced by START_TEST().

◆ test__mbstok()

static void test__mbstok ( void  )
static

Definition at line 3044 of file string.c.

3045{
3046 const unsigned char delim[] = "t";
3047
3048 char str[] = "!.!test";
3049 unsigned char *ret;
3050
3051 strtok(str, "!");
3052
3053 ret = _mbstok(NULL, delim);
3054 /* most versions of msvcrt use the same buffer for strtok and _mbstok */
3055 ok(!ret || broken((char*)ret==str+4),
3056 "_mbstok(NULL, \"t\") = %p, expected NULL (%p)\n", ret, str);
3057
3058 ret = _mbstok(NULL, delim);
3059 ok(!ret, "_mbstok(NULL, \"t\") = %p, expected NULL\n", ret);
3060}
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 2914 of file string.c.

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

Referenced by START_TEST().

◆ test__memicmp()

static void test__memicmp ( void  )
static

Definition at line 4116 of file string.c.

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

Referenced by START_TEST().

◆ test__memicmp_l()

static void test__memicmp_l ( void  )
static

Definition at line 4151 of file string.c.

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

Referenced by START_TEST().

◆ test__stricmp()

static void test__stricmp ( void  )
static

Definition at line 3540 of file string.c.

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

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

Referenced by START_TEST().

◆ test__strnicmp_l()

static void test__strnicmp_l ( void  )
static

Definition at line 4929 of file string.c.

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

Referenced by START_TEST().

◆ test__strnset_s()

static void test__strnset_s ( void  )
static

Definition at line 3917 of file string.c.

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

Referenced by START_TEST().

◆ test__strtod()

static void test__strtod ( void  )
static

Definition at line 2077 of file string.c.

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

Referenced by START_TEST().

◆ test__strtoi64()

static void test__strtoi64 ( void  )
static

Definition at line 1915 of file string.c.

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

4195{
4196 const char str[] = "123";
4197 const char *const_p;
4198 char str2[4];
4199 char *mem, *p;
4200 DWORD prot;
4201
4203 ok(mem != NULL, "VirtualAlloc failed\n");
4204 memcpy(mem, str, sizeof(str));
4205 ok(VirtualProtect(mem, sizeof(str), PAGE_READONLY, &prot), "VirtualProtect failed\n");
4206
4207 strcpy(str2, "aBc");
4208 p = _strupr(str2);
4209 ok(p == str2, "_strupr returned %p\n", p);
4210 ok(!strcmp(str2, "ABC"), "str2 = %s\n", str2);
4211
4212 p = _strupr(mem);
4213 ok(p == mem, "_strupr returned %p\n", p);
4214 ok(!strcmp(mem, "123"), "mem = %s\n", mem);
4215
4216 const_p = "ALREADY_UPPERCASE";
4217 p = _strupr((char *)const_p);
4218 ok(p == const_p, "_strupr returned %p\n", p);
4219
4220 if(!setlocale(LC_ALL, "english")) {
4221 VirtualFree(mem, sizeof(str), MEM_RELEASE);
4222 win_skip("English locale _strupr tests\n");
4223 return;
4224 }
4225
4226 strcpy(str2, "aBc");
4227 p = _strupr(str2);
4228 ok(p == str2, "_strupr returned %p\n", p);
4229 ok(!strcmp(str2, "ABC"), "str2 = %s\n", str2);
4230
4231 if (0) /* crashes on Windows */
4232 {
4233 p = _strupr(mem);
4234 ok(p == mem, "_strupr returned %p\n", p);
4235 ok(!strcmp(mem, "123"), "mem = %s\n", mem);
4236 }
4237
4238 setlocale(LC_ALL, "C");
4239 VirtualFree(mem, sizeof(str), MEM_RELEASE);
4240}
#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 4339 of file string.c.

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

Referenced by START_TEST().

◆ test__tcsncoll()

static void test__tcsncoll ( void  )
static

Definition at line 4242 of file string.c.

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

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

4898{
4899 int ret;
4900
4901 ok(setlocale(LC_ALL, "english") != NULL, "setlocale failed.\n");
4902 ret = _tolower_l('\xa5', 0);
4903 ok(ret == 165, "Got %d.\n", ret);
4904 ret = _tolower_l('\xb9', 0);
4905 ok(ret == 185, "Got %d.\n", ret);
4906 ret = _tolower_l('a', 0);
4907 ok(ret == 97, "Got %d.\n", ret);
4908
4909 ok(setlocale(LC_ALL, ".936") != NULL, "setlocale failed.\n");
4910 ret = _tolower_l('\xa5', 0);
4911 ok(ret == -91, "Got %d.\n", ret);
4912 ret = _tolower_l('\xb9', 0);
4913 ok(ret == -71, "Got %d.\n", ret);
4914 ret = _tolower_l('a', 0);
4915 ok(ret == 97, "Got %d.\n", ret);
4916
4917 ok(setlocale(LC_ALL, "chinese-simplified") != NULL, "setlocale failed.\n");
4918 ret = _tolower_l('\xa5', 0);
4919 ok(ret == -91, "Got %d.\n", ret);
4920 ret = _tolower_l('\xb9', 0);
4921 ok(ret == -71, "Got %d.\n", ret);
4922 ret = _tolower_l('a', 0);
4923 ok(ret == 97, "Got %d.\n", ret);
4924
4925 setlocale(LC_ALL, "C");
4926}
_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 3062 of file string.c.

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

Referenced by START_TEST().

◆ test__wcslwr_s()

static void test__wcslwr_s ( void  )
static

Definition at line 1424 of file string.c.

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

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

Referenced by START_TEST().

◆ test__wcsset_s()

static void test__wcsset_s ( void  )
static

Definition at line 3986 of file string.c.

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

Referenced by START_TEST().

◆ test__wcstoi64()

static void test__wcstoi64 ( void  )
static

Definition at line 3618 of file string.c.

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

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

Referenced by START_TEST().

◆ test__wcstombs_s_l()

static void test__wcstombs_s_l ( void  )
static

Definition at line 2435 of file string.c.

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

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

Referenced by START_TEST().

◆ test_atof()

static void test_atof ( void  )
static

Definition at line 3786 of file string.c.

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

Referenced by START_TEST().

◆ test_atoi()

static void test_atoi ( void  )
static

Definition at line 3752 of file string.c.

3753{
3754 int r;
3755
3756 r = atoi("0");
3757 ok(r == 0, "atoi(0) = %d\n", r);
3758
3759 r = atoi("-1");
3760 ok(r == -1, "atoi(-1) = %d\n", r);
3761
3762 r = atoi("1");
3763 ok(r == 1, "atoi(1) = %d\n", r);
3764
3765 r = atoi("4294967296");
3766 ok(r == 0, "atoi(4294967296) = %d\n", r);
3767}
_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 3769 of file string.c.

3770{
3771 int r;
3772
3773 r = atol("0");
3774 ok(r == 0, "atol(0) = %d\n", r);
3775
3776 r = atol("-1");
3777 ok(r == -1, "atol(-1) = %d\n", r);
3778
3779 r = atol("1");
3780 ok(r == 1, "atol(1) = %d\n", r);
3781
3782 r = atol("4294967296");
3783 ok(r == 0, "atol(4294967296) = %d\n", r);
3784}
_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 3178 of file string.c.

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

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

Referenced by START_TEST().

◆ test_cp_table()

static void test_cp_table ( int  cp,
int result 
)
static

Definition at line 239 of file string.c.

240{
241 int i;
242 int count = 0;
243 int curr = 0;
244 _setmbcp(cp);
245 for (i = 0; i < 256; i++)
246 {
247 if (count == 0)
248 {
249 curr = result[0];
250 count = result[1];
251 result += 2;
252 }
253 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);
254 count--;
255 }
256}
GLuint64EXT * result
Definition: glext.h:11304

◆ test_gcvt()

static void test_gcvt ( void  )
static

Definition at line 2501 of file string.c.

2502{
2503 char buf[1024], *res;
2504 errno_t err;
2505
2506 if(!p_gcvt_s) {
2507 win_skip("Skipping _gcvt tests\n");
2508 return;
2509 }
2510
2511 errno = 0;
2512 res = _gcvt(1.2, -1, buf);
2513 ok(res == NULL, "res != NULL\n");
2514 ok(errno == ERANGE, "errno = %d\n", errno);
2515
2516 errno = 0;
2517 res = _gcvt(1.2, 5, NULL);
2518 ok(res == NULL, "res != NULL\n");
2519 ok(errno == EINVAL, "errno = %d\n", errno);
2520
2521 res = gcvt(1.2, 5, buf);
2522 ok(res == buf, "res != buf\n");
2523 ok(!strcmp(buf, "1.2"), "buf = %s\n", buf);
2524
2525 buf[0] = 'x';
2526 err = p_gcvt_s(buf, 5, 1.2, 10);
2527 ok(err == ERANGE, "err = %d\n", err);
2528 ok(buf[0] == '\0', "buf[0] = %c\n", buf[0]);
2529
2530 buf[0] = 'x';
2531 err = p_gcvt_s(buf, 4, 123456, 2);
2532 ok(err == ERANGE, "err = %d\n", err);
2533 ok(buf[0] == '\0', "buf[0] = %c\n", buf[0]);
2534}
_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 1669 of file string.c.

1669 {
1670 struct katakana_pair {
1671 UINT c;
1672 BOOL exp;
1673 };
1674 static const struct katakana_pair tests[] = {
1675 {0x8152, FALSE}, {0x8153, FALSE}, {0x8154, FALSE}, {0x8155, FALSE},
1676 {0x82a0, FALSE}, {0x833f, FALSE}, {0x8340, TRUE }, {0x837e, TRUE },
1677 {0x837f, FALSE}, {0x8380, TRUE }, {0x8396, TRUE }, {0x8397, FALSE},
1678 {0xa5, FALSE}, {0xb0, FALSE}, {0xdd, FALSE}
1679 };
1680 unsigned int prev_cp = _getmbcp();
1681 int ret;
1682 unsigned int i;
1683
1685 for (i = 0; i < ARRAY_SIZE(tests); i++) {
1686 ret = _ismbckata(tests[i].c);
1687 ok(!ret, "expected 0, got %d for %04x\n", ret, tests[i].c);
1688 }
1689
1690 _setmbcp(932);
1691 for (i = 0; i < ARRAY_SIZE(tests); i++) {
1692 ret = _ismbckata(tests[i].c);
1693 ok(!!ret == tests[i].exp, "expected %d, got %d for %04x\n",
1694 tests[i].exp, !!ret, tests[i].c);
1695 }
1696
1697 _setmbcp(prev_cp);
1698}
#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 1700 of file string.c.

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

4634{
4635 static const struct {
4636 WCHAR c;
4637 int r;
4638 } tests[] = {
4639 { '0', C1_DIGIT },
4640 { '9', C1_DIGIT },
4641 { 'a', 0 },
4642 { 0xff16, C1_DIGIT },
4643 { 0x0660, C1_DIGIT },
4644 { 0x0ce6, C1_DIGIT }
4645 };
4646 int i, r;
4647
4648 for (i = 0; i < ARRAY_SIZE(tests); i++)
4649 {
4650 r = iswdigit(tests[i].c);
4651 ok(r == tests[i].r, "iswdigit returned %x for %x\n", r, tests[i].c);
4652 }
4653}
#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 1621 of file string.c.

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

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

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

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

Referenced by START_TEST().

◆ test_mbctohira()

static void test_mbctohira ( void  )
static

Definition at line 1562 of file string.c.

1563{
1564 static const unsigned int mbchira_932[][2] = {
1565 {0x8152, 0x8152}, {0x8153, 0x8153}, {0x8154, 0x8154}, {0x8155, 0x8155},
1566 {0x82a0, 0x82a0}, {0x833f, 0x833f}, {0x8340, 0x829f}, {0x837e, 0x82dd},
1567 {0x837f, 0x837f}, {0x8380, 0x82de}, {0x8393, 0x82f1}, {0x8394, 0x8394},
1568 {0x8396, 0x8396}, {0x8397, 0x8397},
1569 {0xa5, 0xa5}, {0xb0, 0xb0}, {0xdd, 0xdd} };
1570 unsigned int i;
1571 unsigned int prev_cp = _getmbcp();
1572
1574 for (i = 0; i < ARRAY_SIZE(mbchira_932); i++)
1575 {
1576 int ret, exp = mbchira_932[i][0];
1577 ret = _mbctohira(mbchira_932[i][0]);
1578 ok(ret == exp, "Expected 0x%x, got 0x%x\n", exp, ret);
1579 }
1580
1581 _setmbcp(932);
1582 for (i = 0; i < ARRAY_SIZE(mbchira_932); i++)
1583 {
1584 unsigned int ret, exp;
1585 ret = _mbctohira(mbchira_932[i][0]);
1586 exp = mbchira_932[i][1];
1587 ok(ret == exp, "Expected 0x%x, got 0x%x\n", exp, ret);
1588 }
1589 _setmbcp(prev_cp);
1590}
_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 1592 of file string.c.

1593{
1594 static const unsigned int mbckata_932[][2] = {
1595 {0x8152, 0x8152}, {0x8153, 0x8153}, {0x8154, 0x8154}, {0x8155, 0x8155},
1596 {0x833f, 0x833f}, {0x829f, 0x8340}, {0x82dd, 0x837e}, {0x837f, 0x837f},
1597 {0x82de, 0x8380}, {0x8394, 0x8394}, {0x8397, 0x8397},
1598 {0xa5, 0xa5}, {0xb0, 0xb0}, {0xdd, 0xdd} };
1599 unsigned int i;
1600 unsigned int prev_cp = _getmbcp();
1601
1603 for (i = 0; i < ARRAY_SIZE(mbckata_932); i++)
1604 {
1605 int ret, exp = mbckata_932[i][0];
1606 ret = _mbctokata(mbckata_932[i][0]);
1607 ok(ret == exp, "Expected 0x%x, got 0x%x\n", exp, ret);
1608 }
1609
1610 _setmbcp(932);
1611 for (i = 0; i < ARRAY_SIZE(mbckata_932); i++)
1612 {
1613 unsigned int ret, exp;
1614 ret = _mbctokata(mbckata_932[i][0]);
1615 exp = mbckata_932[i][1];
1616 ok(ret == exp, "Expected 0x%x, got 0x%x\n", exp, ret);
1617 }
1618 _setmbcp(prev_cp);
1619}
_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 1647 of file string.c.

1648{
1649 static const unsigned int mbcmbb_932[][2] = {
1650 {0x829e, 0x829e}, {0x829f, 0xa7}, {0x82f1, 0xdd}, {0x82f2, 0x82f2},
1651 {0x833f, 0x833f}, {0x8340, 0xa7}, {0x837e, 0xd0}, {0x837f, 0x837f},
1652 {0x8380, 0xd1}, {0x8396, 0xb9}, {0x8397, 0x8397}, {0x813f, 0x813f},
1653 {0x8140, 0x20}, {0x814c, 0x814c}, {0x814f, 0x5e}, {0x8197, 0x40},
1654 {0x8198, 0x8198}, {0x8258, 0x39}, {0x8259, 0x8259}, {0x825f, 0x825f},
1655 {0x8260, 0x41}, {0x82f1, 0xdd}, {0x82f2, 0x82f2}, {0,0}};
1656 unsigned int exp, ret, i;
1657 unsigned int prev_cp = _getmbcp();
1658
1659 _setmbcp(932);
1660 for (i = 0; mbcmbb_932[i][0] != 0; i++)
1661 {
1662 ret = _mbctombb(mbcmbb_932[i][0]);
1663 exp = mbcmbb_932[i][1];
1664 ok(ret == exp, "Expected 0x%x, got 0x%x\n", exp, ret);
1665 }
1666 _setmbcp(prev_cp);
1667}
_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 4875 of file string.c.

4876{
4877 unsigned char buf[64], *ret;
4878 int cp = _getmbcp();
4879
4880 _setmbcp(932);
4881
4882 strcpy((char *)buf, "\x36\x8c\x8e");
4883 ret = _mbsrev(buf);
4884 ok(ret == buf, "ret = %p, expected %p\n", ret, buf);
4885 ok(!memcmp(buf, "\x8c\x8e\x36", 4), "buf = %s\n", wine_dbgstr_a((char *)buf));
4886
4887 /* test string that ends with leading byte */
4888 strcpy((char *)buf, "\x36\x8c");
4889 ret = _mbsrev(buf);
4890 ok(ret == buf, "ret = %p, expected %p\n", ret, buf);
4891 skip_2k3_fail ok(!memcmp(buf, "\x36", 2), "buf = %s\n", wine_dbgstr_a((char *)buf));
4892
4893 _setmbcp(cp);
4894}
_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 612 of file string.c.

613{
614 unsigned char str1[]="cabernet";
615 unsigned char str2[]="shiraz";
616 unsigned char set[]="abc";
617 unsigned char empty[]="";
618 unsigned char mbstr[]=" 2019\x94\x4e" "6\x8c\x8e" "29\x93\xfa";
619 unsigned char mbset1[]="0123456789 \x94\x4e";
620 unsigned char mbset2[]=" \x94\x4e\x8c\x8e";
621 unsigned char mbset3[]="\x8e";
622 int ret, cp = _getmbcp();
623
624 ret=_mbsspn( str1, set);
625 ok( ret==3, "_mbsspn returns %d should be 3\n", ret);
626 ret=_mbsspn( str2, set);
627 ok( ret==0, "_mbsspn returns %d should be 0\n", ret);
628 ret=_mbsspn( str1, empty);
629 ok( ret==0, "_mbsspn returns %d should be 0\n", ret);
630
631 ret=_mbscspn( str1, set);
632 ok( ret==0, "_mbscspn returns %d should be 0\n", ret);
633 ret=_mbscspn( str2, set);
634 ok( ret==4, "_mbscspn returns %d should be 4\n", ret);
635 ret=_mbscspn( str1, empty);
636 ok( ret==8, "_mbscspn returns %d should be 8\n", ret);
637
638 _setmbcp( 932);
639 ret=_mbsspn( mbstr, mbset1);
640 ok( ret==8, "_mbsspn returns %d should be 8\n", ret);
641 ret=_mbsspn( mbstr, mbset2);
642 ok( ret==1, "_mbsspn returns %d should be 1\n", ret);
643 ret=_mbsspn( mbstr+8, mbset1);
644 ok( ret==0, "_mbsspn returns %d should be 0\n", ret);
645 ret=_mbsspn( mbstr+8, mbset2);
646 ok( ret==2, "_mbsspn returns %d should be 2\n", ret);
647 ret=_mbsspn( mbstr, mbset3);
648 ok( ret==14, "_mbsspn returns %d should be 14\n", ret);
649
650 ret=_mbscspn( mbstr, mbset1);
651 ok( ret==0, "_mbscspn returns %d should be 0\n", ret);
652 ret=_mbscspn( mbstr, mbset2);
653 ok( ret==0, "_mbscspn returns %d should be 0\n", ret);
654 ret=_mbscspn( mbstr+8, mbset1);
655 ok( ret==2, "_mbscspn returns %d should be 2\n", ret);
656 ret=_mbscspn( mbstr+8, mbset2);
657 ok( ret==0, "_mbscspn returns %d should be 0\n", ret);
658 ret=_mbscspn( mbstr, mbset3);
659 ok( ret==0, "_mbscspn returns %d should be 0\n", ret);
660
661 _setmbcp( cp);
662}
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 664 of file string.c.

665{
666 unsigned char str1[]="cabernet";
667 unsigned char str2[]="shiraz";
668 unsigned char set[]="abc";
669 unsigned char empty[]="";
670 unsigned char full[]="abcenrt";
671 unsigned char mbstr[]=" 2019\x94\x4e" "6\x8c\x8e" "29\x93\xfa";
672 unsigned char mbset1[]="0123456789 \x94\x4e";
673 unsigned char mbset2[]=" \x94\x4e\x8c\x8e";
674 unsigned char* ret;
675 int cp = _getmbcp();
676
677 ret=_mbsspnp( str1, set);
678 ok( ret[0]=='e', "_mbsspnp returns %c should be e\n", ret[0]);
679 ret=_mbsspnp( str2, set);
680 ok( ret[0]=='s', "_mbsspnp returns %c should be s\n", ret[0]);
681 ret=_mbsspnp( str1, empty);
682 ok( ret[0]=='c', "_mbsspnp returns %c should be c\n", ret[0]);
683 ret=_mbsspnp( str1, full);
684 ok( ret==NULL, "_mbsspnp returns %p should be NULL\n", ret);
685
686 _setmbcp( 932);
687 ret=_mbsspnp( mbstr, mbset1);
688 ok( ret==mbstr+8, "_mbsspnp returns %p should be %p\n", ret, mbstr+8);
689 ret=_mbsspnp( mbstr, mbset2);
690 ok( ret==mbstr+1, "_mbsspnp returns %p should be %p\n", ret, mbstr+1);
691 ret=_mbsspnp( mbstr+8, mbset1);
692 ok( ret==mbstr+8, "_mbsspnp returns %p should be %p\n", ret, mbstr+8);
693 ret=_mbsspnp( mbstr+8, mbset2);
694 ok( ret==mbstr+10, "_mbsspnp returns %p should be %p\n", ret, mbstr+10);
695
696 _setmbcp( cp);
697}
_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 2183 of file string.c.

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

Referenced by START_TEST().

◆ test_memcpy_s()

static void test_memcpy_s ( void  )
static

Definition at line 878 of file string.c.

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

Referenced by START_TEST().

◆ test_memmove_s()

static void test_memmove_s ( void  )
static

Definition at line 946 of file string.c.

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

Referenced by START_TEST().

◆ test_SpecialCasing()

static void test_SpecialCasing ( void  )
static

Definition at line 4726 of file string.c.

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

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

Referenced by START_TEST().

◆ test_strcmp()

static void test_strcmp ( void  )
static

Definition at line 717 of file string.c.

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

Referenced by START_TEST().

◆ test_strcpy_s()

static void test_strcpy_s ( void  )
static

Definition at line 759 of file string.c.

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

Referenced by START_TEST().

◆ test_strcspn()

static void test_strcspn ( void  )
static

Definition at line 178 of file string.c.

179{
180 static const struct {
181 const char *str;
182 const char *rej;
183 int ret;
184 } tests[] = {
185 { "test", "a", 4 },
186 { "test", "e", 1 },
187 { "test", "", 4 },
188 { "", "a", 0 },
189 { "a\xf1", "\xf1", 1 }
190 };
191 int r, i;
192
193 for (i = 0; i < ARRAY_SIZE(tests); i++)
194 {
195 r = strcspn(tests[i].str, tests[i].rej);
196 ok(r == tests[i].ret, "strcspn(\"%s\", \"%s\") = %d, expected %d\n",
197 tests[i].str, tests[i].rej, r, tests[i].ret);
198 }
199}
_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 699 of file string.c.

700{
701 char *str;
702 errno = 0xdeadbeef;
703 str = strdup(0);
704 ok(str == 0, "strdup returned %s, expected NULL\n", wine_dbgstr_a(str));
705 ok(errno == 0xdeadbeef, "errno is %d, expected 0xdeadbeef\n", errno);
706}
_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 2692 of file string.c.

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

Referenced by START_TEST().

◆ test_strncpy()

static void test_strncpy ( void  )
static

Definition at line 3816 of file string.c.

3817{
3818#define TEST_STRNCPY_LEN 10
3819 /* use function pointer to bypass gcc builtin */
3820 char *(__cdecl *p_strncpy)(char*,const char*,size_t);
3821 char *ret;
3822 char dst[TEST_STRNCPY_LEN + 1];
3823 char not_null_terminated[] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '0'};
3824
3825 p_strncpy = (void *)GetProcAddress( GetModuleHandleA("msvcrt.dll"), "strncpy");
3826
3827 /* strlen(src) > TEST_STRNCPY_LEN */
3828 ret = p_strncpy(dst, "01234567890123456789", TEST_STRNCPY_LEN);
3829 ok(ret == dst, "ret != dst\n");
3830 ok(!strncmp(dst, "0123456789", TEST_STRNCPY_LEN), "dst != 0123456789\n");
3831
3832 /* without null-terminated */
3833 ret = p_strncpy(dst, not_null_terminated, TEST_STRNCPY_LEN);
3834 ok(ret == dst, "ret != dst\n");
3835 ok(!strncmp(dst, "0123456789", TEST_STRNCPY_LEN), "dst != 0123456789\n");
3836
3837 /* strlen(src) < TEST_STRNCPY_LEN */
3838 strcpy(dst, "0123456789");
3839 ret = p_strncpy(dst, "012345", TEST_STRNCPY_LEN);
3840 ok(ret == dst, "ret != dst\n");
3841 ok(!strcmp(dst, "012345"), "dst != 012345\n");
3842 ok(dst[TEST_STRNCPY_LEN - 1] == '\0', "dst[TEST_STRNCPY_LEN - 1] != 0\n");
3843
3844 /* strlen(src) == TEST_STRNCPY_LEN */
3845 ret = p_strncpy(dst, "0123456789", TEST_STRNCPY_LEN);
3846 ok(ret == dst, "ret != dst\n");
3847 ok(!strncmp(dst, "0123456789", TEST_STRNCPY_LEN), "dst != 0123456789\n");
3848}
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 1895 of file string.c.

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

Referenced by START_TEST().

◆ test_strstr()

static void test_strstr ( void  )
static

Definition at line 4600 of file string.c.

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

Referenced by START_TEST().

◆ test_strtok()

static void test_strtok ( void  )
static

Definition at line 1792 of file string.c.

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

Referenced by START_TEST().

◆ test_strtol()

static void test_strtol ( void  )
static

Definition at line 1827 of file string.c.

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

Referenced by START_TEST().

◆ test_strxfrm()

static void test_strxfrm ( void  )
static

Definition at line 3850 of file string.c.

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

134 {
135 char original[] = "BADCFEHGJILKNMPORQTSVUXWZY@#";
136 char expected1[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ@#";
137 char expected2[] = "ABCDEFGHIJKLMNOPQRSTUVWX$";
138 char expected3[] = "$";
139
140 char from[30];
141 char to[30];
142
143 int testsize;
144
145 /* Test 1 - normal even case */
146 memset(to,'$', sizeof(to));
147 memset(from,'@', sizeof(from));
148 testsize = 26;
149 memcpy(from, original, testsize);
150 _swab( from, to, testsize );
151 ok(memcmp(to,expected1,testsize) == 0, "Testing even size %d returned '%*.*s'\n", testsize, testsize, testsize, to);
152
153 /* Test 2 - uneven case */
154 memset(to,'$', sizeof(to));
155 memset(from,'@', sizeof(from));
156 testsize = 25;
157 memcpy(from, original, testsize);
158 _swab( from, to, testsize );
159 ok(memcmp(to,expected2,testsize) == 0, "Testing odd size %d returned '%*.*s'\n", testsize, testsize, testsize, to);
160
161 /* Test 3 - from = to */
162 memset(to,'$', sizeof(to));
163 memset(from,'@', sizeof(from));
164 testsize = 26;
165 memcpy(to, original, testsize);
166 _swab( to, to, testsize );
167 ok(memcmp(to,expected1,testsize) == 0, "Testing overlapped size %d returned '%*.*s'\n", testsize, testsize, testsize, to);
168
169 /* Test 4 - 1 bytes */
170 memset(to,'$', sizeof(to));
171 memset(from,'@', sizeof(from));
172 testsize = 1;
173 memcpy(from, original, testsize);
174 _swab( from, to, testsize );
175 ok(memcmp(to,expected3,testsize) == 0, "Testing small size %d returned '%*.*s'\n", testsize, testsize, testsize, to);
176}
_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 3331 of file string.c.

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

Referenced by START_TEST().

◆ test_toupper()

static void test_toupper ( void  )
static

Definition at line 5001 of file string.c.

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

Referenced by START_TEST().

◆ test_wcscmp()

static void test_wcscmp ( void  )
static

Definition at line 4655 of file string.c.

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

Referenced by START_TEST().

◆ test_wcscpy_s()

static void test_wcscpy_s ( void  )
static

Definition at line 1234 of file string.c.

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

Referenced by START_TEST().

◆ test_wcsdup()

static void test_wcsdup ( void  )
static

Definition at line 708 of file string.c.

709{
710 WCHAR *str;
711 errno = 0xdeadbeef;
712 str = wcsdup(0);
713 ok(str == 0, "wcsdup returned %s, expected NULL\n", wine_dbgstr_w(str));
714 ok(errno == 0xdeadbeef, "errno is %d, expected 0xdeadbeef\n", errno);
715}
_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 2739 of file string.c.

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

Referenced by START_TEST().

◆ test_wcsncpy()

static void test_wcsncpy ( void  )
static

Definition at line 4864 of file string.c.

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

Referenced by START_TEST().

◆ test_wctob()

static void test_wctob ( void  )
static

Definition at line 3140 of file string.c.

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

Referenced by START_TEST().

◆ test_wctomb()

static void test_wctomb ( void  )
static

Definition at line 3254 of file string.c.

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

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 84 of file string.c.

◆ count

Definition at line 68 of file string.c.

◆ delimiter

◆ double

static double

Definition at line 89 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 69 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 1778 of file string.c.

Referenced by test_strtok().

◆ exp_offsetret2

int exp_offsetret2

Definition at line 1780 of file string.c.

Referenced by test_strtok().

◆ exp_offsetret3

int exp_offsetret3

Definition at line 1782 of file string.c.

Referenced by test_strtok().

◆ hMsvcrt

HMODULE hMsvcrt
static

Definition at line 132 of file string.c.

Referenced by START_TEST(), and und_name().

◆ int

int

Definition at line 79 of file string.c.

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

◆ len

Definition at line 66 of file string.c.

◆ numberOfElements

static size_t numberOfElements

◆ p__mb_cur_max

int* p__mb_cur_max
static

Definition at line 93 of file string.c.

Referenced by START_TEST(), and test_mbcp().

◆ p_mbctype

unsigned char* p_mbctype
static

Definition at line 94 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 230 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 232 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 234 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 236 of file string.c.

◆ size

Definition at line 68 of file string.c.

◆ size_t

Definition at line 60 of file string.c.

◆ src

Definition at line 65 of file string.c.

◆ string

Definition at line 1776 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 100 of file string.c.

◆ wcSrc

static size_t const wchar_t * wcSrc

Definition at line 74 of file string.c.

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