ReactOS  0.4.14-dev-604-gcfdd483
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 <math.h>
#include "winbase.h"
#include "winnls.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 _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 *
 
static void test_swab (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_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 almost_equal (double d1, double d2)
 
static void test__strtod (void)
 
static void test_mbstowcs (void)
 
static void test_gcvt (void)
 
static void test__itoa_s (void)
 
static void test__strlwr_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_wctomb (void)
 
static void test_tolower (void)
 
static void test__atodbl (void)
 
static void test__stricmp (void)
 
static void test__wcstoi64 (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__tcsnicoll (void)
 
static void test___strncnt (void)
 
static void test_C_locale (void)
 
 START_TEST (string)
 

Variables

static size_t
 
static const charsrc
 
static size_t len
 
static size_t size
 
static size_t const unsigned char size_t count
 
static const unsigned char *static size_t const wchar_twcSrc
 
static size_t elem
 
static char int
 
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 _locale_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 53 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 52 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])
static CRYPT_DATA_BLOB b1[]
Definition: msg.c:573
static CRYPT_DATA_BLOB b3[]
Definition: msg.c:592
#define ok(value,...)
Definition: atltest.h:57
GLenum GLenum dst
Definition: glext.h:6340
static CRYPT_DATA_BLOB b2[]
Definition: msg.c:582
static CRYPT_DATA_BLOB b4
Definition: msg.c:2284

Definition at line 655 of file string.c.

◆ SET

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

Definition at line 114 of file string.c.

◆ SETNOFAIL

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

Definition at line 113 of file string.c.

◆ test_codepage

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

Definition at line 219 of file string.c.

◆ TEST_STRNCPY_LEN

#define TEST_STRNCPY_LEN   10

Function Documentation

◆ __int64()

static unsigned __int64 ( __cdecl p_strtoi64) const
static

Referenced by test__strtoi64(), and test__wcstoi64().

◆ _locale_t()

static _locale_t ( __cdecl p__create_locale)
static

◆ almost_equal()

static BOOL almost_equal ( double  d1,
double  d2 
)
inlinestatic

Definition at line 1841 of file string.c.

1841  {
1842  if(d1-d2>-1e-30 && d1-d2<1e-30)
1843  return TRUE;
1844  return FALSE;
1845 }
#define TRUE
Definition: types.h:120
#define e
Definition: ke_i.h:82

Referenced by test__atodbl(), test__strtod(), and test_atof().

◆ buf_to_string()

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

Definition at line 38 of file string.c.

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

◆ 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

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

3860 {
3861  char mem[100];
3862  static const char xilstring[]="c:/xilinx";
3863  int nLen;
3864 
3865  hMsvcrt = GetModuleHandleA("msvcrt.dll");
3866  if (!hMsvcrt)
3867  hMsvcrt = GetModuleHandleA("msvcrtd.dll");
3868  ok(hMsvcrt != 0, "GetModuleHandleA failed\n");
3869  SET(pmemcpy,"memcpy");
3870  p_memcpy_s = (void*)GetProcAddress( hMsvcrt, "memcpy_s" );
3871  p_memmove_s = (void*)GetProcAddress( hMsvcrt, "memmove_s" );
3872  SET(pmemcmp,"memcmp");
3873  SET(p_mbctype,"_mbctype");
3874  SET(p__mb_cur_max,"__mb_cur_max");
3875  SET(p_strcpy, "strcpy");
3876  pstrcpy_s = (void *)GetProcAddress( hMsvcrt,"strcpy_s" );
3877  pstrcat_s = (void *)GetProcAddress( hMsvcrt,"strcat_s" );
3878  p_mbscat_s = (void*)GetProcAddress( hMsvcrt, "_mbscat_s" );
3879  p_mbsnbcat_s = (void *)GetProcAddress( hMsvcrt,"_mbsnbcat_s" );
3880  p_mbsnbcpy_s = (void *)GetProcAddress( hMsvcrt,"_mbsnbcpy_s" );
3881  p__mbscpy_s = (void *)GetProcAddress( hMsvcrt,"_mbscpy_s" );
3882  p_wcscpy_s = (void *)GetProcAddress( hMsvcrt,"wcscpy_s" );
3883  p_wcsncpy_s = (void *)GetProcAddress( hMsvcrt,"wcsncpy_s" );
3884  p_wcsncat_s = (void *)GetProcAddress( hMsvcrt,"wcsncat_s" );
3885  p_wcsupr_s = (void *)GetProcAddress( hMsvcrt,"_wcsupr_s" );
3886  p_strnlen = (void *)GetProcAddress( hMsvcrt,"strnlen" );
3887  p_strtoi64 = (void *)GetProcAddress(hMsvcrt, "_strtoi64");
3888  p_strtoui64 = (void *)GetProcAddress(hMsvcrt, "_strtoui64");
3889  p_wcstoi64 = (void *)GetProcAddress(hMsvcrt, "_wcstoi64");
3890  p_wcstoui64 = (void *)GetProcAddress(hMsvcrt, "_wcstoui64");
3891  pmbstowcs_s = (void *)GetProcAddress(hMsvcrt, "mbstowcs_s");
3892  pwcstombs_s = (void *)GetProcAddress(hMsvcrt, "wcstombs_s");
3893  pwcsrtombs = (void *)GetProcAddress(hMsvcrt, "wcsrtombs");
3894  p_gcvt_s = (void *)GetProcAddress(hMsvcrt, "_gcvt_s");
3895  p_itoa_s = (void *)GetProcAddress(hMsvcrt, "_itoa_s");
3896  p_strlwr_s = (void *)GetProcAddress(hMsvcrt, "_strlwr_s");
3897  p_ultoa_s = (void *)GetProcAddress(hMsvcrt, "_ultoa_s");
3898  p_wcslwr_s = (void*)GetProcAddress(hMsvcrt, "_wcslwr_s");
3899  p_mbsupr_s = (void*)GetProcAddress(hMsvcrt, "_mbsupr_s");
3900  p_mbslwr_s = (void*)GetProcAddress(hMsvcrt, "_mbslwr_s");
3901  p_wctob = (void*)GetProcAddress(hMsvcrt, "wctob");
3902  p_wcrtomb = (void*)GetProcAddress(hMsvcrt, "wcrtomb");
3903  p_wcrtomb_s = (void*)GetProcAddress(hMsvcrt, "wcrtomb_s");
3904  p_tolower = (void*)GetProcAddress(hMsvcrt, "tolower");
3905  p_towlower = (void*)GetProcAddress(hMsvcrt, "towlower");
3906  p__towlower_l = (void*)GetProcAddress(hMsvcrt, "_towlower_l");
3907  p_towupper = (void*)GetProcAddress(hMsvcrt, "towupper");
3908  p__towupper_l = (void*)GetProcAddress(hMsvcrt, "_towupper_l");
3909  p__create_locale = (void*)GetProcAddress(hMsvcrt, "_create_locale");
3910  p__free_locale = (void*)GetProcAddress(hMsvcrt, "_free_locale");
3911  p_mbrlen = (void*)GetProcAddress(hMsvcrt, "mbrlen");
3912  p_mbrtowc = (void*)GetProcAddress(hMsvcrt, "mbrtowc");
3913  p_mbsrtowcs = (void*)GetProcAddress(hMsvcrt, "mbsrtowcs");
3914  p_mbsrtowcs_s = (void*)GetProcAddress(hMsvcrt, "mbsrtowcs_s");
3915  p__atodbl_l = (void*)GetProcAddress(hMsvcrt, "_atodbl_l");
3916  p__atof_l = (void*)GetProcAddress(hMsvcrt, "_atof_l");
3917  p__strtod_l = (void*)GetProcAddress(hMsvcrt, "_strtod_l");
3918  p__strnset_s = (void*)GetProcAddress(hMsvcrt, "_strnset_s");
3919  p__wcsnset_s = (void*)GetProcAddress(hMsvcrt, "_wcsnset_s");
3920  p__wcsset_s = (void*)GetProcAddress(hMsvcrt, "_wcsset_s");
3921  p__mbsnlen = (void*)GetProcAddress(hMsvcrt, "_mbsnlen");
3922  p__mbccpy_s = (void*)GetProcAddress(hMsvcrt, "_mbccpy_s");
3923  p__memicmp = (void*)GetProcAddress(hMsvcrt, "_memicmp");
3924  p__memicmp_l = (void*)GetProcAddress(hMsvcrt, "_memicmp_l");
3925  p___strncnt = (void*)GetProcAddress(hMsvcrt, "__strncnt");
3926 
3927  /* MSVCRT memcpy behaves like memmove for overlapping moves,
3928  MFC42 CString::Insert seems to rely on that behaviour */
3929  strcpy(mem,xilstring);
3930  nLen=strlen(xilstring);
3931  pmemcpy(mem+5, mem,nLen+1);
3932  ok(pmemcmp(mem+5,xilstring, nLen) == 0,
3933  "Got result %s\n",mem+5);
3934 
3935  /* run tolower tests first */
3936  test_tolower();
3937  test_swab();
3938  test_mbcp();
3939  test_mbsspn();
3940  test_mbsspnp();
3941  test_strdup();
3942  test_strcpy_s();
3943  test_memcpy_s();
3944  test_memmove_s();
3945  test_strcat_s();
3946  test__mbscat_s();
3947  test__mbsnbcpy_s();
3948  test__mbscpy_s();
3949  test_mbcjisjms();
3950  test_mbcjmsjis();
3951  test_mbctohira();
3952  test_mbctokata();
3953  test_mbbtombc();
3954  test_mbctombb();
3955  test_ismbckata();
3956  test_ismbclegal();
3957  test_strtok();
3958  test__mbstok();
3959  test_wcscpy_s();
3960  test__wcsupr_s();
3961  test_strtol();
3962  test_strnlen();
3963  test__strtoi64();
3964  test__strtod();
3965  test_mbstowcs();
3966  test_gcvt();
3967  test__itoa_s();
3968  test__strlwr_s();
3969  test_wcsncat_s();
3970  test__mbsnbcat_s();
3971  test__ultoa_s();
3972  test__wcslwr_s();
3973  test__mbsupr_s();
3974  test__mbslwr_s();
3975  test_wctob();
3976  test_wctomb();
3977  test__atodbl();
3978  test__stricmp();
3979  test__wcstoi64();
3980  test_atoi();
3981  test_atol();
3982  test_atof();
3983  test_strncpy();
3984  test_strxfrm();
3985  test__strnset_s();
3986  test__wcsnset_s();
3987  test__wcsset_s();
3988  test__mbscmp();
3989  test__ismbclx();
3990  test__memicmp();
3991  test__memicmp_l();
3992  test__strupr();
3993  test__tcsncoll();
3994  test__tcsnicoll();
3995  test___strncnt();
3996  test_C_locale();
3997 }
static void test_wctob(void)
Definition: string.c:2745
static void test_swab(void)
Definition: string.c:118
static void test_strcpy_s(void)
Definition: string.c:591
static void test__strlwr_s(void)
Definition: string.c:2313
static void test__memicmp_l(void)
Definition: string.c:3507
static void test__tcsnicoll(void)
Definition: string.c:3678
static void test_memcpy_s(void)
Definition: string.c:661
static void test__mbslwr_s(void)
Definition: string.c:2593
#define SET(x, y)
Definition: string.c:114
static void test_ismbclegal(void)
Definition: string.c:1489
static void test__strtoi64(void)
Definition: string.c:1696
static void test_mbstowcs(void)
Definition: string.c:1954
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
static void test_strdup(void)
Definition: string.c:583
static void test_ismbckata(void)
Definition: string.c:1458
static void test_mbcjmsjis(void)
Definition: string.c:1323
static void test_mbctombb(void)
Definition: string.c:1436
static void test_mbsspn(void)
Definition: string.c:514
static void test__memicmp(void)
Definition: string.c:3472
static void test__mbsupr_s(void)
Definition: string.c:2536
static void test__atodbl(void)
Definition: string.c:2938
static void test__strtod(void)
Definition: string.c:1847
static void test_wcsncat_s(void)
Definition: string.c:2370
static HMODULE hMsvcrt
Definition: string.c:116
static int *__cdecl * pmemcmp(void *, const void *, size_t n)
static void test__strupr(void)
Definition: string.c:3550
static void test_strncpy(void)
Definition: string.c:3181
static void test__itoa_s(void)
Definition: string.c:2217
static void test__stricmp(void)
Definition: string.c:2998
static void test_gcvt(void)
Definition: string.c:2182
static void test__mbscmp(void)
Definition: string.c:3386
static void test_mbsspnp(void)
Definition: string.c:548
static void test__mbscpy_s(void)
Definition: string.c:981
static void test_wctomb(void)
Definition: string.c:2783
static void test__tcsncoll(void)
Definition: string.c:3593
static void test_wcscpy_s(void)
Definition: string.c:1017
static unsigned char * p_mbctype
Definition: string.c:85
static void test_atoi(void)
Definition: string.c:3117
static void test_C_locale(void)
Definition: string.c:3796
static void test_mbctokata(void)
Definition: string.c:1381
static void test__wcsupr_s(void)
Definition: string.c:1123
static void test_strnlen(void)
Definition: string.c:1676
static void test_strxfrm(void)
Definition: string.c:3215
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
Definition: loader.c:821
static void test_atof(void)
Definition: string.c:3151
static void test__ismbclx(void)
Definition: string.c:3416
static void test_strtol(void)
Definition: string.c:1608
static void test__mbscat_s(void)
Definition: string.c:854
static void test_mbcjisjms(void)
Definition: string.c:1297
static void test__mbstok(void)
Definition: string.c:2649
static void test_mbbtombc(void)
Definition: string.c:1410
static void test_atol(void)
Definition: string.c:3134
static void test__mbsnbcat_s(void)
Definition: string.c:2409
#define ok(value,...)
Definition: atltest.h:57
static void test_strtok(void)
Definition: string.c:1581
static void test___strncnt(void)
Definition: string.c:3761
static void test_mbctohira(void)
Definition: string.c:1351
Definition: mem.c:156
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
#define GetProcAddress(x, y)
Definition: compat.h:418
static void test__mbsnbcpy_s(void)
Definition: string.c:934
static void test_mbcp(void)
Definition: string.c:223
static void test__wcsnset_s(void)
Definition: string.c:3312
static void test__wcslwr_s(void)
Definition: string.c:1210
static void test_memmove_s(void)
Definition: string.c:729
static void test__ultoa_s(void)
Definition: string.c:2667
static void test__strnset_s(void)
Definition: string.c:3282
static void test_strcat_s(void)
Definition: string.c:791
static void *__cdecl * pmemcpy(void *, const void *, size_t n)
static int * p__mb_cur_max
Definition: string.c:84
static void test__wcstoi64(void)
Definition: string.c:3030
static void test_tolower(void)
Definition: string.c:2860
static void test__wcsset_s(void)
Definition: string.c:3351

◆ test___strncnt()

static void test___strncnt ( void  )
static

Definition at line 3761 of file string.c.

3762 {
3763  static const struct
3764  {
3765  const char *str;
3766  size_t size;
3767  size_t ret;
3768  }
3769  strncnt_tests[] =
3770  {
3771  { NULL, 0, 0 },
3772  { "a", 0, 0 },
3773  { "a", 1, 1 },
3774  { "a", 10, 1 },
3775  { "abc", 1, 1 },
3776  };
3777  unsigned int i;
3778  size_t ret;
3779 
3780  if (!p___strncnt)
3781  {
3782  win_skip("__strncnt() is not available.\n");
3783  return;
3784  }
3785 
3786  if (0) /* crashes */
3787  ret = p___strncnt(NULL, 1);
3788 
3789  for (i = 0; i < ARRAY_SIZE(strncnt_tests); ++i)
3790  {
3791  ret = p___strncnt(strncnt_tests[i].str, strncnt_tests[i].size);
3792  ok(ret == strncnt_tests[i].ret, "%u: unexpected return value %u.\n", i, (int)ret);
3793  }
3794 }
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
const WCHAR * str
smooth NULL
Definition: ftsmooth.c:416
GLsizeiptr size
Definition: glext.h:5919
int ret
#define ARRAY_SIZE(a)
Definition: main.h:24
#define ok(value,...)
Definition: atltest.h:57
static size_t size
Definition: string.c:62
#define win_skip
Definition: test.h:150

Referenced by START_TEST().

◆ test__atodbl()

static void test__atodbl ( void  )
static

Definition at line 2938 of file string.c.

2939 {
2940  _CRT_DOUBLE d;
2941  char num[32];
2942  int ret;
2943 
2944  if(!p__atodbl_l) {
2945  /* Old versions of msvcrt use different values for _OVERFLOW and _UNDERFLOW
2946  * Because of this lets skip _atodbl tests when _atodbl_l is not available */
2947  win_skip("_atodbl_l is not available\n");
2948  return;
2949  }
2950 
2951  num[0] = 0;
2952  ret = p__atodbl_l(&d, num, NULL);
2953  ok(ret == 0, "_atodbl_l(&d, \"\", NULL) returned %d, expected 0\n", ret);
2954  ok(d.x == 0, "d.x = %lf, expected 0\n", d.x);
2955  ret = _atodbl(&d, num);
2956  ok(ret == 0, "_atodbl(&d, \"\") returned %d, expected 0\n", ret);
2957  ok(d.x == 0, "d.x = %lf, expected 0\n", d.x);
2958 
2959  strcpy(num, "t");
2960  ret = p__atodbl_l(&d, num, NULL);
2961  ok(ret == 0, "_atodbl_l(&d, \"t\", NULL) returned %d, expected 0\n", ret);
2962  ok(d.x == 0, "d.x = %lf, expected 0\n", d.x);
2963  ret = _atodbl(&d, num);
2964  ok(ret == 0, "_atodbl(&d, \"t\") returned %d, expected 0\n", ret);
2965  ok(d.x == 0, "d.x = %lf, expected 0\n", d.x);
2966 
2967  strcpy(num, "0");
2968  ret = p__atodbl_l(&d, num, NULL);
2969  ok(ret == 0, "_atodbl_l(&d, \"0\", NULL) returned %d, expected 0\n", ret);
2970  ok(d.x == 0, "d.x = %lf, expected 0\n", d.x);
2971  ret = _atodbl(&d, num);
2972  ok(ret == 0, "_atodbl(&d, \"0\") returned %d, expected 0\n", ret);
2973  ok(d.x == 0, "d.x = %lf, expected 0\n", d.x);
2974 
2975  strcpy(num, "123");
2976  ret = p__atodbl_l(&d, num, NULL);
2977  ok(ret == 0, "_atodbl_l(&d, \"123\", NULL) returned %d, expected 0\n", ret);
2978  ok(d.x == 123, "d.x = %lf, expected 123\n", d.x);
2979  ret = _atodbl(&d, num);
2980  ok(ret == 0, "_atodbl(&d, \"123\") returned %d, expected 0\n", ret);
2981  ok(d.x == 123, "d.x = %lf, expected 123\n", d.x);
2982 
2983  strcpy(num, "1e-309");
2984  ret = p__atodbl_l(&d, num, NULL);
2985  ok(ret == _UNDERFLOW, "_atodbl_l(&d, \"1e-309\", NULL) returned %d, expected _UNDERFLOW\n", ret);
2986  ok(d.x!=0 && almost_equal(d.x, 0), "d.x = %le, expected 0\n", d.x);
2987  ret = _atodbl(&d, num);
2988  ok(ret == _UNDERFLOW, "_atodbl(&d, \"1e-309\") returned %d, expected _UNDERFLOW\n", ret);
2989  ok(d.x!=0 && almost_equal(d.x, 0), "d.x = %le, expected 0\n", d.x);
2990 
2991  strcpy(num, "1e309");
2992  ret = p__atodbl_l(&d, num, NULL);
2993  ok(ret == _OVERFLOW, "_atodbl_l(&d, \"1e309\", NULL) returned %d, expected _OVERFLOW\n", ret);
2994  ret = _atodbl(&d, num);
2995  ok(ret == _OVERFLOW, "_atodbl(&d, \"1e309\") returned %d, expected _OVERFLOW\n", ret);
2996 }
smooth NULL
Definition: ftsmooth.c:416
#define d
Definition: ke_i.h:81
GLuint GLuint num
Definition: glext.h:9618
int ret
#define _UNDERFLOW
Definition: math.h:42
int _atodbl(void *value, char *str)
Definition: stubs.c:29
#define ok(value,...)
Definition: atltest.h:57
static BOOL almost_equal(double d1, double d2)
Definition: string.c:1841
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
#define win_skip
Definition: test.h:150
#define _OVERFLOW
Definition: math.h:41

Referenced by START_TEST().

◆ test__ismbclx()

static void test__ismbclx ( void  )
static

Definition at line 3416 of file string.c.

3417 {
3418  int ret, cp = _getmbcp();
3419 
3420  ret = _ismbcl0(0);
3421  ok(!ret, "got %d\n", ret);
3422 
3423  ret = _ismbcl1(0);
3424  ok(!ret, "got %d\n", ret);
3425 
3426  ret = _ismbcl2(0);
3427  ok(!ret, "got %d\n", ret);
3428 
3429  _setmbcp(1252);
3430 
3431  ret = _ismbcl0(0x8140);
3432  ok(!ret, "got %d\n", ret);
3433 
3434  ret = _ismbcl1(0x889f);
3435  ok(!ret, "got %d\n", ret);
3436 
3437  ret = _ismbcl2(0x989f);
3438  ok(!ret, "got %d\n", ret);
3439 
3440  _setmbcp(932);
3441 
3442  ret = _ismbcl0(0);
3443  ok(!ret, "got %d\n", ret);
3444 
3445  ret = _ismbcl0(0x8140);
3446  ok(ret, "got %d\n", ret);
3447 
3448  ret = _ismbcl0(0x817f);
3449  ok(!ret, "got %d\n", ret);
3450 
3451  ret = _ismbcl1(0);
3452  ok(!ret, "got %d\n", ret);
3453 
3454  ret = _ismbcl1(0x889f);
3455  ok(ret, "got %d\n", ret);
3456 
3457  ret = _ismbcl1(0x88fd);
3458  ok(!ret, "got %d\n", ret);
3459 
3460  ret = _ismbcl2(0);
3461  ok(!ret, "got %d\n", ret);
3462 
3463  ret = _ismbcl2(0x989f);
3464  ok(ret, "got %d\n", ret);
3465 
3466  ret = _ismbcl2(0x993f);
3467  ok(!ret, "got %d\n", ret);
3468 
3469  _setmbcp(cp);
3470 }
_Check_return_ _CRTIMP int __cdecl _ismbcl1(_In_ unsigned int _Ch)
_CRTIMP int __cdecl _getmbcp(void)
Definition: locale.c:1472
int __cdecl _setmbcp(int)
Definition: _setmbcp.c:218
_Check_return_ _CRTIMP int __cdecl _ismbcl2(_In_ unsigned int _Ch)
_Check_return_ _CRTIMP int __cdecl _ismbcl0(_In_ unsigned int _Ch)
int ret
#define ok(value,...)
Definition: atltest.h:57
POINT cp
Definition: magnifier.c:59

Referenced by START_TEST().

◆ test__itoa_s()

static void test__itoa_s ( void  )
static

Definition at line 2217 of file string.c.

2218 {
2219  errno_t ret;
2220  char buffer[33];
2221 
2222  if (!p_itoa_s)
2223  {
2224  win_skip("Skipping _itoa_s tests\n");
2225  return;
2226  }
2227 
2228  errno = EBADF;
2229  ret = p_itoa_s(0, NULL, 0, 0);
2230  ok(ret == EINVAL, "Expected _itoa_s to return EINVAL, got %d\n", ret);
2231  ok(errno == EINVAL, "Expected errno to be EINVAL, got %d\n", errno);
2232 
2233  memset(buffer, 'X', sizeof(buffer));
2234  errno = EBADF;
2235  ret = p_itoa_s(0, buffer, 0, 0);
2236  ok(ret == EINVAL, "Expected _itoa_s to return EINVAL, got %d\n", ret);
2237  ok(errno == EINVAL, "Expected errno to be EINVAL, got %d\n", errno);
2238  ok(buffer[0] == 'X', "Expected the output buffer to be untouched\n");
2239 
2240  memset(buffer, 'X', sizeof(buffer));
2241  errno = EBADF;
2242  ret = p_itoa_s(0, buffer, sizeof(buffer), 0);
2243  ok(ret == EINVAL, "Expected _itoa_s to return EINVAL, got %d\n", ret);
2244  ok(errno == EINVAL, "Expected errno to be EINVAL, got %d\n", errno);
2245  ok(buffer[0] == '\0', "Expected the output buffer to be null terminated\n");
2246 
2247  memset(buffer, 'X', sizeof(buffer));
2248  errno = EBADF;
2249  ret = p_itoa_s(0, buffer, sizeof(buffer), 64);
2250  ok(ret == EINVAL, "Expected _itoa_s to return EINVAL, got %d\n", ret);
2251  ok(errno == EINVAL, "Expected errno to be EINVAL, got %d\n", errno);
2252  ok(buffer[0] == '\0', "Expected the output buffer to be null terminated\n");
2253 
2254  memset(buffer, 'X', sizeof(buffer));
2255  errno = EBADF;
2256  ret = p_itoa_s(12345678, buffer, 4, 10);
2257  ok(ret == ERANGE, "Expected _itoa_s to return ERANGE, got %d\n", ret);
2258  ok(errno == ERANGE, "Expected errno to be ERANGE, got %d\n", errno);
2259  ok(!memcmp(buffer, "\000765", 4),
2260  "Expected the output buffer to be null terminated with truncated output\n");
2261 
2262  memset(buffer, 'X', sizeof(buffer));
2263  errno = EBADF;
2264  ret = p_itoa_s(12345678, buffer, 8, 10);
2265  ok(ret == ERANGE, "Expected _itoa_s to return ERANGE, got %d\n", ret);
2266  ok(errno == ERANGE, "Expected errno to be ERANGE, got %d\n", errno);
2267  ok(!memcmp(buffer, "\0007654321", 8),
2268  "Expected the output buffer to be null terminated with truncated output\n");
2269 
2270  memset(buffer, 'X', sizeof(buffer));
2271  errno = EBADF;
2272  ret = p_itoa_s(-12345678, buffer, 9, 10);
2273  ok(ret == ERANGE, "Expected _itoa_s to return ERANGE, got %d\n", ret);
2274  ok(errno == ERANGE, "Expected errno to be ERANGE, got %d\n", errno);
2275  ok(!memcmp(buffer, "\00087654321", 9),
2276  "Expected the output buffer to be null terminated with truncated output\n");
2277 
2278  ret = p_itoa_s(12345678, buffer, 9, 10);
2279  ok(ret == 0, "Expected _itoa_s to return 0, got %d\n", ret);
2280  ok(!strcmp(buffer, "12345678"),
2281  "Expected output buffer string to be \"12345678\", got \"%s\"\n",
2282  buffer);
2283 
2284  ret = p_itoa_s(43690, buffer, sizeof(buffer), 2);
2285  ok(ret == 0, "Expected _itoa_s to return 0, got %d\n", ret);
2286  ok(!strcmp(buffer, "1010101010101010"),
2287  "Expected output buffer string to be \"1010101010101010\", got \"%s\"\n",
2288  buffer);
2289 
2290  ret = p_itoa_s(1092009, buffer, sizeof(buffer), 36);
2291  ok(ret == 0, "Expected _itoa_s to return 0, got %d\n", ret);
2292  ok(!strcmp(buffer, "nell"),
2293  "Expected output buffer string to be \"nell\", got \"%s\"\n",
2294  buffer);
2295 
2296  ret = p_itoa_s(5704, buffer, sizeof(buffer), 18);
2297  ok(ret == 0, "Expected _itoa_s to return 0, got %d\n", ret);
2298  ok(!strcmp(buffer, "hag"),
2299  "Expected output buffer string to be \"hag\", got \"%s\"\n",
2300  buffer);
2301 
2302  ret = p_itoa_s(-12345678, buffer, sizeof(buffer), 10);
2303  ok(ret == 0, "Expected _itoa_s to return 0, got %d\n", ret);
2304  ok(!strcmp(buffer, "-12345678"),
2305  "Expected output buffer string to be \"-12345678\", got \"%s\"\n",
2306  buffer);
2307 
2308  itoa(100, buffer, 100);
2309  ok(!strcmp(buffer, "10"),
2310  "Expected output buffer string to be \"10\", got \"%s\"\n", buffer);
2311 }
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
Definition: arc.h:39
GLuint buffer
Definition: glext.h:5915
int errno
Definition: arc.h:36
smooth NULL
Definition: ftsmooth.c:416
int errno_t
Definition: crtdefs.h:353
_CRTIMP char *__cdecl itoa(_In_ int _Val, _Pre_notnull_ _Post_z_ char *_DstBuf, _In_ int _Radix)
#define ERANGE
Definition: acclib.h:92
int ret
#define ok(value,...)
Definition: atltest.h:57
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
#define memset(x, y, z)
Definition: compat.h:39
#define win_skip
Definition: test.h:150

Referenced by START_TEST().

◆ test__mbscat_s()

static void test__mbscat_s ( void  )
static

Definition at line 854 of file string.c.

855 {
856  unsigned char dst[8], src[4];
857  int err;
858  int prev_cp = _getmbcp();
859 
860  if(!p_mbscat_s)
861  {
862  win_skip("_mbscat_s not found\n");
863  return;
864  }
865 
866 
867  src[0] = dst[0] = 0;
868  err = p_mbscat_s(NULL, sizeof(dst), src);
869  ok(err == EINVAL, "_mbscat_s returned %d\n", err);
870 
871  err = p_mbscat_s(dst, sizeof(dst), NULL);
872  ok(err == EINVAL, "_mbscat_s returned %d\n", err);
873 
874  dst[0] = 'a';
875  err = p_mbscat_s(dst, 1, src);
876  ok(err == EINVAL, "_mbscat_s returned %d\n", err);
877 
878  memset(dst, 'a', sizeof(dst));
879  dst[6] = 0;
880  src[0] = 'b';
881  src[1] = 0;
882 
883  err = p_mbscat_s(dst, sizeof(dst), src);
884  ok(err == 0, "_mbscat_s returned %d\n", err);
885  ok(!memcmp(dst, "aaaaaab", 8), "dst = %s\n", dst);
886 
887  err = p_mbscat_s(dst, sizeof(dst), src);
888  ok(err == ERANGE, "_mbscat_s returned %d\n", err);
889  ok(!dst[0], "dst[0] = %c\n", dst[0]);
890  ok(dst[1] == 'a', "dst[1] = %c\n", dst[1]);
891 
892  _setmbcp(932);
893  /* test invalid str in dst */
894  dst[0] = 0x81;
895  dst[1] = 0x81;
896  dst[2] = 0x52;
897  dst[3] = 0;
898  src[0] = 'a';
899  src[1] = 0;
900  err = p_mbscat_s(dst, sizeof(dst), src);
901  ok(err == 0, "_mbscat_s returned %d\n", err);
902 
903  /* test invalid str in src */
904  dst[0] = 0;
905  src[0] = 0x81;
906  src[1] = 0x81;
907  src[2] = 0x52;
908  src[3] = 0;
909  err = p_mbscat_s(dst, sizeof(dst), src);
910  ok(err == 0, "_mbscat_s returned %d\n", err);
911 
912  /* test dst with leading byte on the end of buffer */
913  dst[0] = 'a';
914  dst[1] = 0x81;
915  dst[2] = 0;
916  src[0] = 'R';
917  src[1] = 0;
918  err = p_mbscat_s(dst, sizeof(dst), src);
919  ok(err == EILSEQ, "_mbscat_s returned %d\n", err);
920  ok(!memcmp(dst, "aR", 3), "dst = %s\n", dst);
921 
922  /* test src with leading byte on the end of buffer */
923  dst[0] = 'a';
924  dst[1] = 0;
925  src[0] = 'b';
926  src[1] = 0x81;
927  src[2] = 0;
928  err = p_mbscat_s(dst, sizeof(dst), src);
929  ok(err == EILSEQ, "_mbscat_s returned %d\n", err);
930  ok(!memcmp(dst, "ab", 3), "dst = %s\n", dst);
931  _setmbcp(prev_cp);
932 }
#define EILSEQ
Definition: errno.h:97
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
Definition: arc.h:39
_CRTIMP int __cdecl _getmbcp(void)
Definition: locale.c:1472
smooth NULL
Definition: ftsmooth.c:416
int __cdecl _setmbcp(int)
Definition: _setmbcp.c:218
#define ERANGE
Definition: acclib.h:92
GLenum src
Definition: glext.h:6340
#define err(...)
#define ok(value,...)
Definition: atltest.h:57
GLenum GLenum dst
Definition: glext.h:6340
#define memset(x, y, z)
Definition: compat.h:39
#define win_skip
Definition: test.h:150

Referenced by START_TEST().

◆ test__mbscmp()

static void test__mbscmp ( void  )
static

Definition at line 3386 of file string.c.

3387 {
3388  static const unsigned char a[] = {'a',0}, b[] = {'b',0};
3389  int ret;
3390 
3391  if (!p_mbrlen)
3392  {
3393  win_skip("_mbscmp tests\n");
3394  return;
3395  }
3396 
3397  ret = _mbscmp(NULL, NULL);
3398  ok(ret == INT_MAX, "got %d\n", ret);
3399 
3400  ret = _mbscmp(a, NULL);
3401  ok(ret == INT_MAX, "got %d\n", ret);
3402 
3403  ret = _mbscmp(NULL, a);
3404  ok(ret == INT_MAX, "got %d\n", ret);
3405 
3406  ret = _mbscmp(a, a);
3407  ok(!ret, "got %d\n", ret);
3408 
3409  ret = _mbscmp(a, b);
3410  ok(ret == -1, "got %d\n", ret);
3411 
3412  ret = _mbscmp(b, a);
3413  ok(ret == 1, "got %d\n", ret);
3414 }
#define INT_MAX
Definition: limits.h:40
smooth NULL
Definition: ftsmooth.c:416
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
_Check_return_ _CRTIMP int __cdecl _mbscmp(_In_z_ const unsigned char *_Str1, _In_z_ const unsigned char *_Str2)
int ret
#define ok(value,...)
Definition: atltest.h:57
GLboolean GLboolean GLboolean GLboolean a
Definition: glext.h:6204
#define win_skip
Definition: test.h:150

Referenced by START_TEST().

◆ test__mbscpy_s()

static void test__mbscpy_s ( void  )
static

Definition at line 981 of file string.c.

982 {
983  const unsigned char src[] = "source string";
984  unsigned char dest[16];
985  int ret;
986 
987  if(!p__mbscpy_s)
988  {
989  win_skip("_mbscpy_s not found\n");
990  return;
991  }
992 
993  ret = p__mbscpy_s(NULL, 0, src);
994  ok(ret == EINVAL, "got %d\n", ret);
995  ret = p__mbscpy_s(NULL, sizeof(dest), src);
996  ok(ret == EINVAL, "got %d\n", ret);
997  ret = p__mbscpy_s(dest, 0, src);
998  ok(ret == EINVAL, "got %d\n", ret);
999  dest[0] = 'x';
1000  ret = p__mbscpy_s(dest, sizeof(dest), NULL);
1001  ok(ret == EINVAL, "got %d\n", ret);
1002  ok(!dest[0], "dest buffer was not modified on invalid argument\n");
1003 
1004  memset(dest, 'X', sizeof(dest));
1005  ret = p__mbscpy_s(dest, sizeof(dest), src);
1006  ok(!ret, "got %d\n", ret);
1007  ok(!memcmp(dest, src, sizeof(src)), "dest = %s\n", dest);
1008  ok(dest[sizeof(src)] == 'X', "unused part of buffer was modified\n");
1009 
1010  memset(dest, 'X', sizeof(dest));
1011  ret = p__mbscpy_s(dest, 4, src);
1012  ok(ret == ERANGE, "got %d\n", ret);
1013  ok(!dest[0], "incorrect dest buffer (%d)\n", dest[0]);
1014  ok(dest[1] == src[1], "incorrect dest buffer (%d)\n", dest[1]);
1015 }
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
Definition: arc.h:39
smooth NULL
Definition: ftsmooth.c:416
#define ERANGE
Definition: acclib.h:92
int ret
GLenum src
Definition: glext.h:6340
#define ok(value,...)
Definition: atltest.h:57
static char * dest
Definition: rtl.c:135
#define memset(x, y, z)
Definition: compat.h:39
#define win_skip
Definition: test.h:150

Referenced by START_TEST().

◆ test__mbslwr_s()

static void test__mbslwr_s ( void  )
static

Definition at line 2593 of file string.c.

2594 {
2595  errno_t ret;
2596  unsigned char buffer[20];
2597 
2598  if (!p_mbslwr_s)
2599  {
2600  win_skip("Skipping _mbslwr_s tests\n");
2601  return;
2602  }
2603 
2604  errno = EBADF;
2605  ret = p_mbslwr_s(NULL, 0);
2606  ok(ret == 0, "Expected _mbslwr_s to return 0, got %d\n", ret);
2607 
2608  errno = EBADF;
2609  ret = p_mbslwr_s(NULL, sizeof(buffer));
2610  ok(ret == EINVAL, "Expected _mbslwr_s to return EINVAL, got %d\n", ret);
2611  ok(errno == EINVAL, "Expected errno to be EINVAL, got %d\n", errno);
2612 
2613  errno = EBADF;
2614  ret = p_mbslwr_s(buffer, 0);
2615  ok(ret == EINVAL, "Expected _mbslwr_s to return EINVAL, got %d\n", ret);
2616  ok(errno == EINVAL, "Expected errno to be EINVAL, got %d\n", errno);
2617 
2618  memcpy(buffer, "ABCDEFGH", sizeof("ABCDEFGH"));
2619  errno = EBADF;
2620  ret = p_mbslwr_s(buffer, sizeof("ABCDEFGH"));
2621  ok(ret == 0, "Expected _mbslwr_s to return 0, got %d\n", ret);
2622  ok(!memcmp(buffer, "abcdefgh", sizeof("abcdefgh")),
2623  "Expected the output buffer to be \"abcdefgh\", got \"%s\"\n",
2624  buffer);
2625 
2626  memcpy(buffer, "ABCDEFGH", sizeof("ABCDEFGH"));
2627  errno = EBADF;
2628  ret = p_mbslwr_s(buffer, sizeof(buffer));
2629  ok(ret == 0, "Expected _mbslwr_s to return 0, got %d\n", ret);
2630  ok(!memcmp(buffer, "abcdefgh", sizeof("abcdefgh")),
2631  "Expected the output buffer to be \"abcdefgh\", got \"%s\"\n",
2632  buffer);
2633 
2634  memcpy(buffer, "ABCDEFGH", sizeof("ABCDEFGH"));
2635  errno = EBADF;
2636  ret = p_mbslwr_s(buffer, 4);
2637  ok(ret == EINVAL, "Expected _mbslwr_s to return EINVAL, got %d\n", ret);
2638  ok(errno == EINVAL, "Expected errno to be EINVAL, got %d\n", errno);
2639 
2640  memcpy(buffer, "ABCDEFGH\0IJKLMNOP", sizeof("ABCDEFGH\0IJKLMNOP"));
2641  errno = EBADF;
2642  ret = p_mbslwr_s(buffer, sizeof(buffer));
2643  ok(ret == 0, "Expected _mbslwr_s to return 0, got %d\n", ret);
2644  ok(!memcmp(buffer, "abcdefgh\0IJKLMNOP", sizeof("abcdefgh\0IJKLMNOP")),
2645  "Expected the output buffer to be \"abcdefgh\\0IJKLMNOP\", got \"%s\"\n",
2646  buffer);
2647 }
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
Definition: arc.h:39
GLuint buffer
Definition: glext.h:5915
int errno
Definition: arc.h:36
smooth NULL
Definition: ftsmooth.c:416
int errno_t
Definition: crtdefs.h:353
int ret
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define ok(value,...)
Definition: atltest.h:57
#define win_skip
Definition: test.h:150

Referenced by START_TEST().

◆ test__mbsnbcat_s()

static void test__mbsnbcat_s ( void  )
static

Definition at line 2409 of file string.c.

2410 {
2411  unsigned char dest[16];
2412  const unsigned char first[] = "dinosaur";
2413  const unsigned char second[] = "duck";
2414  int ret;
2415 
2416  if (!p_mbsnbcat_s)
2417  {
2418  win_skip("Skipping _mbsnbcat_s tests\n");
2419  return;
2420  }
2421 
2422  /* Test invalid arguments. */
2423  ret = p_mbsnbcat_s(NULL, 0, NULL, 0);
2424  ok(ret == 0, "Expected _mbsnbcat_s to return 0, got %d\n", ret);
2425 
2426  errno = EBADF;
2427  ret = p_mbsnbcat_s(NULL, 10, NULL, 0);
2428  ok(ret == EINVAL, "Expected _mbsnbcat_s to return EINVAL, got %d\n", ret);
2429  ok(errno == EINVAL, "Expected errno to be EINVAL, got %d\n", errno);
2430 
2431  errno = EBADF;
2432  ret = p_mbsnbcat_s(NULL, 0, NULL, 10);
2433  ok(ret == EINVAL, "Expected _mbsnbcat_s to return EINVAL, got %d\n", ret);
2434  ok(errno == EINVAL, "Expected errno to be EINVAL, got %d\n", errno);
2435 
2436  memset(dest, 'X', sizeof(dest));
2437  errno = EBADF;
2438  ret = p_mbsnbcat_s(dest, 0, NULL, 0);
2439  ok(ret == EINVAL, "Expected _mbsnbcat_s to return EINVAL, got %d\n", ret);
2440  ok(errno == EINVAL, "Expected errno to be EINVAL, got %d\n", errno);
2441  ok(dest[0] == 'X', "Expected the output buffer to be untouched\n");
2442 
2443  memset(dest, 'X', sizeof(dest));
2444  errno = EBADF;
2445  ret = p_mbsnbcat_s(dest, 0, second, 0);
2446  ok(ret == EINVAL, "Expected _mbsnbcat_s to return EINVAL, got %d\n", ret);
2447  ok(errno == EINVAL, "Expected errno to be EINVAL, got %d\n", errno);
2448  ok(dest[0] == 'X', "Expected the output buffer to be untouched\n");
2449 
2450  memset(dest, 'X', sizeof(dest));
2451  errno = EBADF;
2452  ret = p_mbsnbcat_s(dest, sizeof(dest), NULL, 0);
2453  ok(ret == EINVAL, "Expected _mbsnbcat_s to return EINVAL, got %d\n", ret);
2454  ok(errno == EINVAL, "Expected errno to be EINVAL, got %d\n", errno);
2455  ok(dest[0] == '\0', "Expected the output buffer to be null terminated\n");
2456 
2457  memset(dest, 'X', sizeof(dest));
2458  errno = EBADF;
2459  ret = p_mbsnbcat_s(dest, sizeof(dest), NULL, 10);
2460  ok(ret == EINVAL, "Expected _mbsnbcat_s to return EINVAL, got %d\n", ret);
2461  ok(errno == EINVAL, "Expected errno to be EINVAL, got %d\n", errno);
2462  ok(dest[0] == '\0', "Expected the output buffer to be null terminated\n");
2463 
2464  memset(dest, 'X', sizeof(dest));
2465  dest[0] = '\0';
2466  ret = p_mbsnbcat_s(dest, sizeof(dest), second, sizeof(second));
2467  ok(ret == 0, "Expected _mbsnbcat_s to return 0, got %d\n", ret);
2468  ok(!memcmp(dest, second, sizeof(second)),
2469  "Expected the output buffer string to be \"duck\"\n");
2470 
2471  /* Test source truncation behavior. */
2472  memset(dest, 'X', sizeof(dest));
2473  memcpy(dest, first, sizeof(first));
2474  ret = p_mbsnbcat_s(dest, sizeof(dest), second, 0);
2475  ok(ret == 0, "Expected _mbsnbcat_s to return 0, got %d\n", ret);
2476  ok(!memcmp(dest, first, sizeof(first)),
2477  "Expected the output buffer string to be \"dinosaur\"\n");
2478 
2479  memset(dest, 'X', sizeof(dest));
2480  memcpy(dest, first, sizeof(first));
2481  ret = p_mbsnbcat_s(dest, sizeof(dest), second, sizeof(second));
2482  ok(ret == 0, "Expected _mbsnbcat_s to return 0, got %d\n", ret);
2483  ok(!memcmp(dest, "dinosaurduck", sizeof("dinosaurduck")),
2484  "Expected the output buffer string to be \"dinosaurduck\"\n");
2485 
2486  memset(dest, 'X', sizeof(dest));
2487  memcpy(dest, first, sizeof(first));
2488  ret = p_mbsnbcat_s(dest, sizeof(dest), second, sizeof(second) + 1);
2489  ok(ret == 0, "Expected _mbsnbcat_s to return 0, got %d\n", ret);
2490  ok(!memcmp(dest, "dinosaurduck", sizeof("dinosaurduck")),
2491  "Expected the output buffer string to be \"dinosaurduck\"\n");
2492 
2493  memset(dest, 'X', sizeof(dest));
2494  memcpy(dest, first, sizeof(first));
2495  ret = p_mbsnbcat_s(dest, sizeof(dest), second, sizeof(second) - 1);
2496  ok(ret == 0, "Expected _mbsnbcat_s to return 0, got %d\n", ret);
2497  ok(!memcmp(dest, "dinosaurduck", sizeof("dinosaurduck")),
2498  "Expected the output buffer string to be \"dinosaurduck\"\n");
2499 
2500  memset(dest, 'X', sizeof(dest));
2501  memcpy(dest, first, sizeof(first));
2502  ret = p_mbsnbcat_s(dest, sizeof(dest), second, sizeof(second) - 2);
2503  ok(ret == 0, "Expected _mbsnbcat_s to return 0, got %d\n", ret);
2504  ok(!memcmp(dest, "dinosaurduc", sizeof("dinosaurduc")),
2505  "Expected the output buffer string to be \"dinosaurduc\"\n");
2506 
2507  /* Test destination truncation behavior. */
2508  memset(dest, 'X', sizeof(dest));
2509  memcpy(dest, first, sizeof(first));
2510  errno = EBADF;
2511  ret = p_mbsnbcat_s(dest, sizeof(first) - 1, second, sizeof(second));
2512  ok(ret == EINVAL, "Expected _mbsnbcat_s to return EINVAL, got %d\n", ret);
2513  ok(errno == EINVAL, "Expected errno to be EINVAL, got %d\n", errno);
2514  ok(!memcmp(dest, "\0inosaur", sizeof("\0inosaur") - 1),
2515  "Expected the output buffer string to be \"\\0inosaur\" without ending null terminator\n");
2516 
2517  memset(dest, 'X', sizeof(dest));
2518  memcpy(dest, first, sizeof(first));
2519  errno = EBADF;
2520  ret = p_mbsnbcat_s(dest, sizeof(first), second, sizeof(second));
2521  ok(ret == ERANGE, "Expected _mbsnbcat_s to return ERANGE, got %d\n", ret);
2522  ok(errno == ERANGE, "Expected errno to be ERANGE, got %d\n", errno);
2523  ok(!memcmp(dest, "\0inosaurd", sizeof("\0inosaurd") - 1),
2524  "Expected the output buffer string to be \"\\0inosaurd\" without ending null terminator\n");
2525 
2526  memset(dest, 'X', sizeof(dest));
2527  memcpy(dest, first, sizeof(first));
2528  errno = EBADF;
2529  ret = p_mbsnbcat_s(dest, sizeof(first) + 1, second, sizeof(second));
2530  ok(ret == ERANGE, "Expected _mbsnbcat_s to return ERANGE, got %d\n", ret);
2531  ok(errno == ERANGE, "Expected errno to be ERANGE, got %d\n", errno);
2532  ok(!memcmp(dest, "\0inosaurdu", sizeof("\0inosaurdu") - 1),
2533  "Expected the output buffer string to be \"\\0inosaurdu\" without ending null terminator\n");
2534 }
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
Definition: arc.h:39
const GLint * first
Definition: glext.h:5794
int errno
Definition: arc.h:36
smooth NULL
Definition: ftsmooth.c:416
#define ERANGE
Definition: acclib.h:92
int ret
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define ok(value,...)
Definition: atltest.h:57
static char * dest
Definition: rtl.c:135
#define memset(x, y, z)
Definition: compat.h:39
#define win_skip
Definition: test.h:150

Referenced by START_TEST().

◆ test__mbsnbcpy_s()

static void test__mbsnbcpy_s ( void  )
static

Definition at line 934 of file string.c.

935 {
936  unsigned char dest[8];
937  const unsigned char big[] = "atoolongstringforthislittledestination";
938  const unsigned char small[] = "small";
939  int ret;
940 
941  if(!p_mbsnbcpy_s)
942  {
943  win_skip("_mbsnbcpy_s not found\n");
944  return;
945  }
946 
947  memset(dest, 'X', sizeof(dest));
948  ret = p_mbsnbcpy_s(dest, sizeof(dest), small, sizeof(small));
949  ok(ret == 0, "_mbsnbcpy_s: Copying a string into a big enough destination returned %d, expected 0\n", ret);
950  ok(dest[0] == 's' && dest[1] == 'm' && dest[2] == 'a' && dest[3] == 'l' &&
951  dest[4] == 'l' && dest[5] == '\0'&& dest[6] == 'X' && dest[7] == 'X',
952  "Unexpected return data from _mbsnbcpy_s: 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x\n",
953  dest[0], dest[1], dest[2], dest[3], dest[4], dest[5], dest[6], dest[7]);
954 
955  /* WTF? */
956  memset(dest, 'X', sizeof(dest));
957  ret = p_mbsnbcpy_s(dest, sizeof(dest) - 2, big, sizeof(small));
958  ok(ret == ERANGE, "_mbsnbcpy_s: Copying a too long string returned %d, expected ERANGE\n", ret);
959  ok(dest[0] == '\0'&& dest[1] == 't' && dest[2] == 'o' && dest[3] == 'o' &&
960  dest[4] == 'l' && dest[5] == 'o' && dest[6] == 'X' && dest[7] == 'X',
961  "Unexpected return data from _mbsnbcpy_s: 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x\n",
962  dest[0], dest[1], dest[2], dest[3], dest[4], dest[5], dest[6], dest[7]);
963 
964  memset(dest, 'X', sizeof(dest));
965  ret = p_mbsnbcpy_s(dest, sizeof(dest) - 2, big, 4);
966  ok(ret == 0, "_mbsnbcpy_s: Copying a too long string with a count cap returned %d, expected 0\n", ret);
967  ok(dest[0] == 'a' && dest[1] == 't' && dest[2] == 'o' && dest[3] == 'o' &&
968  dest[4] == '\0'&& dest[5] == 'X' && dest[6] == 'X' && dest[7] == 'X',
969  "Unexpected return data from _mbsnbcpy_s: 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x\n",
970  dest[0], dest[1], dest[2], dest[3], dest[4], dest[5], dest[6], dest[7]);
971 
972  memset(dest, 'X', sizeof(dest));
973  ret = p_mbsnbcpy_s(dest, sizeof(dest) - 2, small, sizeof(small) + 10);
974  ok(ret == 0, "_mbsnbcpy_s: Copying more data than the source string len returned %d, expected 0\n", ret);
975  ok(dest[0] == 's' && dest[1] == 'm' && dest[2] == 'a' && dest[3] == 'l' &&
976  dest[4] == 'l' && dest[5] == '\0'&& dest[6] == 'X' && dest[7] == 'X',
977  "Unexpected return data from _mbsnbcpy_s: 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x\n",
978  dest[0], dest[1], dest[2], dest[3], dest[4], dest[5], dest[6], dest[7]);
979 }
#define small
Definition: rpcndr.h:115
#define ERANGE
Definition: acclib.h:92
int ret
#define ok(value,...)
Definition: atltest.h:57
static char * dest
Definition: rtl.c:135
#define memset(x, y, z)
Definition: compat.h:39
#define win_skip
Definition: test.h:150

Referenced by START_TEST().

◆ test__mbstok()

static void test__mbstok ( void  )
static

Definition at line 2649 of file string.c.

2650 {
2651  const unsigned char delim[] = "t";
2652 
2653  char str[] = "!.!test";
2654  unsigned char *ret;
2655 
2656  strtok(str, "!");
2657 
2658  ret = _mbstok(NULL, delim);
2659  /* most versions of msvcrt use the same buffer for strtok and _mbstok */
2660  ok(!ret || broken((char*)ret==str+4),
2661  "_mbstok(NULL, \"t\") = %p, expected NULL (%p)\n", ret, str);
2662 
2663  ret = _mbstok(NULL, delim);
2664  ok(!ret, "_mbstok(NULL, \"t\") = %p, expected NULL\n", ret);
2665 }
_Check_return_ _CRTIMP unsigned char *__cdecl _mbstok(_Inout_opt_z_ unsigned char *_Str, _In_z_ const unsigned char *_Delim)
const WCHAR * str
smooth NULL
Definition: ftsmooth.c:416
int ret
#define broken(x)
Definition: _sntprintf.h:21
#define ok(value,...)
Definition: atltest.h:57
char * strtok(char *String, const char *Delimiters)
Definition: utclib.c:338

Referenced by START_TEST().

◆ test__mbsupr_s()

static void test__mbsupr_s ( void  )
static

Definition at line 2536 of file string.c.

2537 {
2538  errno_t ret;
2539  unsigned char buffer[20];
2540 
2541  if (!p_mbsupr_s)
2542  {
2543  win_skip("Skipping _mbsupr_s tests\n");
2544  return;
2545  }
2546 
2547  errno = EBADF;
2548  ret = p_mbsupr_s(NULL, 0);
2549  ok(ret == 0, "Expected _mbsupr_s to return 0, got %d\n", ret);
2550 
2551  errno = EBADF;
2552  ret = p_mbsupr_s(NULL, sizeof(buffer));
2553  ok(ret == EINVAL, "Expected _mbsupr_s to return EINVAL, got %d\n", ret);
2554  ok(errno == EINVAL, "Expected errno to be EINVAL, got %d\n", errno);
2555 
2556  errno = EBADF;
2557  ret = p_mbsupr_s(buffer, 0);
2558  ok(ret == EINVAL, "Expected _mbsupr_s to return EINVAL, got %d\n", ret);
2559  ok(errno == EINVAL, "Expected errno to be EINVAL, got %d\n", errno);
2560 
2561  memcpy(buffer, "abcdefgh", sizeof("abcdefgh"));
2562  errno = EBADF;
2563  ret = p_mbsupr_s(buffer, sizeof("abcdefgh"));
2564  ok(ret == 0, "Expected _mbsupr_s to return 0, got %d\n", ret);
2565  ok(!memcmp(buffer, "ABCDEFGH", sizeof("ABCDEFGH")),
2566  "Expected the output buffer to be \"ABCDEFGH\", got \"%s\"\n",
2567  buffer);
2568 
2569  memcpy(buffer, "abcdefgh", sizeof("abcdefgh"));
2570  errno = EBADF;
2571  ret = p_mbsupr_s(buffer, sizeof(buffer));
2572  ok(ret == 0, "Expected _mbsupr_s to return 0, got %d\n", ret);
2573  ok(!memcmp(buffer, "ABCDEFGH", sizeof("ABCDEFGH")),
2574  "Expected the output buffer to be \"ABCDEFGH\", got \"%s\"\n",
2575  buffer);
2576 
2577  memcpy(buffer, "abcdefgh", sizeof("abcdefgh"));
2578  errno = EBADF;
2579  ret = p_mbsupr_s(buffer, 4);
2580  ok(ret == EINVAL, "Expected _mbsupr_s to return EINVAL, got %d\n", ret);
2581  ok(errno == EINVAL, "Expected errno to be EINVAL, got %d\n", errno);
2582 
2583  memcpy(buffer, "abcdefgh\0ijklmnop", sizeof("abcdefgh\0ijklmnop"));
2584  errno = EBADF;
2585  ret = p_mbsupr_s(buffer, sizeof(buffer));
2586  ok(ret == 0, "Expected _mbsupr_s to return 0, got %d\n", ret);
2587  ok(!memcmp(buffer, "ABCDEFGH\0ijklmnop", sizeof("ABCDEFGH\0ijklmnop")),
2588  "Expected the output buffer to be \"ABCDEFGH\\0ijklmnop\", got \"%s\"\n",
2589  buffer);
2590 
2591 }
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
Definition: arc.h:39
GLuint buffer
Definition: glext.h:5915
int errno
Definition: arc.h:36
smooth NULL
Definition: ftsmooth.c:416
int errno_t
Definition: crtdefs.h:353
int ret
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define ok(value,...)
Definition: atltest.h:57
#define win_skip
Definition: test.h:150

Referenced by START_TEST().

◆ test__memicmp()

static void test__memicmp ( void  )
static

Definition at line 3472 of file string.c.

3473 {
3474  static const char *s1 = "abc";
3475  static const char *s2 = "aBd";
3476  int ret;
3477 
3478  ret = p__memicmp(NULL, NULL, 0);
3479  ok(!ret, "got %d\n", ret);
3480 
3481  ret = p__memicmp(s1, s2, 2);
3482  ok(!ret, "got %d\n", ret);
3483 
3484  ret = p__memicmp(s1, s2, 3);
3485  ok(ret == -1, "got %d\n", ret);
3486 
3487  if (!p__memicmp_l)
3488  return;
3489 
3490  /* Following calls crash on WinXP/W2k3. */
3491  errno = 0xdeadbeef;
3492  ret = p__memicmp(NULL, NULL, 1);
3493  ok(ret == _NLSCMPERROR, "got %d\n", ret);
3494  ok(errno == EINVAL, "errno is %d, expected EINVAL\n", errno);
3495 
3496  errno = 0xdeadbeef;
3497  ret = p__memicmp(s1, NULL, 1);
3498  ok(ret == _NLSCMPERROR, "got %d\n", ret);
3499  ok(errno == EINVAL, "errno is %d, expected EINVAL\n", errno);
3500 
3501  errno = 0xdeadbeef;
3502  ret = p__memicmp(NULL, s2, 1);
3503  ok(ret == _NLSCMPERROR, "got %d\n", ret);
3504  ok(errno == EINVAL, "errno is %d, expected EINVAL\n", errno);
3505 }
struct S2 s2
Definition: arc.h:39
int errno
smooth NULL
Definition: ftsmooth.c:416
struct S1 s1
int ret
#define ok(value,...)
Definition: atltest.h:57
#define _NLSCMPERROR
Definition: string.h:17

Referenced by START_TEST().

◆ test__memicmp_l()

static void test__memicmp_l ( void  )
static

Definition at line 3507 of file string.c.

3508 {
3509  static const char *s1 = "abc";
3510  static const char *s2 = "aBd";
3511  int ret;
3512 
3513  if (!p__memicmp_l)
3514  {
3515  win_skip("_memicmp_l not found.\n");
3516  return;
3517  }
3518 
3519  errno = 0xdeadbeef;
3520  ret = p__memicmp_l(NULL, NULL, 0, NULL);
3521  ok(!ret, "got %d\n", ret);
3522  ok(errno == 0xdeadbeef, "errno is %d, expected 0xdeadbeef\n", errno);
3523 
3524  errno = 0xdeadbeef;
3525  ret = p__memicmp_l(NULL, NULL, 1, NULL);
3526  ok(ret == _NLSCMPERROR, "got %d\n", ret);
3527  ok(errno == EINVAL, "errno is %d, expected EINVAL\n", errno);
3528 
3529  errno = 0xdeadbeef;
3530  ret = p__memicmp_l(s1, NULL, 1, NULL);
3531  ok(ret == _NLSCMPERROR, "got %d\n", ret);
3532  ok(errno == EINVAL, "errno is %d, expected EINVAL\n", errno);
3533 
3534  errno = 0xdeadbeef;
3535  ret = p__memicmp_l(NULL, s2, 1, NULL);
3536  ok(ret == _NLSCMPERROR, "got %d\n", ret);
3537  ok(errno == EINVAL, "errno is %d, expected EINVAL\n", errno);
3538 
3539  errno = 0xdeadbeef;
3540  ret = p__memicmp_l(s1, s2, 2, NULL);
3541  ok(!ret, "got %d\n", ret);
3542  ok(errno == 0xdeadbeef, "errno is %d, expected 0xdeadbeef\n", errno);
3543 
3544  errno = 0xdeadbeef;
3545  ret = p__memicmp_l(s1, s2, 3, NULL);
3546  ok(ret == -1, "got %d\n", ret);
3547  ok(errno == 0xdeadbeef, "errno is %d, expected 0xdeadbeef\n", errno);
3548 }
struct S2 s2
Definition: arc.h:39
int errno
smooth NULL
Definition: ftsmooth.c:416
struct S1 s1
int ret
#define ok(value,...)
Definition: atltest.h:57
#define _NLSCMPERROR
Definition: string.h:17
#define win_skip
Definition: test.h:150

Referenced by START_TEST().

◆ test__stricmp()

static void test__stricmp ( void  )
static

Definition at line 2998 of file string.c.

2999 {
3000  int ret;
3001 
3002  ret = _stricmp("test", "test");
3003  ok(ret == 0, "_stricmp returned %d\n", ret);
3004  ret = _stricmp("a", "z");
3005  ok(ret < 0, "_stricmp returned %d\n", ret);
3006  ret = _stricmp("z", "a");
3007  ok(ret > 0, "_stricmp returned %d\n", ret);
3008  ret = _stricmp("\xa5", "\xb9");
3009  ok(ret < 0, "_stricmp returned %d\n", ret);
3010 
3011  if(!setlocale(LC_ALL, "polish")) {
3012  win_skip("stricmp tests\n");
3013  return;
3014  }
3015 
3016  ret = _stricmp("test", "test");
3017  ok(ret == 0, "_stricmp returned %d\n", ret);
3018  ret = _stricmp("a", "z");
3019  ok(ret < 0, "_stricmp returned %d\n", ret);
3020  ret = _stricmp("z", "a");
3021  ok(ret > 0, "_stricmp returned %d\n", ret);
3022  ret = _stricmp("\xa5", "\xb9");
3023  ok(ret == 0, "_stricmp returned %d\n", ret);
3024  ret = _stricmp("a", "\xb9");
3025  ok(ret < 0, "_stricmp returned %d\n", ret);
3026 
3027  setlocale(LC_ALL, "C");
3028 }
#define LC_ALL
Definition: locale.h:25
int _stricmp(const char *str1, const char *str2)
Definition: string.c:11
int ret
#define ok(value,...)
Definition: atltest.h:57
#define setlocale(n, s)
Definition: locale.h:46
#define win_skip
Definition: test.h:150

Referenced by START_TEST().

◆ test__strlwr_s()

static void test__strlwr_s ( void  )
static

Definition at line 2313 of file string.c.

2314 {
2315  errno_t ret;
2316  char buffer[20];
2317 
2318  if (!p_strlwr_s)
2319  {
2320  win_skip("Skipping _strlwr_s tests\n");
2321  return;
2322  }
2323 
2324  errno = EBADF;
2325  ret = p_strlwr_s(NULL, 0);
2326  ok(ret == EINVAL, "Expected _strlwr_s to return EINVAL, got %d\n", ret);
2327  ok(errno == EINVAL, "Expected errno to be EINVAL, got %d\n", errno);
2328 
2329  errno = EBADF;
2330  ret = p_strlwr_s(NULL, sizeof(buffer));
2331  ok(ret == EINVAL, "Expected _strlwr_s to return EINVAL, got %d\n", ret);
2332  ok(errno == EINVAL, "Expected errno to be EINVAL, got %d\n", errno);
2333 
2334  errno = EBADF;
2335  ret = p_strlwr_s(buffer, 0);
2336  ok(ret == EINVAL, "Expected _strlwr_s to return EINVAL, got %d\n", ret);
2337  ok(errno == EINVAL, "Expected errno to be EINVAL, got %d\n", errno);
2338 
2339  strcpy(buffer, "GoRrIsTeR");
2340  errno = EBADF;
2341  ret = p_strlwr_s(buffer, 5);
2342  ok(ret == EINVAL, "Expected _strlwr_s to return EINVAL, got %d\n", ret);
2343  ok(errno == EINVAL, "Expected errno to be EINVAL, got %d\n", errno);
2344  ok(!memcmp(buffer, "\0oRrIsTeR", sizeof("\0oRrIsTeR")),
2345  "Expected the output buffer to be \"\\0oRrIsTeR\"\n");
2346 
2347  strcpy(buffer, "GoRrIsTeR");
2348  errno = EBADF;
2349  ret = p_strlwr_s(buffer, sizeof("GoRrIsTeR") - 1);
2350  ok(ret == EINVAL, "Expected _strlwr_s to return EINVAL, got %d\n", ret);
2351  ok(errno == EINVAL, "Expected errno to be EINVAL, got %d\n", errno);
2352  ok(!memcmp(buffer, "\0oRrIsTeR", sizeof("\0oRrIsTeR")),
2353  "Expected the output buffer to be \"\\0oRrIsTeR\"\n");
2354 
2355  strcpy(buffer, "GoRrIsTeR");
2356  ret = p_strlwr_s(buffer, sizeof("GoRrIsTeR"));
2357  ok(ret == 0, "Expected _strlwr_s to return 0, got %d\n", ret);
2358  ok(!strcmp(buffer, "gorrister"),
2359  "Expected the output buffer to be \"gorrister\", got \"%s\"\n",
2360  buffer);
2361 
2362  memcpy(buffer, "GoRrIsTeR\0ELLEN", sizeof("GoRrIsTeR\0ELLEN"));
2363  ret = p_strlwr_s(buffer, sizeof(buffer));
2364  ok(ret == 0, "Expected _strlwr_s to return 0, got %d\n", ret);
2365  ok(!memcmp(buffer, "gorrister\0ELLEN", sizeof("gorrister\0ELLEN")),
2366  "Expected the output buffer to be \"gorrister\\0ELLEN\", got \"%s\"\n",
2367  buffer);
2368 }
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
Definition: arc.h:39
GLuint buffer
Definition: glext.h:5915
int errno
Definition: arc.h:36
smooth NULL
Definition: ftsmooth.c:416
int errno_t
Definition: crtdefs.h:353
int ret
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define ok(value,...)
Definition: atltest.h:57
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
#define win_skip
Definition: test.h:150

Referenced by START_TEST().

◆ test__strnset_s()

static void test__strnset_s ( void  )
static

Definition at line 3282 of file string.c.

3283 {
3284  char buf[5] = {0};
3285  int r;
3286 
3287  if(!p__strnset_s) {
3288  win_skip("_strnset_s not available\n");
3289  return;
3290  }
3291 
3292  r = p__strnset_s(NULL, 0, 'a', 0);
3293  ok(r == 0, "r = %d\n", r);
3294 
3295  buf[0] = buf[1] = buf[2] = 'b';
3296  r = p__strnset_s(buf, sizeof(buf), 'a', 2);
3297  ok(r == 0, "r = %d\n", r);
3298  ok(!strcmp(buf, "aab"), "buf = %s\n", buf);
3299 
3300  r = p__strnset_s(buf, 0, 'a', 0);
3301  ok(r == EINVAL, "r = %d\n", r);
3302 
3303  r = p__strnset_s(NULL, 0, 'a', 1);
3304  ok(r == EINVAL, "r = %d\n", r);
3305 
3306  buf[3] = 'b';
3307  r = p__strnset_s(buf, sizeof(buf)-1, 'c', 2);
3308  ok(r == EINVAL, "r = %d\n", r);
3309  ok(!buf[0] && buf[1]=='c' && buf[2]=='b', "buf = %s\n", buf);
3310 }
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
Definition: arc.h:39
smooth NULL
Definition: ftsmooth.c:416
#define ok(value,...)
Definition: atltest.h:57
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
#define win_skip
Definition: test.h:150

Referenced by START_TEST().

◆ test__strtod()

static void test__strtod ( void  )
static

Definition at line 1847 of file string.c.

1848 {
1849  const char double1[] = "12.1";
1850  const char double2[] = "-13.721";
1851  const char double3[] = "INF";
1852  const char double4[] = ".21e12";
1853  const char double5[] = "214353e-3";
1854  const char double6[] = "NAN";
1855  const char overflow[] = "1d9999999999999999999";
1856  const char white_chars[] = " d10";
1857 
1858  char *end;
1859  double d;
1860 
1861  d = strtod(double1, &end);
1862  ok(almost_equal(d, 12.1), "d = %lf\n", d);
1863  ok(end == double1+4, "incorrect end (%d)\n", (int)(end-double1));
1864 
1865  d = strtod(double2, &end);
1866  ok(almost_equal(d, -13.721), "d = %lf\n", d);
1867  ok(end == double2+7, "incorrect end (%d)\n", (int)(end-double2));
1868 
1869  d = strtod(double3, &end);
1870  ok(almost_equal(d, 0), "d = %lf\n", d);
1871  ok(end == double3, "incorrect end (%d)\n", (int)(end-double3));
1872 
1873  d = strtod(double4, &end);
1874  ok(almost_equal(d, 210000000000.0), "d = %lf\n", d);
1875  ok(end == double4+6, "incorrect end (%d)\n", (int)(end-double4));
1876 
1877  d = strtod(double5, &end);
1878  ok(almost_equal(d, 214.353), "d = %lf\n", d);
1879  ok(end == double5+9, "incorrect end (%d)\n", (int)(end-double5));
1880 
1881  d = strtod(double6, &end);
1882  ok(almost_equal(d, 0), "d = %lf\n", d);
1883  ok(end == double6, "incorrect end (%d)\n", (int)(end-double6));
1884 
1885  d = strtod("12.1d2", NULL);
1886  ok(almost_equal(d, 12.1e2), "d = %lf\n", d);
1887 
1888  d = strtod(white_chars, &end);
1889  ok(almost_equal(d, 0), "d = %lf\n", d);
1890  ok(end == white_chars, "incorrect end (%d)\n", (int)(end-white_chars));
1891 
1892  if (!p__strtod_l)
1893  win_skip("_strtod_l not found\n");
1894  else
1895  {
1896  errno = EBADF;
1897  d = strtod(NULL, NULL);
1898  ok(almost_equal(d, 0.0), "d = %lf\n", d);
1899  ok(errno == EINVAL, "errno = %x\n", errno);
1900 
1901  errno = EBADF;
1902  end = (char *)0xdeadbeef;
1903  d = strtod(NULL, &end);
1904  ok(almost_equal(d, 0.0), "d = %lf\n", d);
1905  ok(errno == EINVAL, "errno = %x\n", errno);
1906  ok(!end, "incorrect end ptr %p\n", end);
1907 
1908  errno = EBADF;
1909  d = p__strtod_l(NULL, NULL, NULL);
1910  ok(almost_equal(d, 0.0), "d = %lf\n", d);
1911  ok(errno == EINVAL, "errno = %x\n", errno);
1912  }
1913 
1914  /* Set locale with non '.' decimal point (',') */
1915  if(!setlocale(LC_ALL, "Polish")) {
1916  win_skip("system with limited locales\n");
1917  return;
1918  }
1919 
1920  d = strtod("12.1", NULL);
1921  ok(almost_equal(d, 12.0), "d = %lf\n", d);
1922 
1923  d = strtod("12,1", NULL);
1924  ok(almost_equal(d, 12.1), "d = %lf\n", d);
1925 
1926  setlocale(LC_ALL, "C");
1927 
1928  /* Precision tests */
1929  d = strtod("0.1", NULL);
1930  ok(almost_equal(d, 0.1), "d = %lf\n", d);
1931  d = strtod("-0.1", NULL);
1932  ok(almost_equal(d, -0.1), "d = %lf\n", d);
1933  d = strtod("0.1281832188491894198128921", NULL);
1934  ok(almost_equal(d, 0.1281832188491894198128921), "d = %lf\n", d);
1935  d = strtod("0.82181281288121", NULL);
1936  ok(almost_equal(d, 0.82181281288121), "d = %lf\n", d);
1937  d = strtod("21921922352523587651128218821", NULL);
1938  ok(almost_equal(d, 21921922352523587651128218821.0), "d = %lf\n", d);
1939  d = strtod("0.1d238", NULL);
1940  ok(almost_equal(d, 0.1e238L), "d = %lf\n", d);
1941  d = strtod("0.1D-4736", NULL);
1942  ok(almost_equal(d, 0.1e-4736L), "d = %lf\n", d);
1943 
1944  errno = 0xdeadbeef;
1945  strtod(overflow, &end);
1946  ok(errno == ERANGE, "errno = %x\n", errno);
1947  ok(end == overflow+21, "incorrect end (%d)\n", (int)(end-overflow));
1948 
1949  errno = 0xdeadbeef;
1950  strtod("-1d309", NULL);
1951  ok(errno == ERANGE, "errno = %x\n", errno);
1952 }
_Check_return_ double __cdecl strtod(_In_z_ const char *_Str, _Out_opt_ _Deref_post_z_ char **_EndPtr)
Definition: arc.h:39
GLuint GLuint end
Definition: gl.h:1545
int errno
Definition: arc.h:36
#define e
Definition: ke_i.h:82
smooth NULL
Definition: ftsmooth.c:416
#define LC_ALL
Definition: locale.h:25
#define d
Definition: ke_i.h:81
#define ERANGE
Definition: acclib.h:92
static const WCHAR L[]
Definition: oid.c:1250
#define ok(value,...)
Definition: atltest.h:57
static BOOL almost_equal(double d1, double d2)
Definition: string.c:1841
#define setlocale(n, s)
Definition: locale.h:46
#define win_skip
Definition: test.h:150

Referenced by START_TEST().

◆ test__strtoi64()

static void test__strtoi64 ( void  )
static

Definition at line 1696 of file string.c.

1697 {
1698  static const char no1[] = "31923";
1699  static const char no2[] = "-213312";
1700  static const char no3[] = "12aa";
1701  static const char no4[] = "abc12";
1702  static const char overflow[] = "99999999999999999999";
1703  static const char neg_overflow[] = "-99999999999999999999";
1704  static const char hex[] = "0x123";
1705  static const char oct[] = "000123";
1706  static const char blanks[] = " 12 212.31";
1707 
1708  __int64 res;
1709  unsigned __int64 ures;
1710  char *endpos;
1711 
1712  if(!p_strtoi64 || !p_strtoui64) {
1713  win_skip("_strtoi64 or _strtoui64 not found\n");
1714  return;
1715  }
1716 
1717  errno = 0xdeadbeef;
1718  res = p_strtoi64(no1, NULL, 10);
1719  ok(res == 31923, "res != 31923\n");
1720  res = p_strtoi64(no2, NULL, 10);
1721  ok(res == -213312, "res != -213312\n");
1722  res = p_strtoi64(no3, NULL, 10);
1723  ok(res == 12, "res != 12\n");
1724  res = p_strtoi64(no4, &endpos, 10);
1725  ok(res == 0, "res != 0\n");
1726  ok(endpos == no4, "Scanning was not stopped on first character\n");
1727  res = p_strtoi64(hex, &endpos, 10);
1728  ok(res == 0, "res != 0\n");
1729  ok(endpos == hex+1, "Incorrect endpos (%p-%p)\n", hex, endpos);
1730  res = p_strtoi64(oct, &endpos, 10);
1731  ok(res == 123, "res != 123\n");
1732  ok(endpos == oct+strlen(oct), "Incorrect endpos (%p-%p)\n", oct, endpos);
1733  res = p_strtoi64(blanks, &endpos, 10);
1734  ok(res == 12, "res != 12\n");
1735  ok(endpos == blanks+10, "Incorrect endpos (%p-%p)\n", blanks, endpos);
1736  ok(errno == 0xdeadbeef, "errno = %x\n", errno);
1737 
1738  errno = 0xdeadbeef;
1739  res = p_strtoi64(overflow, &endpos, 10);
1740  ok(res == _I64_MAX, "res != _I64_MAX\n");
1741  ok(endpos == overflow+strlen(overflow), "Incorrect endpos (%p-%p)\n", overflow, endpos);
1742  ok(errno == ERANGE, "errno = %x\n", errno);
1743 
1744  errno = 0xdeadbeef;
1745  res = p_strtoi64(neg_overflow, &endpos, 10);
1746  ok(res == _I64_MIN, "res != _I64_MIN\n");
1747  ok(endpos == neg_overflow+strlen(neg_overflow), "Incorrect endpos (%p-%p)\n", neg_overflow, endpos);
1748  ok(errno == ERANGE, "errno = %x\n", errno);
1749 
1750  errno = 0xdeadbeef;
1751  res = p_strtoi64(no1, &endpos, 16);
1752  ok(res == 203043, "res != 203043\n");
1753  ok(endpos == no1+strlen(no1), "Incorrect endpos (%p-%p)\n", no1, endpos);
1754  res = p_strtoi64(no2, &endpos, 16);
1755  ok(res == -2175762, "res != -2175762\n");
1756  ok(endpos == no2+strlen(no2), "Incorrect endpos (%p-%p)\n", no2, endpos);
1757  res = p_strtoi64(no3, &endpos, 16);
1758  ok(res == 4778, "res != 4778\n");
1759  ok(endpos == no3+strlen(no3), "Incorrect endpos (%p-%p)\n", no3, endpos);
1760  res = p_strtoi64(no4, &endpos, 16);
1761  ok(res == 703506, "res != 703506\n");
1762  ok(endpos == no4+strlen(no4), "Incorrect endpos (%p-%p)\n", no4, endpos);
1763  res = p_strtoi64(hex, &endpos, 16);
1764  ok(res == 291, "res != 291\n");
1765  ok(endpos == hex+strlen(hex), "Incorrect endpos (%p-%p)\n", hex, endpos);
1766  res = p_strtoi64(oct, &endpos, 16);
1767  ok(res == 291, "res != 291\n");
1768  ok(endpos == oct+strlen(oct), "Incorrect endpos (%p-%p)\n", oct, endpos);
1769  res = p_strtoi64(blanks, &endpos, 16);
1770  ok(res == 18, "res != 18\n");
1771  ok(endpos == blanks+10, "Incorrect endpos (%p-%p)\n", blanks, endpos);
1772  ok(errno == 0xdeadbeef, "errno = %x\n", errno);
1773 
1774  errno = 0xdeadbeef;
1775  res = p_strtoi64(hex, &endpos, 36);
1776  ok(res == 1541019, "res != 1541019\n");
1777  ok(endpos == hex+strlen(hex), "Incorrect endpos (%p-%p)\n", hex, endpos);
1778  ok(errno == 0xdeadbeef, "errno = %x\n", errno);
1779 
1780  errno = 0xdeadbeef;
1781  res = p_strtoi64(no1, &endpos, 0);
1782  ok(res == 31923, "res != 31923\n");
1783  ok(endpos == no1+strlen(no1), "Incorrect endpos (%p-%p)\n", no1, endpos);
1784  res = p_strtoi64(no2, &endpos, 0);
1785  ok(res == -213312, "res != -213312\n");
1786  ok(endpos == no2+strlen(no2), "Incorrect endpos (%p-%p)\n", no2, endpos);
1787  res = p_strtoi64(no3, &endpos, 10);
1788  ok(res == 12, "res != 12\n");
1789  ok(endpos == no3+2, "Incorrect endpos (%p-%p)\n", no3, endpos);
1790  res = p_strtoi64(no4, &endpos, 10);
1791  ok(res == 0, "res != 0\n");
1792  ok(endpos == no4, "Incorrect endpos (%p-%p)\n", no4, endpos);
1793  res = p_strtoi64(hex, &endpos, 10);
1794  ok(res == 0, "res != 0\n");
1795  ok(endpos == hex+1, "Incorrect endpos (%p-%p)\n", hex, endpos);
1796  res = p_strtoi64(oct, &endpos, 10);
1797  ok(res == 123, "res != 123\n");
1798  ok(endpos == oct+strlen(oct), "Incorrect endpos (%p-%p)\n", oct, endpos);
1799  res = p_strtoi64(blanks, &endpos, 10);
1800  ok(res == 12, "res != 12\n");
1801  ok(endpos == blanks+10, "Incorrect endpos (%p-%p)\n", blanks, endpos);
1802  ok(errno == 0xdeadbeef, "errno = %x\n", errno);
1803 
1804  errno = 0xdeadbeef;
1805  ures = p_strtoui64(no1, &endpos, 0);
1806  ok(ures == 31923, "ures != 31923\n");
1807  ok(endpos == no1+strlen(no1), "Incorrect endpos (%p-%p)\n", no1, endpos);
1808  ures = p_strtoui64(no2, &endpos, 0);
1809  ok(ures == -213312, "ures != -213312\n");
1810  ok(endpos == no2+strlen(no2), "Incorrect endpos (%p-%p)\n", no2, endpos);
1811  ures = p_strtoui64(no3, &endpos, 10);
1812  ok(ures == 12, "ures != 12\n");
1813  ok(endpos == no3+2, "Incorrect endpos (%p-%p)\n", no3, endpos);
1814  ures = p_strtoui64(no4, &endpos, 10);
1815  ok(ures == 0, "ures != 0\n");
1816  ok(endpos == no4, "Incorrect endpos (%p-%p)\n", no4, endpos);
1817  ures = p_strtoui64(hex, &endpos, 10);
1818  ok(ures == 0, "ures != 0\n");
1819  ok(endpos == hex+1, "Incorrect endpos (%p-%p)\n", hex, endpos);
1820  ures = p_strtoui64(oct, &endpos, 10);
1821  ok(ures == 123, "ures != 123\n");
1822  ok(endpos == oct+strlen(oct), "Incorrect endpos (%p-%p)\n", oct, endpos);
1823  ures = p_strtoui64(blanks, &endpos, 10);
1824  ok(ures == 12, "ures != 12\n");
1825  ok(endpos == blanks+10, "Incorrect endpos (%p-%p)\n", blanks, endpos);
1826  ok(errno == 0xdeadbeef, "errno = %x\n", errno);
1827 
1828  errno = 0xdeadbeef;
1829  ures = p_strtoui64(overflow, &endpos, 10);
1830  ok(ures == _UI64_MAX, "ures != _UI64_MAX\n");
1831  ok(endpos == overflow+strlen(overflow), "Incorrect endpos (%p-%p)\n", overflow, endpos);
1832  ok(errno == ERANGE, "errno = %x\n", errno);
1833 
1834  errno = 0xdeadbeef;
1835  ures = p_strtoui64(neg_overflow, &endpos, 10);
1836  ok(ures == 1, "ures != 1\n");
1837  ok(endpos == neg_overflow+strlen(neg_overflow), "Incorrect endpos (%p-%p)\n", neg_overflow, endpos);
1838  ok(errno == ERANGE, "errno = %x\n", errno);
1839 }
#define _UI64_MAX
Definition: limits.h:63
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
int errno
static const char hex[16]
Definition: profile.c:123
static __int64(__cdecl *p_strtoi64)(const char *
smooth NULL
Definition: ftsmooth.c:416
#define _I64_MAX
Definition: limits.h:62
#define ERANGE
Definition: acclib.h:92
#define _I64_MIN
Definition: limits.h:61
#define ok(value,...)
Definition: atltest.h:57
ios_base &_STLP_CALL oct(ios_base &__s)
Definition: _ios_base.h:327
GLuint res
Definition: glext.h:9613
#define win_skip
Definition: test.h:150

Referenced by START_TEST().

◆ test__strupr()

static void test__strupr ( void  )
static

Definition at line 3550 of file string.c.

3551 {
3552  const char str[] = "123";
3553  char str2[4];
3554  char *mem, *p;
3555  DWORD prot;
3556 
3558  ok(mem != NULL, "VirtualAlloc failed\n");
3559  memcpy(mem, str, sizeof(str));
3560  ok(VirtualProtect(mem, sizeof(str), PAGE_READONLY, &prot), "VirtualProtect failed\n");
3561 
3562  strcpy(str2, "aBc");
3563  p = _strupr(str2);
3564  ok(p == str2, "_strupr returned %p\n", p);
3565  ok(!strcmp(str2, "ABC"), "str2 = %s\n", str2);
3566 
3567  p = _strupr(mem);
3568  ok(p == mem, "_strupr returned %p\n", p);
3569  ok(!strcmp(mem, "123"), "mem = %s\n", mem);
3570 
3571  if(!setlocale(LC_ALL, "english")) {
3572  VirtualFree(mem, sizeof(str), MEM_RELEASE);
3573  win_skip("English locale _strupr tests\n");
3574  return;
3575  }
3576 
3577  strcpy(str2, "aBc");
3578  p = _strupr(str2);
3579  ok(p == str2, "_strupr returned %p\n", p);
3580  ok(!strcmp(str2, "ABC"), "str2 = %s\n", str2);
3581 
3582  if (0) /* crashes on Windows */
3583  {
3584  p = _strupr(mem);
3585  ok(p == mem, "_strupr returned %p\n", p);
3586  ok(!strcmp(mem, "123"), "mem = %s\n", mem);
3587  }
3588 
3589  setlocale(LC_ALL, "C");
3590  VirtualFree(mem, sizeof(str), MEM_RELEASE);
3591 }
#define MEM_COMMIT
Definition: nt_native.h:1313
LPVOID NTAPI VirtualAlloc(IN LPVOID lpAddress, IN SIZE_T dwSize, IN DWORD flAllocationType, IN DWORD flProtect)
Definition: virtmem.c:74
const WCHAR * str
smooth NULL
Definition: ftsmooth.c:416
#define LC_ALL
Definition: locale.h:25
unsigned long DWORD
Definition: ntddk_ex.h:95
BOOL NTAPI VirtualProtect(IN LPVOID lpAddress, IN SIZE_T dwSize, IN DWORD flNewProtect, OUT PDWORD lpflOldProtect)
Definition: virtmem.c:144
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
_CRTIMP char *__cdecl _strupr(_Inout_z_ char *_String)
#define ok(value,...)
Definition: atltest.h:57
#define PAGE_READONLY
Definition: compat.h:127
Definition: mem.c:156
#define MEM_RELEASE
Definition: nt_native.h:1316
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
#define setlocale(n, s)
Definition: locale.h:46
BOOL NTAPI VirtualFree(IN LPVOID lpAddress, IN SIZE_T dwSize, IN DWORD dwFreeType)
Definition: virtmem.c:128
GLfloat GLfloat p
Definition: glext.h:8902
#define win_skip
Definition: test.h:150
#define PAGE_READWRITE
Definition: nt_native.h:1304

Referenced by START_TEST().

◆ test__tcsncoll()

static void test__tcsncoll ( void  )
static

Definition at line 3593 of file string.c.

3594 {
3595  struct test {
3596  const char *locale;
3597  const char *str1;
3598  const char *str2;
3599  size_t count;
3600  int exp;
3601  };
3602  static const struct test tests[] = {
3603  { "English", "ABCD", "ABCD", 4, 0 },
3604  { "English", "ABCD", "ABCD", 10, 0 },
3605 
3606  { "English", "ABC", "ABCD", 3, 0 },
3607  { "English", "ABC", "ABCD", 4, -1 },
3608  { "English", "ABC", "ABCD", 10, -1 },
3609 
3610  { "English", "ABCD", "ABC", 3, 0 },
3611  { "English", "ABCD", "ABC", 4, 1 },
3612  { "English", "ABCD", "ABC", 10, 1 },
3613 
3614  { "English", "ABCe", "ABCf", 3, 0 },
3615  { "English", "abcd", "ABCD", 10, -1 },
3616 
3617  { "C", "ABCD", "ABCD", 4, 0 },
3618  { "C", "ABCD", "ABCD", 10, 0 },
3619 
3620  { "C", "ABC", "ABCD", 3, 0 },
3621  { "C", "ABC", "ABCD", 10, -1 },
3622 
3623  { "C", "ABCD", "ABC", 3, 0 },
3624  { "C", "ABCD", "ABC", 10, 1 },
3625 
3626  { "C", "ABCe", "ABCf", 3, 0 },
3627  { "C", "abcd", "ABCD", 10, 1 },
3628  };
3629  WCHAR str1W[16];
3630  WCHAR str2W[16];
3631  char str1[16];
3632  char str2[16];
3633  size_t len;
3634  int i, ret;
3635 
3636  for (i = 0; i < ARRAY_SIZE(tests); i++)
3637  {
3638  if (!setlocale(LC_ALL, tests[i].locale))
3639  {
3640  win_skip("%s locale _tcsncoll tests\n", tests[i].locale);
3641  for (; i+1 < ARRAY_SIZE(tests); i++)
3642  if (strcmp(tests[i].locale, tests[i+1].locale)) break;
3643  continue;
3644  }
3645 
3646  memset(str1, 0xee, sizeof(str1));
3647  strcpy(str1, tests[i].str1);
3648 
3649  memset(str2, 0xff, sizeof(str2));
3650  strcpy(str2, tests[i].str2);
3651 
3652  ret = _strncoll(str1, str2, tests[i].count);
3653  if (!tests[i].exp)
3654  ok(!ret, "expected 0, got %d for %s, %s, %d\n", ret, str1, str2, (int)tests[i].count);
3655  else if (tests[i].exp < 0)
3656  ok(ret < 0, "expected < 0, got %d for %s, %s, %d\n", ret, str1, str2, (int)tests[i].count);
3657  else
3658  ok(ret > 0, "expected > 0, got %d for %s, %s, %d\n", ret, str1, str2, (int)tests[i].count);
3659 
3660  memset(str1W, 0xee, sizeof(str1W));
3661  len = mbstowcs(str1W, str1, ARRAY_SIZE(str1W));
3662  str1W[len] = 0;
3663 
3664  memset(str2W, 0xff, sizeof(str2W));
3665  len = mbstowcs(str2W, str2, ARRAY_SIZE(str2W));
3666  str2W[len] = 0;
3667 
3668  ret = _wcsncoll(str1W, str2W, tests[i].count);
3669  if (!tests[i].exp)
3670  ok(!ret, "expected 0, got %d for %s, %s, %d\n", ret, str1, str2, (int)tests[i].count);
3671  else if (tests[i].exp < 0)
3672  ok(ret < 0, "expected < 0, got %d for %s, %s, %d\n", ret, str1, str2, (int)tests[i].count);
3673  else
3674  ok(ret > 0, "expected > 0, got %d for %s, %s, %d\n", ret, str1, str2, (int)tests[i].count);
3675  }
3676 }
struct param_test tests[]
size_t __cdecl mbstowcs(_Out_writes_opt_z_(_MaxCount) wchar_t *_Dest, _In_z_ const char *_Source, _In_ size_t _MaxCount)
GLuint GLuint GLsizei count
Definition: gl.h:1545
#define test
Definition: rosglue.h:37
_Check_return_ _CRTIMP int __cdecl _wcsncoll(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2, _In_ size_t _MaxCount)
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
Definition: _locale.h:75
#define LC_ALL
Definition: locale.h:25
_Check_return_ _CRTIMP int __cdecl _strncoll(_In_z_ const char *_Str1, _In_z_ const char *_Str2, _In_ size_t _MaxCount)
__wchar_t WCHAR
Definition: xmlstorage.h:180
static size_t len
Definition: string.c:60
int ret
GLenum GLsizei len
Definition: glext.h:6722
static const wchar_t void * locale
Definition: printf.c:79
#define ARRAY_SIZE(a)
Definition: main.h:24
#define ok(value,...)
Definition: atltest.h:57
static size_t const unsigned char size_t count
Definition: string.c:63
DWORD exp
Definition: msg.c:16038
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
#define setlocale(n, s)
Definition: locale.h:46
#define memset(x, y, z)
Definition: compat.h:39
#define win_skip
Definition: test.h:150

Referenced by START_TEST().

◆ test__tcsnicoll()

static void test__tcsnicoll ( void  )
static

Definition at line 3678 of file string.c.

3679 {
3680  struct test {
3681  const char *locale;
3682  const char *str1;
3683  const char *str2;
3684  size_t count;
3685  int exp;
3686  };
3687  static const struct test tests[] = {
3688  { "English", "abcd", "ABCD", 4, 0 },
3689  { "English", "abcd", "ABCD", 10, 0 },
3690 
3691  { "English", "abc", "ABCD", 3, 0 },
3692  { "English", "abc", "ABCD", 4, -1 },
3693  { "English", "abc", "ABCD", 10, -1 },
3694 
3695  { "English", "abcd", "ABC", 3, 0 },
3696  { "English", "abcd", "ABC", 4, 1 },
3697  { "English", "abcd", "ABC", 10, 1 },
3698 
3699  { "English", "abcE", "ABCF", 3, 0 },
3700 
3701  { "C", "abcd", "ABCD", 4, 0 },
3702  { "C", "abcd", "ABCD", 10, 0 },
3703 
3704  { "C", "abc", "ABCD", 3, 0 },
3705  { "C", "abc", "ABCD", 10, -1 },
3706 
3707  { "C", "abcd", "ABC", 3, 0 },
3708  { "C", "abcd", "ABC", 10, 1 },
3709 
3710  { "C", "abce", "ABCf", 3, 0 },
3711  };
3712  WCHAR str1W[16];
3713  WCHAR str2W[16];
3714  char str1[16];
3715  char str2[16];
3716  size_t len;
3717  int i, ret;
3718 
3719  for (i = 0; i < ARRAY_SIZE(tests); i++)
3720  {
3721  if (!setlocale(LC_ALL, tests[i].locale))
3722  {
3723  win_skip("%s locale _tcsnicoll tests\n", tests[i].locale);
3724  for (; i+1 < ARRAY_SIZE(tests); i++)
3725  if (strcmp(tests[i].locale, tests[i+1].locale)) break;
3726  continue;
3727  }
3728 
3729  memset(str1, 0xee, sizeof(str1));
3730  strcpy(str1, tests[i].str1);
3731 
3732  memset(str2, 0xff, sizeof(str2));
3733  strcpy(str2, tests[i].str2);
3734 
3735  ret = _strnicoll(str1, str2, tests[i].count);
3736  if (!tests[i].exp)
3737  ok(!ret, "expected 0, got %d for %s, %s, %d\n", ret, str1, str2, (int)tests[i].count);
3738  else if (tests[i].exp < 0)
3739  ok(ret < 0, "expected < 0, got %d for %s, %s, %d\n", ret, str1, str2, (int)tests[i].count);
3740  else
3741  ok(ret > 0, "expected > 0, got %d for %s, %s, %d\n", ret, str1, str2, (int)tests[i].count);
3742 
3743  memset(str1W, 0xee, sizeof(str1W));
3744  len = mbstowcs(str1W, str1, ARRAY_SIZE(str1W));
3745  str1W[len] = 0;
3746 
3747  memset(str2W, 0xff, sizeof(str2W));
3748  len = mbstowcs(str2W, str2, ARRAY_SIZE(str2W));
3749  str2W[len] = 0;
3750 
3751  ret = _wcsnicoll(str1W, str2W, tests[i].count);
3752  if (!tests[i].exp)
3753  ok(!ret, "expected 0, got %d for %s, %s, %d\n", ret, str1, str2, (int)tests[i].count);
3754  else if (tests[i].exp < 0)
3755  ok(ret < 0, "expected < 0, got %d for %s, %s, %d\n", ret, str1, str2, (int)tests[i].count);
3756  else
3757  ok(ret > 0, "expected > 0, got %d for %s, %s, %d\n", ret, str1, str2, (int)tests[i].count);
3758  }
3759 }
struct param_test tests[]
size_t __cdecl mbstowcs(_Out_writes_opt_z_(_MaxCount) wchar_t *_Dest, _In_z_ const char *_Source, _In_ size_t _MaxCount)
GLuint GLuint GLsizei count
Definition: gl.h:1545
#define test
Definition: rosglue.h:37
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
Definition: _locale.h:75
#define LC_ALL
Definition: locale.h:25
__wchar_t WCHAR
Definition: xmlstorage.h:180
static size_t len
Definition: string.c:60
int ret
_Check_return_ _CRTIMP int __cdecl _wcsnicoll(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2, _In_ size_t _MaxCount)
GLenum GLsizei len
Definition: glext.h:6722
static const wchar_t void * locale
Definition: printf.c:79
_Check_return_ _CRTIMP int __cdecl _strnicoll(_In_z_ const char *_Str1, _In_z_ const char *_Str2, _In_ size_t _MaxCount)
#define ARRAY_SIZE(a)
Definition: main.h:24
#define ok(value,...)
Definition: atltest.h:57
static size_t const unsigned char size_t count
Definition: string.c:63
DWORD exp
Definition: msg.c:16038
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
#define setlocale(n, s)
Definition: locale.h:46
#define memset(x, y, z)
Definition: compat.h:39
#define win_skip
Definition: test.h:150

Referenced by START_TEST().

◆ test__ultoa_s()

static void test__ultoa_s ( void  )
static

Definition at line 2667 of file string.c.

2668 {
2669  errno_t ret;
2670  char buffer[33];
2671 
2672  if (!p_ultoa_s)
2673  {
2674  win_skip("Skipping _ultoa_s tests\n");
2675  return;
2676  }
2677 
2678  errno = EBADF;
2679  ret = p_ultoa_s(0, NULL, 0, 0);
2680  ok(ret == EINVAL, "Expected _ultoa_s to return EINVAL, got %d\n", ret);
2681  ok(errno == EINVAL, "Expected errno to be EINVAL, got %d\n", errno);
2682 
2683  memset(buffer, 'X', sizeof(buffer));
2684  errno = EBADF;
2685  ret = p_ultoa_s(0, buffer, 0, 0);
2686  ok(ret == EINVAL, "Expected _ultoa_s to return EINVAL, got %d\n", ret);
2687  ok(errno == EINVAL, "Expected errno to be EINVAL, got %d\n", errno);
2688  ok(buffer[0] == 'X', "Expected the output buffer to be untouched\n");
2689 
2690  memset(buffer, 'X', sizeof(buffer));
2691  errno = EBADF;
2692  ret = p_ultoa_s(0, buffer, sizeof(buffer), 0);
2693  ok(ret == EINVAL, "Expected _ultoa_s to return EINVAL, got %d\n", ret);
2694  ok(errno == EINVAL, "Expected errno to be EINVAL, got %d\n", errno);
2695  ok(buffer[0] == '\0', "Expected the output buffer to be null terminated\n");
2696 
2697  memset(buffer, 'X', sizeof(buffer));
2698  errno = EBADF;
2699  ret = p_ultoa_s(0, buffer, sizeof(buffer), 64);
2700  ok(ret == EINVAL, "Expected _ultoa_s to return EINVAL, got %d\n", ret);
2701  ok(errno == EINVAL, "Expected errno to be EINVAL, got %d\n", errno);
2702  ok(buffer[0] == '\0', "Expected the output buffer to be null terminated\n");
2703 
2704  memset(buffer, 'X', sizeof(buffer));
2705  errno = EBADF;
2706  ret = p_ultoa_s(12345678, buffer, 4, 10);
2707  ok(ret == ERANGE, "Expected _ultoa_s to return ERANGE, got %d\n", ret);
2708  ok(errno == ERANGE, "Expected errno to be ERANGE, got %d\n", errno);
2709  ok(!memcmp(buffer, "\000765", 4),
2710  "Expected the output buffer to be null terminated with truncated output\n");
2711 
2712  memset(buffer, 'X', sizeof(buffer));
2713  errno = EBADF;
2714  ret = p_ultoa_s(12345678, buffer, 8, 10);
2715  ok(ret == ERANGE, "Expected _ultoa_s to return ERANGE, got %d\n", ret);
2716  ok(errno == ERANGE, "Expected errno to be ERANGE, got %d\n", errno);
2717  ok(!memcmp(buffer, "\0007654321", 8),
2718  "Expected the output buffer to be null terminated with truncated output\n");
2719 
2720  ret = p_ultoa_s(12345678, buffer, 9, 10);
2721  ok(ret == 0, "Expected _ultoa_s to return 0, got %d\n", ret);
2722  ok(!strcmp(buffer, "12345678"),
2723  "Expected output buffer string to be \"12345678\", got \"%s\"\n",
2724  buffer);
2725 
2726  ret = p_ultoa_s(43690, buffer, sizeof(buffer), 2);
2727  ok(ret == 0, "Expected _ultoa_s to return 0, got %d\n", ret);
2728  ok(!strcmp(buffer, "1010101010101010"),
2729  "Expected output buffer string to be \"1010101010101010\", got \"%s\"\n",
2730  buffer);
2731 
2732  ret = p_ultoa_s(1092009, buffer, sizeof(buffer), 36);
2733  ok(ret == 0, "Expected _ultoa_s to return 0, got %d\n", ret);
2734  ok(!strcmp(buffer, "nell"),
2735  "Expected output buffer string to be \"nell\", got \"%s\"\n",
2736  buffer);
2737 
2738  ret = p_ultoa_s(5704, buffer, sizeof(buffer), 18);
2739  ok(ret == 0, "Expected _ultoa_s to return 0, got %d\n", ret);
2740  ok(!strcmp(buffer, "hag"),
2741  "Expected output buffer string to be \"hag\", got \"%s\"\n",
2742  buffer);
2743 }
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
Definition: arc.h:39
GLuint buffer
Definition: glext.h:5915
int errno
Definition: arc.h:36
smooth NULL
Definition: ftsmooth.c:416
int errno_t
Definition: crtdefs.h:353
#define ERANGE
Definition: acclib.h:92
int ret
#define ok(value,...)
Definition: atltest.h:57
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
#define memset(x, y, z)
Definition: compat.h:39
#define win_skip
Definition: test.h:150

Referenced by START_TEST().

◆ test__wcslwr_s()

static void test__wcslwr_s ( void  )
static

Definition at line 1210 of file string.c.

1211 {
1212  static const WCHAR mixedString[] = {'M', 'i', 'X', 'e', 'D', 'l', 'o', 'w',
1213  'e', 'r', 'U', 'P', 'P', 'E', 'R', 0};
1214  static const WCHAR expectedString[] = {'m', 'i', 'x', 'e', 'd', 'l', 'o',
1215  'w', 'e', 'r', 'u', 'p', 'p', 'e',
1216  'r', 0};
1217  WCHAR buffer[2*ARRAY_SIZE(mixedString)];
1218  int ret;
1219 
1220  if (!p_wcslwr_s)
1221  {
1222  win_skip("_wcslwr_s not found\n");
1223  return;
1224  }
1225 
1226  /* Test NULL input string and invalid size. */
1227  errno = EBADF;
1228  ret = p_wcslwr_s(NULL, 0);
1229  ok(ret == EINVAL, "expected EINVAL, got %d\n", ret);
1230  ok(errno == EINVAL, "expected errno EINVAL, got %d\n", errno);
1231 
1232  /* Test NULL input string and valid size. */
1233  errno = EBADF;
1234  ret = p_wcslwr_s(NULL, ARRAY_SIZE(buffer));
1235  ok(ret == EINVAL, "expected EINVAL, got %d\n", ret);
1236  ok(errno == EINVAL, "expected errno EINVAL, got %d\n", errno);
1237 
1238  /* Test empty string with zero size. */
1239  errno = EBADF;
1240  buffer[0] = 'a';
1241  ret = p_wcslwr_s(buffer, 0);
1242  ok(ret == EINVAL, "expected EINVAL, got %d\n", ret);
1243  ok(errno == EINVAL, "expected errno EINVAL, got %d\n", errno);
1244  ok(buffer[0] == 0, "expected empty string\n");
1245 
1246  /* Test empty string with size of one. */
1247  buffer[0] = 0;
1248  ret = p_wcslwr_s(buffer, 1);
1249  ok(ret == 0, "got %d\n", ret);
1250  ok(buffer[0] == 0, "expected buffer to be unchanged\n");
1251 
1252  /* Test one-byte buffer with zero size. */
1253  errno = EBADF;
1254  buffer[0] = 'x';
1255  ret = p_wcslwr_s(buffer, 0);
1256  ok(ret == EINVAL, "expected EINVAL, got %d\n", ret);
1257  ok(errno == EINVAL, "expected errno to be EINVAL, got %d\n", errno);
1258  ok(buffer[0] == '\0', "expected empty string\n");
1259 
1260  /* Test one-byte buffer with size of one. */
1261  errno = EBADF;
1262  buffer[0] = 'x';
1263  ret = p_wcslwr_s(buffer, 1);
1264  ok(ret == EINVAL, "expected EINVAL, got %d\n", ret);
1265  ok(errno == EINVAL, "expected errno to be EINVAL, got %d\n", errno);
1266  ok(buffer[0] == '\0', "expected empty string\n");
1267 
1268  /* Test invalid size. */
1269  wcscpy(buffer, mixedString);
1270  errno = EBADF;
1271  ret = p_wcslwr_s(buffer, 0);
1272  ok(ret == EINVAL, "Expected EINVAL, got %d\n", ret);
1273  ok(errno == EINVAL, "expected errno to be EINVAL, got %d\n", errno);
1274  ok(buffer[0] == '\0', "expected empty string\n");
1275 
1276  /* Test normal string uppercasing. */
1277  wcscpy(buffer, mixedString);
1278  ret = p_wcslwr_s(buffer, ARRAY_SIZE(mixedString));
1279  ok(ret == 0, "expected 0, got %d\n", ret);
1280  ok(!wcscmp(buffer, expectedString), "expected lowercase\n");
1281 
1282  /* Test uppercasing with a shorter buffer size count. */
1283  wcscpy(buffer, mixedString);
1284  errno = EBADF;
1285  ret = p_wcslwr_s(buffer, ARRAY_SIZE(mixedString) - 1);
1286  ok(ret == EINVAL, "expected EINVAL, got %d\n", ret);
1287  ok(errno == EINVAL, "expected errno to be EINVAL, got %d\n", errno);
1288  ok(buffer[0] == '\0', "expected empty string\n");
1289 
1290  /* Test uppercasing with a longer buffer size count. */
1291  wcscpy(buffer, mixedString);
1292  ret = p_wcslwr_s(buffer, ARRAY_SIZE(buffer));
1293  ok(ret == 0, "expected 0, got %d\n", ret);
1294  ok(!wcscmp(buffer, expectedString), "expected lowercase\n");
1295 }
Definition: arc.h:39
GLuint buffer
Definition: glext.h:5915
int errno
Definition: arc.h:36
smooth NULL
Definition: ftsmooth.c:416
__wchar_t WCHAR
Definition: xmlstorage.h:180
int ret
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
_Check_return_ _CRTIMP int __cdecl wcscmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
#define ARRAY_SIZE(a)
Definition: main.h:24
#define ok(value,...)
Definition: atltest.h:57
#define win_skip
Definition: test.h:150

Referenced by START_TEST().

◆ test__wcsnset_s()

static void test__wcsnset_s ( void  )
static

Definition at line 3312 of file string.c.

3313 {
3314  wchar_t text[] = { 't','e','x','t',0 };
3315  int r;
3316 
3317  if(!p__wcsnset_s) {
3318  win_skip("_wcsnset_s not available\n");
3319  return;
3320  }
3321 
3322  r = p__wcsnset_s(NULL, 0, 'a', 0);
3323  ok(r == 0, "r = %d\n", r);
3324 
3325  r = p__wcsnset_s(text, 0, 'a', 1);
3326  ok(r == EINVAL, "r = %d\n", r);
3327  ok(text[0] == 't', "text[0] = %d\n", text[0]);
3328 
3329  r = p__wcsnset_s(NULL, 2, 'a', 1);
3330  ok(r == EINVAL, "r = %d\n", r);
3331 
3332  r = p__wcsnset_s(text, 2, 'a', 3);
3333  ok(r == EINVAL, "r = %d\n", r);
3334  ok(text[0] == 0, "text[0] = %d\n", text[0]);
3335  ok(text[1] == 'e', "text[1] = %d\n", text[1]);
3336 
3337  text[0] = 't';
3338  r = p__wcsnset_s(text, 5, 'a', 1);
3339  ok(r == 0, "r = %d\n", r);
3340  ok(text[0] == 'a', "text[0] = %d\n", text[0]);
3341  ok(text[1] == 'e', "text[1] = %d\n", text[1]);
3342 
3343  text[1] = 0;
3344  r = p__wcsnset_s(text, 5, 'b', 3);
3345  ok(r == 0, "r = %d\n", r);
3346  ok(text[0] == 'b', "text[0] = %d\n", text[0]);
3347  ok(text[1] == 0, "text[1] = %d\n", text[1]);
3348  ok(text[2] == 'x', "text[2] = %d\n", text[2]);
3349 }
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
const WCHAR * text
Definition: package.c:1827
Definition: arc.h:39
smooth NULL
Definition: ftsmooth.c:416
#define ok(value,...)
Definition: atltest.h:57
#define win_skip
Definition: test.h:150

Referenced by START_TEST().

◆ test__wcsset_s()

static void test__wcsset_s ( void  )
static

Definition at line 3351 of file string.c.

3352 {
3353  wchar_t str[10];
3354  int r;
3355 
3356  if(!p__wcsset_s) {
3357  win_skip("_wcsset_s not available\n");
3358  return;
3359  }
3360 
3361  r = p__wcsset_s(NULL, 0, 'a');
3362  ok(r == EINVAL, "r = %d\n", r);
3363 
3364  str[0] = 'a';
3365  r = p__wcsset_s(str, 0, 'a');
3366  ok(r == EINVAL, "r = %d\n", r);
3367  ok(str[0] == 'a', "str[0] = %d\n", str[0]);
3368 
3369  str[0] = 'a';
3370  str[1] = 'b';
3371  r = p__wcsset_s(str, 2, 'c');
3372  ok(r == EINVAL, "r = %d\n", r);
3373  ok(!str[0], "str[0] = %d\n", str[0]);
3374  ok(str[1] == 'b', "str[1] = %d\n", str[1]);
3375 
3376  str[0] = 'a';
3377  str[1] = 0;
3378  str[2] = 'b';
3379  r = p__wcsset_s(str, 3, 'c');
3380  ok(r == 0, "r = %d\n", r);
3381  ok(str[0] == 'c', "str[0] = %d\n", str[0]);
3382  ok(str[1] == 0, "str[1] = %d\n", str[1]);
3383  ok(str[2] == 'b', "str[2] = %d\n", str[2]);
3384 }
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
Definition: arc.h:39
const WCHAR * str
smooth NULL
Definition: ftsmooth.c:416
#define ok(value,...)
Definition: atltest.h:57
#define win_skip
Definition: test.h:150

Referenced by START_TEST().

◆ test__wcstoi64()

static void test__wcstoi64 ( void  )
static

Definition at line 3030 of file string.c.

3031 {
3032  static const WCHAR digit[] = { '9', 0 };
3033  static const WCHAR space[] = { ' ', 0 };
3034  static const WCHAR stock[] = { 0x3231, 0 }; /* PARENTHESIZED IDEOGRAPH STOCK */
3035  static const WCHAR cjk_1[] = { 0x4e00, 0 }; /* CJK Ideograph, First */
3036  static const WCHAR tamil[] = { 0x0bef, 0 }; /* TAMIL DIGIT NINE */
3037  static const WCHAR thai[] = { 0x0e59, 0 }; /* THAI DIGIT NINE */
3038  static const WCHAR fullwidth[] = { 0xff19, 0 }; /* FULLWIDTH DIGIT NINE */
3039  static const WCHAR superscript1[] = { 0xb9, 0 }; /* SUPERSCRIPT ONE */
3040  static const WCHAR minus_0x91[] = { '-', 0x0e50, 'x', 0xff19, '1', 0 };
3041  static const WCHAR plus_071[] = { '+', 0x0e50, 0xff17, '1', 0 };
3042  static const WCHAR hex[] = { 0xff19, 'f', 0x0e59, 0xff46, 0 };
3043  static const WCHAR zeros[] = {
3044  0x660, 0x6f0, 0x966, 0x9e6, 0xa66, 0xae6, 0xb66, 0xc66, 0xce6,
3045  0xd66, 0xe50, 0xed0, 0xf20, 0x1040, 0x17e0, 0x1810, 0xff10
3046  };
3047  int i;
3048 
3049  __int64 res;
3050  unsigned __int64 ures;
3051  WCHAR *endpos;
3052 
3053  if (!p_wcstoi64 || !p_wcstoui64) {
3054  win_skip("_wcstoi64 or _wcstoui64 not found\n");
3055  return;
3056  }
3057 
3058  res = p_wcstoi64(digit, NULL, 10);
3059  ok(res == 9, "res != 9\n");
3060  res = p_wcstoi64(space, &endpos, 0);
3061  ok(endpos == space, "endpos != space\n");
3062  res = p_wcstoi64(stock, &endpos, 10);
3063  ok(res == 0, "res != 0\n");
3064  ok(endpos == stock, "Incorrect endpos (%p-%p)\n", stock, endpos);
3065  res = p_wcstoi64(cjk_1, NULL, 0);
3066  ok(res == 0, "res != 0\n");
3067  res = p_wcstoi64(tamil, &endpos, 10);
3068  ok(res == 0, "res != 0\n");
3069  ok(endpos == tamil, "Incorrect endpos (%p-%p)\n", tamil, endpos);
3070  res = p_wcstoi64(thai, NULL, 10);
3071  ok(res == 9, "res != 9\n");
3072  res = p_wcstoi64(fullwidth, NULL, 10);
3073  ok(res == 9, "res != 9\n");
3074  res = p_wcstoi64(superscript1, NULL, 10);
3075  ok(res == 0, "res != 0\n");
3076  res = p_wcstoi64(hex, NULL, 16);
3077  ok(res == 0x9f9, "res != 0x9f9\n");
3078  res = p_wcstoi64(minus_0x91, NULL, 0);
3079  ok(res == -0x91, "res != -0x91\n");
3080  res = p_wcstoi64(plus_071, NULL, 0);
3081  ok(res == 071, "res != 071\n");
3082 
3083  ures = p_wcstoui64(digit, NULL, 10);
3084  ok(ures == 9, "ures != 9\n");
3085  ures = p_wcstoui64(space, &endpos, 0);
3086  ok(endpos == space, "endpos != space\n");
3087  ures = p_wcstoui64(stock, &endpos, 10);
3088  ok(ures == 0, "ures != 0\n");
3089  ok(endpos == stock, "Incorrect endpos (%p-%p)\n", stock, endpos);
3090  ures = p_wcstoui64(tamil, &endpos, 10);
3091  ok(ures == 0, "ures != 0\n");
3092  ok(endpos == tamil, "Incorrect endpos (%p-%p)\n", tamil, endpos);
3093  ures = p_wcstoui64(thai, NULL, 10);
3094  ok(ures == 9, "ures != 9\n");
3095  ures = p_wcstoui64(fullwidth, NULL, 10);
3096  ok(ures == 9, "ures != 9\n");
3097  ures = p_wcstoui64(superscript1, NULL, 10);
3098  ok(ures == 0, "ures != 0\n");
3099  ures = p_wcstoui64(hex, NULL, 16);
3100  ok(ures == 0x9f9, "ures != 0x9f9\n");
3101  ures = p_wcstoui64(plus_071, NULL, 0);
3102  ok(ures == 071, "ures != 071\n");
3103 
3104  /* Test various unicode digits */
3105  for (i = 0; i < ARRAY_SIZE(zeros); ++i) {
3106  WCHAR tmp[] = {zeros[i] + 4, zeros[i], zeros[i] + 5, 0};
3107  res = p_wcstoi64(tmp, NULL, 0);
3108  ok(res == 405, "with zero = U+%04X: got %d, expected 405\n", zeros[i], (int)res);
3109  tmp[1] = zeros[i] + 10;
3110  res = p_wcstoi64(tmp, NULL, 16);
3111  ok(res == 4, "with zero = U+%04X: got %d, expected 4\n", zeros[i], (int)res);
3112  }
3113 
3114  return;
3115 }
static const char hex[16]
Definition: profile.c:123
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
static __int64(__cdecl *p_strtoi64)(const char *
smooth NULL
Definition: ftsmooth.c:416
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define ARRAY_SIZE(a)
Definition: main.h:24
#define ok(value,...)
Definition: atltest.h:57
GLuint res
Definition: glext.h:9613
#define win_skip
Definition: test.h:150

Referenced by START_TEST().

◆ test__wcsupr_s()

static void test__wcsupr_s ( void  )
static

Definition at line 1123 of file string.c.

1124 {
1125  static const WCHAR mixedString[] = {'M', 'i', 'X', 'e', 'D', 'l', 'o', 'w',
1126  'e', 'r', 'U', 'P', 'P', 'E', 'R', 0};
1127  static const WCHAR expectedString[] = {'M', 'I', 'X', 'E', 'D', 'L', 'O',
1128  'W', 'E', 'R', 'U', 'P', 'P', 'E',
1129  'R', 0};
1130  WCHAR testBuffer[2*ARRAY_SIZE(mixedString)];
1131  int ret;
1132 
1133  if (!p_wcsupr_s)
1134  {
1135  win_skip("_wcsupr_s not found\n");
1136  return;
1137  }
1138 
1139  /* Test NULL input string and invalid size. */
1140  errno = EBADF;
1141  ret = p_wcsupr_s(NULL, 0);
1142  ok(ret == EINVAL, "Expected _wcsupr_s to fail with EINVAL, got %d\n", ret);
1143  ok(errno == EINVAL, "Expected errno to be EINVAL, got %d\n", errno);
1144 
1145  /* Test NULL input string and valid size. */
1146  errno = EBADF;
1147  ret = p_wcsupr_s(NULL, ARRAY_SIZE(testBuffer));
1148  ok(ret == EINVAL, "Expected _wcsupr_s to fail with EINVAL, got %d\n", ret);
1149  ok(errno == EINVAL, "Expected errno to be EINVAL, got %d\n", errno);
1150 
1151  /* Test empty string with zero size. */
1152  errno = EBADF;
1153  testBuffer[0] = '\0';
1154  ret = p_wcsupr_s(testBuffer, 0);
1155  ok(ret == EINVAL, "Expected _wcsupr_s to fail with EINVAL, got %d\n", ret);
1156  ok(errno == EINVAL, "Expected errno to be EINVAL, got %d\n", errno);
1157  ok(testBuffer[0] == '\0', "Expected the buffer to be unchanged\n");
1158 
1159  /* Test empty string with size of one. */
1160  testBuffer[0] = '\0';
1161  ret = p_wcsupr_s(testBuffer, 1);
1162  ok(ret == 0, "Expected _wcsupr_s to succeed, got %d\n", ret);
1163  ok(testBuffer[0] == '\0', "Expected the buffer to be unchanged\n");
1164 
1165  /* Test one-byte buffer with zero size. */
1166  errno = EBADF;
1167  testBuffer[0] = 'x';
1168  ret = p_wcsupr_s(testBuffer, 0);
1169  ok(ret == EINVAL, "Expected _wcsupr_s to fail with EINVAL, got %d\n", ret);
1170  ok(errno == EINVAL, "Expected errno to be EINVAL, got %d\n", errno);
1171  ok(testBuffer[0] == '\0', "Expected the first buffer character to be null\n");
1172 
1173  /* Test one-byte buffer with size of one. */
1174  errno = EBADF;
1175  testBuffer[0] = 'x';
1176  ret = p_wcsupr_s(testBuffer, 1);
1177  ok(ret == EINVAL, "Expected _wcsupr_s to fail with EINVAL, got %d\n", ret);
1178  ok(errno == EINVAL, "Expected errno to be EINVAL, got %d\n", errno);
1179  ok(testBuffer[0] == '\0', "Expected the first buffer character to be null\n");
1180 
1181  /* Test invalid size. */
1182  wcscpy(testBuffer, mixedString);
1183  errno = EBADF;
1184  ret = p_wcsupr_s(testBuffer, 0);
1185  ok(ret == EINVAL, "Expected _wcsupr_s to fail with EINVAL, got %d\n", ret);
1186  ok(errno == EINVAL, "Expected errno to be EINVAL, got %d\n", errno);
1187  ok(testBuffer[0] == '\0', "Expected the first buffer character to be null\n");
1188 
1189  /* Test normal string uppercasing. */
1190  wcscpy(testBuffer, mixedString);
1191  ret = p_wcsupr_s(testBuffer, ARRAY_SIZE(mixedString));
1192  ok(ret == 0, "Expected _wcsupr_s to succeed, got %d\n", ret);
1193  ok(!wcscmp(testBuffer, expectedString), "Expected the string to be fully upper-case\n");
1194 
1195  /* Test uppercasing with a shorter buffer size count. */
1196  wcscpy(testBuffer, mixedString);
1197  errno = EBADF;
1198  ret = p_wcsupr_s(testBuffer, ARRAY_SIZE(mixedString) - 1);
1199  ok(ret == EINVAL, "Expected _wcsupr_s to fail with EINVAL, got %d\n", ret);
1200  ok(errno == EINVAL, "Expected errno to be EINVAL, got %d\n", errno);
1201  ok(testBuffer[0] == '\0', "Expected the first buffer character to be null\n");
1202 
1203  /* Test uppercasing with a longer buffer size count. */
1204  wcscpy(testBuffer, mixedString);
1205  ret = p_wcsupr_s(testBuffer, ARRAY_SIZE(testBuffer));
1206  ok(ret == 0, "Expected _wcsupr_s to succeed, got %d\n", ret);
1207  ok(!wcscmp(testBuffer, expectedString), "Expected the string to be fully upper-case\n");
1208 }
Definition: arc.h:39
int errno
Definition: arc.h:36
smooth NULL
Definition: ftsmooth.c:416
__wchar_t WCHAR
Definition: xmlstorage.h:180
int ret
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
_Check_return_ _CRTIMP int __cdecl wcscmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
#define ARRAY_SIZE(a)
Definition: main.h:24
#define ok(value,...)
Definition: atltest.h:57
#define win_skip
Definition: test.h:150

Referenced by START_TEST().

◆ test_atof()

static void test_atof ( void  )
static

Definition at line 3151 of file string.c.

3152 {
3153  double d;
3154 
3155  d = atof("0.0");
3156  ok(almost_equal(d, 0.0), "d = %lf\n", d);
3157 
3158  d = atof("1.0");
3159  ok(almost_equal(d, 1.0), "d = %lf\n", d);
3160 
3161  d = atof("-1.0");
3162  ok(almost_equal(d, -1.0), "d = %lf\n", d);
3163 
3164  if (!p__atof_l)
3165  {
3166  win_skip("_atof_l not found\n");
3167  return;
3168  }
3169 
3170  errno = EBADF;
3171  d = atof(NULL);
3172  ok(almost_equal(d, 0.0), "d = %lf\n", d);
3173  ok(errno == EINVAL, "errno = %x\n", errno);
3174 
3175  errno = EBADF;
3176  d = p__atof_l(NULL, NULL);
3177  ok(almost_equal(d, 0.0), "d = %lf\n", d);
3178  ok(errno == EINVAL, "errno = %x\n", errno);
3179 }
Definition: arc.h:39
int errno
Definition: arc.h:36
_Check_return_ _CRTIMP double __cdecl atof(_In_z_ const char *str)
smooth NULL
Definition: ftsmooth.c:416
#define d
Definition: ke_i.h:81
#define ok(value,...)
Definition: atltest.h:57
static BOOL almost_equal(double d1, double d2)
Definition: string.c:1841
#define win_skip
Definition: test.h:150

Referenced by START_TEST().

◆ test_atoi()

static void test_atoi ( void  )
static

Definition at line 3117 of file string.c.

3118 {
3119  int r;
3120 
3121  r = atoi("0");
3122  ok(r == 0, "atoi(0) = %d\n", r);
3123 
3124  r = atoi("-1");
3125  ok(r == -1, "atoi(-1) = %d\n", r);
3126 
3127  r = atoi("1");
3128  ok(r == 1, "atoi(1) = %d\n", r);
3129 
3130  r = atoi("4294967296");
3131  ok(r == 0, "atoi(4294967296) = %d\n", r);
3132 }
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
#define ok(value,...)
Definition: atltest.h:57
_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 3134 of file string.c.

3135 {
3136  int r;
3137 
3138  r = atol("0");
3139  ok(r == 0, "atol(0) = %d\n", r);
3140 
3141  r = atol("-1");
3142  ok(r == -1, "atol(-1) = %d\n", r);
3143 
3144  r = atol("1");
3145  ok(r == 1, "atol(1) = %d\n", r);
3146 
3147  r = atol("4294967296");
3148  ok(r == 0, "atol(4294967296) = %d\n", r);
3149 }
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
_Check_return_ long __cdecl atol(_In_z_ const char *_Str)
#define ok(value,...)
Definition: atltest.h:57

Referenced by START_TEST().

◆ test_C_locale()

static void test_C_locale ( void  )
static

Definition at line 3796 of file string.c.

3797 {
3798  int i, j;
3799  wint_t ret, exp;
3800  _locale_t locale;
3801  static const char *locales[] = { NULL, "C" };
3802 
3803  /* C locale only converts case for [a-zA-Z] */
3804  setlocale(LC_ALL, "C");
3805  for (i = 0; i <= 0xffff; i++)
3806  {
3807  ret = p_towlower(i);
3808  if (i >= 'A' && i <= 'Z')
3809  {
3810  exp = i + 'a' - 'A';
3811  ok(ret == exp, "expected %x, got %x for C locale\n", exp, ret);
3812  }
3813  else
3814  ok(ret == i, "expected self %x, got %x for C locale\n", i, ret);
3815 
3816  ret = p_towupper(i);
3817  if (i >= 'a' && i <= 'z')
3818  {
3819  exp = i + 'A' - 'a';
3820  ok(ret == exp, "expected %x, got %x for C locale\n", exp, ret);
3821  }
3822  else
3823  ok(ret == i, "expected self %x, got %x for C locale\n", i, ret);
3824  }
3825 
3826  if (!p__towlower_l || !p__towupper_l || !p__create_locale)
3827  {
3828  win_skip("_towlower_l/_towupper_l/_create_locale not available\n");
3829  return;
3830  }
3831 
3832  for (i = 0; i < ARRAY_SIZE(locales); i++) {
3833  locale = locales[i] ? p__create_locale(LC_ALL, locales[i]) : NULL;
3834 
3835  for (j = 0; j <= 0xffff; j++) {
3836  ret = p__towlower_l(j, locale);
3837  if (j >= 'A' && j <= 'Z')
3838  {
3839  exp = j + 'a' - 'A';
3840  ok(ret == exp, "expected %x, got %x for C locale\n", exp, ret);
3841  }
3842  else
3843  ok(ret == j, "expected self %x, got %x for C locale\n", j, ret);
3844 
3845  ret = p__towupper_l(j, locale);
3846  if (j >= 'a' && j <= 'z')
3847  {
3848  exp = j + 'A' - 'a';
3849  ok(ret == exp, "expected %x, got %x for C locale\n", exp, ret);
3850  }
3851  else
3852  ok(ret == j, "expected self %x, got %x for C locale\n", j, ret);
3853  }
3854 
3855  p__free_locale(locale);
3856  }
3857 }
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
Definition: _locale.h:75
int wint_t
Definition: _apple.h:38
smooth NULL
Definition: ftsmooth.c:416
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 LC_ALL
Definition: locale.h:25
int ret
static const wchar_t void * locale
Definition: printf.c:79
#define ARRAY_SIZE(a)
Definition: main.h:24
#define ok(value,...)
Definition: atltest.h:57
DWORD exp
Definition: msg.c:16038
#define setlocale(n, s)
Definition: locale.h:46
#define win_skip
Definition: test.h:150

Referenced by START_TEST().

◆ test_cp_table()

static void test_cp_table ( int  cp,
int result 
)
static

Definition at line 200 of file string.c.

201 {
202  int i;
203  int count = 0;
204  int curr = 0;
205  _setmbcp(cp);
206  for (i = 0; i < 256; i++)
207  {
208  if (count == 0)
209  {
210  curr = result[0];
211  count = result[1];
212  result += 2;
213  }
214  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);
215  count--;
216  }
217 }
GLuint GLuint GLsizei count
Definition: gl.h:1545
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
int __cdecl _setmbcp(int)
Definition: _setmbcp.c:218
static unsigned char * p_mbctype
Definition: string.c:85
#define ok(value,...)
Definition: atltest.h:57
POINT cp
Definition: magnifier.c:59
GLuint64EXT * result
Definition: glext.h:11304

◆ test_gcvt()

static void test_gcvt ( void  )
static

Definition at line 2182 of file string.c.

2183 {
2184  char buf[1024], *res;
2185  errno_t err;
2186 
2187  if(!p_gcvt_s) {
2188  win_skip("Skipping _gcvt tests\n");
2189  return;
2190  }
2191 
2192  errno = 0;
2193  res = _gcvt(1.2, -1, buf);
2194  ok(res == NULL, "res != NULL\n");
2195  ok(errno == ERANGE, "errno = %d\n", errno);
2196 
2197  errno = 0;
2198  res = _gcvt(1.2, 5, NULL);
2199  ok(res == NULL, "res != NULL\n");
2200  ok(errno == EINVAL, "errno = %d\n", errno);
2201 
2202  res = gcvt(1.2, 5, buf);
2203  ok(res == buf, "res != buf\n");
2204  ok(!strcmp(buf, "1.2"), "buf = %s\n", buf);
2205 
2206  buf[0] = 'x';
2207  err = p_gcvt_s(buf, 5, 1.2, 10);
2208  ok(err == ERANGE, "err = %d\n", err);
2209  ok(buf[0] == '\0', "buf[0] = %c\n", buf[0]);
2210 
2211  buf[0] = 'x';
2212  err = p_gcvt_s(buf, 4, 123456, 2);
2213  ok(err == ERANGE, "err = %d\n", err);
2214  ok(buf[0] == '\0', "buf[0] = %c\n", buf[0]);
2215 }
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
Definition: arc.h:39
int errno
smooth NULL
Definition: ftsmooth.c:416
int errno_t
Definition: crtdefs.h:353
#define ERANGE
Definition: acclib.h:92
#define err(...)
#define ok(value,...)
Definition: atltest.h:57
GLuint res
Definition: glext.h:9613
_CRTIMP char *__cdecl _gcvt(_In_ double _Val, _In_ int _NumOfDigits, _Pre_notnull_ _Post_z_ char *_DstBuf)
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
_CRTIMP char *__cdecl gcvt(_In_ double _Val, _In_ int _NumOfDigits, _Pre_notnull_ _Post_z_ char *_DstBuf)
#define win_skip
Definition: test.h:150

Referenced by START_TEST().

◆ test_ismbckata()

static void test_ismbckata ( void  )
static

Definition at line 1458 of file string.c.

1458  {
1459  struct katakana_pair {
1460  UINT c;
1461  BOOL exp;
1462  };
1463  static const struct katakana_pair tests[] = {
1464  {0x8152, FALSE}, {0x8153, FALSE}, {0x8154, FALSE}, {0x8155, FALSE},
1465  {0x82a0, FALSE}, {0x833f, FALSE}, {0x8340, TRUE }, {0x837e, TRUE },
1466  {0x837f, FALSE}, {0x8380, TRUE }, {0x8396, TRUE }, {0x8397, FALSE},
1467  {0xa5, FALSE}, {0xb0, FALSE}, {0xdd, FALSE}
1468  };
1469  unsigned int prev_cp = _getmbcp();
1470  int ret;
1471  unsigned int i;
1472 
1474  for (i = 0; i < ARRAY_SIZE(tests); i++) {
1475  ret = _ismbckata(tests[i].c);
1476  ok(!ret, "expected 0, got %d for %04x\n", ret, tests[i].c);
1477  }
1478 
1479  _setmbcp(932);
1480  for (i = 0; i < ARRAY_SIZE(tests); i++) {
1481  ret = _ismbckata(tests[i].c);
1482  ok(!!ret == tests[i].exp, "expected %d, got %d for %04x\n",
1483  tests[i].exp, !!ret, tests[i].c);
1484  }
1485 
1486  _setmbcp(prev_cp);
1487 }
struct param_test tests[]
#define TRUE
Definition: types.h:120
_CRTIMP int __cdecl _getmbcp(void)
Definition: locale.c:1472
#define _MB_CP_SBCS
Definition: msvcrt.h:828
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
unsigned int BOOL
Definition: ntddk_ex.h:94
int __cdecl _setmbcp(int)
Definition: _setmbcp.c:218
const GLubyte * c
Definition: glext.h:8905
_Check_return_ _CRTIMP int __cdecl _ismbckata(_In_ unsigned int _Ch)
int ret
#define ARRAY_SIZE(a)
Definition: main.h:24
#define ok(value,...)
Definition: atltest.h:57
unsigned int UINT
Definition: ndis.h:50
DWORD exp
Definition: msg.c:16038
#define c
Definition: ke_i.h:80

Referenced by START_TEST().

◆ test_ismbclegal()

static void test_ismbclegal ( void  )
static

Definition at line 1489 of file string.c.

1489  {
1490  unsigned int prev_cp = _getmbcp();
1491  int ret, exp, err;
1492  unsigned int i;
1493 
1494  _setmbcp(932); /* Japanese */
1495  err = 0;
1496  for(i = 0; i < 0x10000; i++) {
1497  ret = _ismbclegal(i);
1498  exp = ((HIBYTE(i) >= 0x81 && HIBYTE(i) <= 0x9F) ||
1499  (HIBYTE(i) >= 0xE0 && HIBYTE(i) <= 0xFC)) &&
1500  ((LOBYTE(i) >= 0x40 && LOBYTE(i) <= 0x7E) ||
1501  (LOBYTE(i) >= 0x80 && LOBYTE(i) <= 0xFC));
1502  if(ret != exp) {
1503  err = 1;
1504  break;
1505  }
1506  }
1507  ok(!err, "_ismbclegal (932) : Expected 0x%x, got 0x%x (0x%x)\n", exp, ret, i);
1508  _setmbcp(936); /* Chinese (GBK) */
1509  err = 0;
1510  for(i = 0; i < 0x10000; i++) {
1511  ret = _ismbclegal(i);
1512  exp = HIBYTE(i) >= 0x81 && HIBYTE(i) <= 0xFE &&
1513  LOBYTE(i) >= 0x40 && LOBYTE(i) <= 0xFE;
1514  if(ret != exp) {
1515  err = 1;
1516  break;
1517  }
1518  }
1519  ok(!err, "_ismbclegal (936) : Expected 0x%x, got 0x%x (0x%x)\n", exp, ret, i);
1520  _setmbcp(949); /* Korean */
1521  err = 0;
1522  for(i = 0; i < 0x10000; i++) {
1523  ret = _ismbclegal(i);
1524  exp = HIBYTE(i) >= 0x81 && HIBYTE(i) <= 0xFE &&
1525  LOBYTE(i) >= 0x41 && LOBYTE(i) <= 0xFE;
1526  if(ret != exp) {
1527  err = 1;
1528  break;
1529  }
1530  }
1531  ok(!err, "_ismbclegal (949) : Expected 0x%x, got 0x%x (0x%x)\n", exp, ret, i);
1532  _setmbcp(950); /* Chinese (Big5) */
1533  err = 0;
1534  for(i = 0; i < 0x10000; i++) {
1535  ret = _ismbclegal(i);
1536  exp = HIBYTE(i) >= 0x81 && HIBYTE(i) <= 0xFE &&
1537  ((LOBYTE(i) >= 0x40 && LOBYTE(i) <= 0x7E) ||
1538  (LOBYTE(i) >= 0xA1 && LOBYTE(i) <= 0xFE));
1539  if(ret != exp) {
1540  err = 1;
1541  break;
1542  }
1543  }
1544  ok(!err, "_ismbclegal (950) : Expected 0x%x, got 0x%x (0x%x)\n", exp, ret, i);
1545  _setmbcp(1361); /* Korean (Johab) */
1546  err = 0;
1547  for(i = 0; i < 0x10000; i++) {
1548  ret = _ismbclegal(i);
1549