ReactOS  0.4.12-dev-432-g3463b2d
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 NUMELMS(array)   (sizeof(array)/sizeof((array)[0]))
 
#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 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_atof (void)
 
static void test_strncpy (void)
 
static void test_strxfrm (void)
 
static void test__strnset_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)
 
 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 mbstate_t *static const char mbstate_t *static char _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.

◆ NUMELMS

#define NUMELMS (   array)    (sizeof(array)/sizeof((array)[0]))

Definition at line 610 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
#define ok(value,...)
Definition: CComObject.cpp:34
static CRYPT_DATA_BLOB b3[]
Definition: msg.c:592
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 612 of file string.c.

◆ SET

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

Definition at line 105 of file string.c.

◆ SETNOFAIL

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

Definition at line 104 of file string.c.

◆ test_codepage

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

Definition at line 210 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().

◆ almost_equal()

static BOOL almost_equal ( double  d1,
double  d2 
)
inlinestatic

Definition at line 1781 of file string.c.

1781  {
1782  if(d1-d2>-1e-30 && d1-d2<1e-30)
1783  return TRUE;
1784  return FALSE;
1785 }
#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 3349 of file string.c.

3350 {
3351  char mem[100];
3352  static const char xilstring[]="c:/xilinx";
3353  int nLen;
3354 
3355  hMsvcrt = GetModuleHandleA("msvcrt.dll");
3356  if (!hMsvcrt)
3357  hMsvcrt = GetModuleHandleA("msvcrtd.dll");
3358  ok(hMsvcrt != 0, "GetModuleHandleA failed\n");
3359  SET(pmemcpy,"memcpy");
3360  p_memcpy_s = (void*)GetProcAddress( hMsvcrt, "memcpy_s" );
3361  p_memmove_s = (void*)GetProcAddress( hMsvcrt, "memmove_s" );
3362  SET(pmemcmp,"memcmp");
3363  SET(p_mbctype,"_mbctype");
3364  SET(p__mb_cur_max,"__mb_cur_max");
3365  SET(p_strcpy, "strcpy");
3366  pstrcpy_s = (void *)GetProcAddress( hMsvcrt,"strcpy_s" );
3367  pstrcat_s = (void *)GetProcAddress( hMsvcrt,"strcat_s" );
3368  p_mbscat_s = (void*)GetProcAddress( hMsvcrt, "_mbscat_s" );
3369  p_mbsnbcat_s = (void *)GetProcAddress( hMsvcrt,"_mbsnbcat_s" );
3370  p_mbsnbcpy_s = (void *)GetProcAddress( hMsvcrt,"_mbsnbcpy_s" );
3371  p__mbscpy_s = (void *)GetProcAddress( hMsvcrt,"_mbscpy_s" );
3372  p_wcscpy_s = (void *)GetProcAddress( hMsvcrt,"wcscpy_s" );
3373  p_wcsncpy_s = (void *)GetProcAddress( hMsvcrt,"wcsncpy_s" );
3374  p_wcsncat_s = (void *)GetProcAddress( hMsvcrt,"wcsncat_s" );
3375  p_wcsupr_s = (void *)GetProcAddress( hMsvcrt,"_wcsupr_s" );
3376  p_strnlen = (void *)GetProcAddress( hMsvcrt,"strnlen" );
3377  p_strtoi64 = (void *)GetProcAddress(hMsvcrt, "_strtoi64");
3378  p_strtoui64 = (void *)GetProcAddress(hMsvcrt, "_strtoui64");
3379  p_wcstoi64 = (void *)GetProcAddress(hMsvcrt, "_wcstoi64");
3380  p_wcstoui64 = (void *)GetProcAddress(hMsvcrt, "_wcstoui64");
3381  pmbstowcs_s = (void *)GetProcAddress(hMsvcrt, "mbstowcs_s");
3382  pwcstombs_s = (void *)GetProcAddress(hMsvcrt, "wcstombs_s");
3383  pwcsrtombs = (void *)GetProcAddress(hMsvcrt, "wcsrtombs");
3384  p_gcvt_s = (void *)GetProcAddress(hMsvcrt, "_gcvt_s");
3385  p_itoa_s = (void *)GetProcAddress(hMsvcrt, "_itoa_s");
3386  p_strlwr_s = (void *)GetProcAddress(hMsvcrt, "_strlwr_s");
3387  p_ultoa_s = (void *)GetProcAddress(hMsvcrt, "_ultoa_s");
3388  p_wcslwr_s = (void*)GetProcAddress(hMsvcrt, "_wcslwr_s");
3389  p_mbsupr_s = (void*)GetProcAddress(hMsvcrt, "_mbsupr_s");
3390  p_mbslwr_s = (void*)GetProcAddress(hMsvcrt, "_mbslwr_s");
3391  p_wctob = (void*)GetProcAddress(hMsvcrt, "wctob");
3392  p_wcrtomb = (void*)GetProcAddress(hMsvcrt, "wcrtomb");
3393  p_tolower = (void*)GetProcAddress(hMsvcrt, "tolower");
3394  p_mbrlen = (void*)GetProcAddress(hMsvcrt, "mbrlen");
3395  p_mbrtowc = (void*)GetProcAddress(hMsvcrt, "mbrtowc");
3396  p_mbsrtowcs = (void*)GetProcAddress(hMsvcrt, "mbsrtowcs");
3397  p_mbsrtowcs_s = (void*)GetProcAddress(hMsvcrt, "mbsrtowcs_s");
3398  p__atodbl_l = (void*)GetProcAddress(hMsvcrt, "_atodbl_l");
3399  p__atof_l = (void*)GetProcAddress(hMsvcrt, "_atof_l");
3400  p__strtod_l = (void*)GetProcAddress(hMsvcrt, "_strtod_l");
3401  p__strnset_s = (void*)GetProcAddress(hMsvcrt, "_strnset_s");
3402  p__wcsset_s = (void*)GetProcAddress(hMsvcrt, "_wcsset_s");
3403  p__mbsnlen = (void*)GetProcAddress(hMsvcrt, "_mbsnlen");
3404  p__mbccpy_s = (void*)GetProcAddress(hMsvcrt, "_mbccpy_s");
3405  p__memicmp = (void*)GetProcAddress(hMsvcrt, "_memicmp");
3406  p__memicmp_l = (void*)GetProcAddress(hMsvcrt, "_memicmp_l");
3407 
3408  /* MSVCRT memcpy behaves like memmove for overlapping moves,
3409  MFC42 CString::Insert seems to rely on that behaviour */
3410  strcpy(mem,xilstring);
3411  nLen=strlen(xilstring);
3412  pmemcpy(mem+5, mem,nLen+1);
3413  ok(pmemcmp(mem+5,xilstring, nLen) == 0,
3414  "Got result %s\n",mem+5);
3415 
3416  /* run tolower tests first */
3417  test_tolower();
3418  test_swab();
3419  test_mbcp();
3420  test_mbsspn();
3421  test_mbsspnp();
3422  test_strdup();
3423  test_strcpy_s();
3424  test_memcpy_s();
3425  test_memmove_s();
3426  test_strcat_s();
3427  test__mbscat_s();
3428  test__mbsnbcpy_s();
3429  test__mbscpy_s();
3430  test_mbcjisjms();
3431  test_mbcjmsjis();
3432  test_mbctohira();
3433  test_mbctokata();
3434  test_mbbtombc();
3435  test_mbctombb();
3436  test_ismbckata();
3437  test_ismbclegal();
3438  test_strtok();
3439  test__mbstok();
3440  test_wcscpy_s();
3441  test__wcsupr_s();
3442  test_strtol();
3443  test_strnlen();
3444  test__strtoi64();
3445  test__strtod();
3446  test_mbstowcs();
3447  test_gcvt();
3448  test__itoa_s();
3449  test__strlwr_s();
3450  test_wcsncat_s();
3451  test__mbsnbcat_s();
3452  test__ultoa_s();
3453  test__wcslwr_s();
3454  test__mbsupr_s();
3455  test__mbslwr_s();
3456  test_wctob();
3457  test_wctomb();
3458  test__atodbl();
3459  test__stricmp();
3460  test__wcstoi64();
3461  test_atoi();
3462  test_atof();
3463  test_strncpy();
3464  test_strxfrm();
3465  test__strnset_s();
3466  test__wcsset_s();
3467  test__mbscmp();
3468  test__ismbclx();
3469  test__memicmp();
3470  test__memicmp_l();
3471 }
static void test_wctob(void)
Definition: string.c:2685
static void test_swab(void)
Definition: string.c:109
static void test_strcpy_s(void)
Definition: string.c:546
static void test__strlwr_s(void)
Definition: string.c:2253
static void test__memicmp_l(void)
Definition: string.c:3306
static void test_memcpy_s(void)
Definition: string.c:618
static void test__mbslwr_s(void)
Definition: string.c:2533
#define SET(x, y)
Definition: string.c:105
static void test_ismbclegal(void)
Definition: string.c:1429
static void test__strtoi64(void)
Definition: string.c:1636
static void test_mbstowcs(void)
Definition: string.c:1894
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
static void test_strdup(void)
Definition: string.c:538
static void test_ismbckata(void)
Definition: string.c:1398
static void test_mbcjmsjis(void)
Definition: string.c:1263
static void test_mbctombb(void)
Definition: string.c:1376
static void test_mbsspn(void)
Definition: string.c:505
static void test__memicmp(void)
Definition: string.c:3271
static void test__mbsupr_s(void)
Definition: string.c:2476
static void test__atodbl(void)
Definition: string.c:2831
static void test__strtod(void)
Definition: string.c:1787
static void test_wcsncat_s(void)
Definition: string.c:2310
static HMODULE hMsvcrt
Definition: string.c:107
static int *__cdecl * pmemcmp(void *, const void *, size_t n)
static void test_strncpy(void)
Definition: string.c:3057
static void test__itoa_s(void)
Definition: string.c:2157
static void test__stricmp(void)
Definition: string.c:2891
static void test_gcvt(void)
Definition: string.c:2122
static void test__mbscmp(void)
Definition: string.c:3218
static void test_mbsspnp(void)
Definition: string.c:520
static void test__mbscpy_s(void)
Definition: string.c:926
#define ok(value,...)
Definition: CComObject.cpp:34
static void test_wctomb(void)
Definition: string.c:2720
static void test_wcscpy_s(void)
Definition: string.c:962
static unsigned char * p_mbctype
Definition: string.c:85
static void test_atoi(void)
Definition: string.c:3010
static void test_mbctokata(void)
Definition: string.c:1321
static void test__wcsupr_s(void)
Definition: string.c:1063
static void test_strnlen(void)
Definition: string.c:1616
static void test_strxfrm(void)
Definition: string.c:3087
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
Definition: loader.c:819
static void test_atof(void)
Definition: string.c:3027
static void test__ismbclx(void)
Definition: string.c:3248
static void test_strtol(void)
Definition: string.c:1548
static void test__mbscat_s(void)
Definition: string.c:799
static void test_mbcjisjms(void)
Definition: string.c:1237
static void test__mbstok(void)
Definition: string.c:2589
static void test_mbbtombc(void)
Definition: string.c:1350
static void test__mbsnbcat_s(void)
Definition: string.c:2349
static void test_strtok(void)
Definition: string.c:1521
static void test_mbctohira(void)
Definition: string.c:1291
Definition: mem.c:156
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
#define GetProcAddress(x, y)
Definition: compat.h:410
static void test__mbsnbcpy_s(void)
Definition: string.c:879
static void test_mbcp(void)
Definition: string.c:214
static void test__wcslwr_s(void)
Definition: string.c:1150
static void test_memmove_s(void)
Definition: string.c:674
static void test__ultoa_s(void)
Definition: string.c:2607
static void test__strnset_s(void)
Definition: string.c:3154
static void test_strcat_s(void)
Definition: string.c:736
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:2923
static void test_tolower(void)
Definition: string.c:2759
static void test__wcsset_s(void)
Definition: string.c:3184

◆ test__atodbl()

static void test__atodbl ( void  )
static

Definition at line 2831 of file string.c.

2832 {
2833  _CRT_DOUBLE d;
2834  char num[32];
2835  int ret;
2836 
2837  if(!p__atodbl_l) {
2838  /* Old versions of msvcrt use different values for _OVERFLOW and _UNDERFLOW
2839  * Because of this lets skip _atodbl tests when _atodbl_l is not available */
2840  win_skip("_atodbl_l is not available\n");
2841  return;
2842  }
2843 
2844  num[0] = 0;
2845  ret = p__atodbl_l(&d, num, NULL);
2846  ok(ret == 0, "_atodbl_l(&d, \"\", NULL) returned %d, expected 0\n", ret);
2847  ok(d.x == 0, "d.x = %lf, expected 0\n", d.x);
2848  ret = _atodbl(&d, num);
2849  ok(ret == 0, "_atodbl(&d, \"\") returned %d, expected 0\n", ret);
2850  ok(d.x == 0, "d.x = %lf, expected 0\n", d.x);
2851 
2852  strcpy(num, "t");
2853  ret = p__atodbl_l(&d, num, NULL);
2854  ok(ret == 0, "_atodbl_l(&d, \"t\", NULL) returned %d, expected 0\n", ret);
2855  ok(d.x == 0, "d.x = %lf, expected 0\n", d.x);
2856  ret = _atodbl(&d, num);
2857  ok(ret == 0, "_atodbl(&d, \"t\") returned %d, expected 0\n", ret);
2858  ok(d.x == 0, "d.x = %lf, expected 0\n", d.x);
2859 
2860  strcpy(num, "0");
2861  ret = p__atodbl_l(&d, num, NULL);
2862  ok(ret == 0, "_atodbl_l(&d, \"0\", NULL) returned %d, expected 0\n", ret);
2863  ok(d.x == 0, "d.x = %lf, expected 0\n", d.x);
2864  ret = _atodbl(&d, num);
2865  ok(ret == 0, "_atodbl(&d, \"0\") returned %d, expected 0\n", ret);
2866  ok(d.x == 0, "d.x = %lf, expected 0\n", d.x);
2867 
2868  strcpy(num, "123");
2869  ret = p__atodbl_l(&d, num, NULL);
2870  ok(ret == 0, "_atodbl_l(&d, \"123\", NULL) returned %d, expected 0\n", ret);
2871  ok(d.x == 123, "d.x = %lf, expected 123\n", d.x);
2872  ret = _atodbl(&d, num);
2873  ok(ret == 0, "_atodbl(&d, \"123\") returned %d, expected 0\n", ret);
2874  ok(d.x == 123, "d.x = %lf, expected 123\n", d.x);
2875 
2876  strcpy(num, "1e-309");
2877  ret = p__atodbl_l(&d, num, NULL);
2878  ok(ret == _UNDERFLOW, "_atodbl_l(&d, \"1e-309\", NULL) returned %d, expected _UNDERFLOW\n", ret);
2879  ok(d.x!=0 && almost_equal(d.x, 0), "d.x = %le, expected 0\n", d.x);
2880  ret = _atodbl(&d, num);
2881  ok(ret == _UNDERFLOW, "_atodbl(&d, \"1e-309\") returned %d, expected _UNDERFLOW\n", ret);
2882  ok(d.x!=0 && almost_equal(d.x, 0), "d.x = %le, expected 0\n", d.x);
2883 
2884  strcpy(num, "1e309");
2885  ret = p__atodbl_l(&d, num, NULL);
2886  ok(ret == _OVERFLOW, "_atodbl_l(&d, \"1e309\", NULL) returned %d, expected _OVERFLOW\n", ret);
2887  ret = _atodbl(&d, num);
2888  ok(ret == _OVERFLOW, "_atodbl(&d, \"1e309\") returned %d, expected _OVERFLOW\n", ret);
2889 }
smooth NULL
Definition: ftsmooth.c:416
#define ok(value,...)
Definition: CComObject.cpp:34
#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
static BOOL almost_equal(double d1, double d2)
Definition: string.c:1781
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
#define win_skip
Definition: test.h:141
#define _OVERFLOW
Definition: math.h:41

Referenced by START_TEST().

◆ test__ismbclx()

static void test__ismbclx ( void  )
static

Definition at line 3248 of file string.c.

3249 {
3250  int cp, ret;
3251 
3252  ret = _ismbcl0(0);
3253  ok(!ret, "got %d\n", ret);
3254 
3255  cp = _setmbcp(1252);
3256 
3257  ret = _ismbcl0(0x8140);
3258  ok(!ret, "got %d\n", ret);
3259 
3260  _setmbcp(932);
3261 
3262  ret = _ismbcl0(0);
3263  ok(!ret, "got %d\n", ret);
3264 
3265  ret = _ismbcl0(0x8140);
3266  ok(ret, "got %d\n", ret);
3267 
3268  _setmbcp(cp);
3269 }
#define ok(value,...)
Definition: CComObject.cpp:34
int __cdecl _setmbcp(int)
Definition: _setmbcp.c:218
_Check_return_ _CRTIMP int __cdecl _ismbcl0(_In_ unsigned int _Ch)
int ret
POINT cp
Definition: magnifier.c:60

Referenced by START_TEST().

◆ test__itoa_s()

static void test__itoa_s ( void  )
static

Definition at line 2157 of file string.c.

2158 {
2159  errno_t ret;
2160  char buffer[33];
2161 
2162  if (!p_itoa_s)
2163  {
2164  win_skip("Skipping _itoa_s tests\n");
2165  return;
2166  }
2167 
2168  errno = EBADF;
2169  ret = p_itoa_s(0, NULL, 0, 0);
2170  ok(ret == EINVAL, "Expected _itoa_s to return EINVAL, got %d\n", ret);
2171  ok(errno == EINVAL, "Expected errno to be EINVAL, got %d\n", errno);
2172 
2173  memset(buffer, 'X', sizeof(buffer));
2174  errno = EBADF;
2175  ret = p_itoa_s(0, buffer, 0, 0);
2176  ok(ret == EINVAL, "Expected _itoa_s to return EINVAL, got %d\n", ret);
2177  ok(errno == EINVAL, "Expected errno to be EINVAL, got %d\n", errno);
2178  ok(buffer[0] == 'X', "Expected the output buffer to be untouched\n");
2179 
2180  memset(buffer, 'X', sizeof(buffer));
2181  errno = EBADF;
2182  ret = p_itoa_s(0, buffer, sizeof(buffer), 0);
2183  ok(ret == EINVAL, "Expected _itoa_s to return EINVAL, got %d\n", ret);
2184  ok(errno == EINVAL, "Expected errno to be EINVAL, got %d\n", errno);
2185  ok(buffer[0] == '\0', "Expected the output buffer to be null terminated\n");
2186 
2187  memset(buffer, 'X', sizeof(buffer));
2188  errno = EBADF;
2189  ret = p_itoa_s(0, buffer, sizeof(buffer), 64);
2190  ok(ret == EINVAL, "Expected _itoa_s to return EINVAL, got %d\n", ret);
2191  ok(errno == EINVAL, "Expected errno to be EINVAL, got %d\n", errno);
2192  ok(buffer[0] == '\0', "Expected the output buffer to be null terminated\n");
2193 
2194  memset(buffer, 'X', sizeof(buffer));
2195  errno = EBADF;
2196  ret = p_itoa_s(12345678, buffer, 4, 10);
2197  ok(ret == ERANGE, "Expected _itoa_s to return ERANGE, got %d\n", ret);
2198  ok(errno == ERANGE, "Expected errno to be ERANGE, got %d\n", errno);
2199  ok(!memcmp(buffer, "\000765", 4),
2200  "Expected the output buffer to be null terminated with truncated output\n");
2201 
2202  memset(buffer, 'X', sizeof(buffer));
2203  errno = EBADF;
2204  ret = p_itoa_s(12345678, buffer, 8, 10);
2205  ok(ret == ERANGE, "Expected _itoa_s to return ERANGE, got %d\n", ret);
2206  ok(errno == ERANGE, "Expected errno to be ERANGE, got %d\n", errno);
2207  ok(!memcmp(buffer, "\0007654321", 8),
2208  "Expected the output buffer to be null terminated with truncated output\n");
2209 
2210  memset(buffer, 'X', sizeof(buffer));
2211  errno = EBADF;
2212  ret = p_itoa_s(-12345678, buffer, 9, 10);
2213  ok(ret == ERANGE, "Expected _itoa_s to return ERANGE, got %d\n", ret);
2214  ok(errno == ERANGE, "Expected errno to be ERANGE, got %d\n", errno);
2215  ok(!memcmp(buffer, "\00087654321", 9),
2216  "Expected the output buffer to be null terminated with truncated output\n");
2217 
2218  ret = p_itoa_s(12345678, buffer, 9, 10);
2219  ok(ret == 0, "Expected _itoa_s to return 0, got %d\n", ret);
2220  ok(!strcmp(buffer, "12345678"),
2221  "Expected output buffer string to be \"12345678\", got \"%s\"\n",
2222  buffer);
2223 
2224  ret = p_itoa_s(43690, buffer, sizeof(buffer), 2);
2225  ok(ret == 0, "Expected _itoa_s to return 0, got %d\n", ret);
2226  ok(!strcmp(buffer, "1010101010101010"),
2227  "Expected output buffer string to be \"1010101010101010\", got \"%s\"\n",
2228  buffer);
2229 
2230  ret = p_itoa_s(1092009, buffer, sizeof(buffer), 36);
2231  ok(ret == 0, "Expected _itoa_s to return 0, got %d\n", ret);
2232  ok(!strcmp(buffer, "nell"),
2233  "Expected output buffer string to be \"nell\", got \"%s\"\n",
2234  buffer);
2235 
2236  ret = p_itoa_s(5704, buffer, sizeof(buffer), 18);
2237  ok(ret == 0, "Expected _itoa_s to return 0, got %d\n", ret);
2238  ok(!strcmp(buffer, "hag"),
2239  "Expected output buffer string to be \"hag\", got \"%s\"\n",
2240  buffer);
2241 
2242  ret = p_itoa_s(-12345678, buffer, sizeof(buffer), 10);
2243  ok(ret == 0, "Expected _itoa_s to return 0, got %d\n", ret);
2244  ok(!strcmp(buffer, "-12345678"),
2245  "Expected output buffer string to be \"-12345678\", got \"%s\"\n",
2246  buffer);
2247 
2248  itoa(100, buffer, 100);
2249  ok(!strcmp(buffer, "10"),
2250  "Expected output buffer string to be \"10\", got \"%s\"\n", buffer);
2251 }
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 ok(value,...)
Definition: CComObject.cpp:34
_CRTIMP char *__cdecl itoa(_In_ int _Val, _Pre_notnull_ _Post_z_ char *_DstBuf, _In_ int _Radix)
#define ERANGE
Definition: acclib.h:92
int ret
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:141

Referenced by START_TEST().

◆ test__mbscat_s()

static void test__mbscat_s ( void  )
static

Definition at line 799 of file string.c.

800 {
801  unsigned char dst[8], src[4];
802  int err;
803  int prev_cp = _getmbcp();
804 
805  if(!p_mbscat_s)
806  {
807  win_skip("_mbscat_s not found\n");
808  return;
809  }
810 
811 
812  src[0] = dst[0] = 0;
813  err = p_mbscat_s(NULL, sizeof(dst), src);
814  ok(err == EINVAL, "_mbscat_s returned %d\n", err);
815 
816  err = p_mbscat_s(dst, sizeof(dst), NULL);
817  ok(err == EINVAL, "_mbscat_s returned %d\n", err);
818 
819  dst[0] = 'a';
820  err = p_mbscat_s(dst, 1, src);
821  ok(err == EINVAL, "_mbscat_s returned %d\n", err);
822 
823  memset(dst, 'a', sizeof(dst));
824  dst[6] = 0;
825  src[0] = 'b';
826  src[1] = 0;
827 
828  err = p_mbscat_s(dst, sizeof(dst), src);
829  ok(err == 0, "_mbscat_s returned %d\n", err);
830  ok(!memcmp(dst, "aaaaaab", 8), "dst = %s\n", dst);
831 
832  err = p_mbscat_s(dst, sizeof(dst), src);
833  ok(err == ERANGE, "_mbscat_s returned %d\n", err);
834  ok(!dst[0], "dst[0] = %c\n", dst[0]);
835  ok(dst[1] == 'a', "dst[1] = %c\n", dst[1]);
836 
837  _setmbcp(932);
838  /* test invalid str in dst */
839  dst[0] = 0x81;
840  dst[1] = 0x81;
841  dst[2] = 0x52;
842  dst[3] = 0;
843  src[0] = 'a';
844  src[1] = 0;
845  err = p_mbscat_s(dst, sizeof(dst), src);
846  ok(err == 0, "_mbscat_s returned %d\n", err);
847 
848  /* test invalid str in src */
849  dst[0] = 0;
850  src[0] = 0x81;
851  src[1] = 0x81;
852  src[2] = 0x52;
853  src[3] = 0;
854  err = p_mbscat_s(dst, sizeof(dst), src);
855  ok(err == 0, "_mbscat_s returned %d\n", err);
856 
857  /* test dst with leading byte on the end of buffer */
858  dst[0] = 'a';
859  dst[1] = 0x81;
860  dst[2] = 0;
861  src[0] = 'R';
862  src[1] = 0;
863  err = p_mbscat_s(dst, sizeof(dst), src);
864  ok(err == EILSEQ, "_mbscat_s returned %d\n", err);
865  ok(!memcmp(dst, "aR", 3), "dst = %s\n", dst);
866 
867  /* test src with leading byte on the end of buffer */
868  dst[0] = 'a';
869  dst[1] = 0;
870  src[0] = 'b';
871  src[1] = 0x81;
872  src[2] = 0;
873  err = p_mbscat_s(dst, sizeof(dst), src);
874  ok(err == EILSEQ, "_mbscat_s returned %d\n", err);
875  ok(!memcmp(dst, "ab", 3), "dst = %s\n", dst);
876  _setmbcp(prev_cp);
877 }
#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
#define ok(value,...)
Definition: CComObject.cpp:34
int __cdecl _setmbcp(int)
Definition: _setmbcp.c:218
#define ERANGE
Definition: acclib.h:92
GLenum src
Definition: glext.h:6340
#define err(...)
GLenum GLenum dst
Definition: glext.h:6340
#define memset(x, y, z)
Definition: compat.h:39
#define win_skip
Definition: test.h:141

Referenced by START_TEST().

◆ test__mbscmp()

static void test__mbscmp ( void  )
static

Definition at line 3218 of file string.c.

3219 {
3220  static const unsigned char a[] = {'a',0}, b[] = {'b',0};
3221  int ret;
3222 
3223  if (!p_mbrlen)
3224  {
3225  win_skip("_mbscmp tests\n");
3226  return;
3227  }
3228 
3229  ret = _mbscmp(NULL, NULL);
3230  ok(ret == INT_MAX, "got %d\n", ret);
3231 
3232  ret = _mbscmp(a, NULL);
3233  ok(ret == INT_MAX, "got %d\n", ret);
3234 
3235  ret = _mbscmp(NULL, a);
3236  ok(ret == INT_MAX, "got %d\n", ret);
3237 
3238  ret = _mbscmp(a, a);
3239  ok(!ret, "got %d\n", ret);
3240 
3241  ret = _mbscmp(a, b);
3242  ok(ret == -1, "got %d\n", ret);
3243 
3244  ret = _mbscmp(b, a);
3245  ok(ret == 1, "got %d\n", ret);
3246 }
#define INT_MAX
Definition: limits.h:40
smooth NULL
Definition: ftsmooth.c:416
#define ok(value,...)
Definition: CComObject.cpp:34
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
GLboolean GLboolean GLboolean GLboolean a
Definition: glext.h:6204
#define win_skip
Definition: test.h:141

Referenced by START_TEST().

◆ test__mbscpy_s()

static void test__mbscpy_s ( void  )
static

Definition at line 926 of file string.c.

927 {
928  const unsigned char src[] = "source string";
929  unsigned char dest[16];
930  int ret;
931 
932  if(!p__mbscpy_s)
933  {
934  win_skip("_mbscpy_s not found\n");
935  return;
936  }
937 
938  ret = p__mbscpy_s(NULL, 0, src);
939  ok(ret == EINVAL, "got %d\n", ret);
940  ret = p__mbscpy_s(NULL, sizeof(dest), src);
941  ok(ret == EINVAL, "got %d\n", ret);
942  ret = p__mbscpy_s(dest, 0, src);
943  ok(ret == EINVAL, "got %d\n", ret);
944  dest[0] = 'x';
945  ret = p__mbscpy_s(dest, sizeof(dest), NULL);
946  ok(ret == EINVAL, "got %d\n", ret);
947  ok(!dest[0], "dest buffer was not modified on invalid argument\n");
948 
949  memset(dest, 'X', sizeof(dest));
950  ret = p__mbscpy_s(dest, sizeof(dest), src);
951  ok(!ret, "got %d\n", ret);
952  ok(!memcmp(dest, src, sizeof(src)), "dest = %s\n", dest);
953  ok(dest[sizeof(src)] == 'X', "unused part of buffer was modified\n");
954 
955  memset(dest, 'X', sizeof(dest));
956  ret = p__mbscpy_s(dest, 4, src);
957  ok(ret == ERANGE, "got %d\n", ret);
958  ok(!dest[0], "incorrect dest buffer (%d)\n", dest[0]);
959  ok(dest[1] == src[1], "incorrect dest buffer (%d)\n", dest[1]);
960 }
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
Definition: arc.h:39
smooth NULL
Definition: ftsmooth.c:416
#define ok(value,...)
Definition: CComObject.cpp:34
#define ERANGE
Definition: acclib.h:92
int ret
GLenum src
Definition: glext.h:6340
static char * dest
Definition: rtl.c:135
#define memset(x, y, z)
Definition: compat.h:39
#define win_skip
Definition: test.h:141

Referenced by START_TEST().

◆ test__mbslwr_s()

static void test__mbslwr_s ( void  )
static

Definition at line 2533 of file string.c.

2534 {
2535  errno_t ret;
2536  unsigned char buffer[20];
2537 
2538  if (!p_mbslwr_s)
2539  {
2540  win_skip("Skipping _mbslwr_s tests\n");
2541  return;
2542  }
2543 
2544  errno = EBADF;
2545  ret = p_mbslwr_s(NULL, 0);
2546  ok(ret == 0, "Expected _mbslwr_s to return 0, got %d\n", ret);
2547 
2548  errno = EBADF;
2549  ret = p_mbslwr_s(NULL, sizeof(buffer));
2550  ok(ret == EINVAL, "Expected _mbslwr_s to return EINVAL, got %d\n", ret);
2551  ok(errno == EINVAL, "Expected errno to be EINVAL, got %d\n", errno);
2552 
2553  errno = EBADF;
2554  ret = p_mbslwr_s(buffer, 0);
2555  ok(ret == EINVAL, "Expected _mbslwr_s to return EINVAL, got %d\n", ret);
2556  ok(errno == EINVAL, "Expected errno to be EINVAL, got %d\n", errno);
2557 
2558  memcpy(buffer, "ABCDEFGH", sizeof("ABCDEFGH"));
2559  errno = EBADF;
2560  ret = p_mbslwr_s(buffer, sizeof("ABCDEFGH"));
2561  ok(ret == 0, "Expected _mbslwr_s to return 0, got %d\n", ret);
2562  ok(!memcmp(buffer, "abcdefgh", sizeof("abcdefgh")),
2563  "Expected the output buffer to be \"abcdefgh\", got \"%s\"\n",
2564  buffer);
2565 
2566  memcpy(buffer, "ABCDEFGH", sizeof("ABCDEFGH"));
2567  errno = EBADF;
2568  ret = p_mbslwr_s(buffer, sizeof(buffer));
2569  ok(ret == 0, "Expected _mbslwr_s to return 0, got %d\n", ret);
2570  ok(!memcmp(buffer, "abcdefgh", sizeof("abcdefgh")),
2571  "Expected the output buffer to be \"abcdefgh\", got \"%s\"\n",
2572  buffer);
2573 
2574  memcpy(buffer, "ABCDEFGH", sizeof("ABCDEFGH"));
2575  errno = EBADF;
2576  ret = p_mbslwr_s(buffer, 4);
2577  ok(ret == EINVAL, "Expected _mbslwr_s to return EINVAL, got %d\n", ret);
2578  ok(errno == EINVAL, "Expected errno to be EINVAL, got %d\n", errno);
2579 
2580  memcpy(buffer, "ABCDEFGH\0IJKLMNOP", sizeof("ABCDEFGH\0IJKLMNOP"));
2581  errno = EBADF;
2582  ret = p_mbslwr_s(buffer, sizeof(buffer));
2583  ok(ret == 0, "Expected _mbslwr_s to return 0, got %d\n", ret);
2584  ok(!memcmp(buffer, "abcdefgh\0IJKLMNOP", sizeof("abcdefgh\0IJKLMNOP")),
2585  "Expected the output buffer to be \"abcdefgh\\0IJKLMNOP\", got \"%s\"\n",
2586  buffer);
2587 }
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 ok(value,...)
Definition: CComObject.cpp:34
int ret
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define win_skip
Definition: test.h:141

Referenced by START_TEST().

◆ test__mbsnbcat_s()

static void test__mbsnbcat_s ( void  )
static

Definition at line 2349 of file string.c.

2350 {
2351  unsigned char dest[16];
2352  const unsigned char first[] = "dinosaur";
2353  const unsigned char second[] = "duck";
2354  int ret;
2355 
2356  if (!p_mbsnbcat_s)
2357  {
2358  win_skip("Skipping _mbsnbcat_s tests\n");
2359  return;
2360  }
2361 
2362  /* Test invalid arguments. */
2363  ret = p_mbsnbcat_s(NULL, 0, NULL, 0);
2364  ok(ret == 0, "Expected _mbsnbcat_s to return 0, got %d\n", ret);
2365 
2366  errno = EBADF;
2367  ret = p_mbsnbcat_s(NULL, 10, NULL, 0);
2368  ok(ret == EINVAL, "Expected _mbsnbcat_s to return EINVAL, got %d\n", ret);
2369  ok(errno == EINVAL, "Expected errno to be EINVAL, got %d\n", errno);
2370 
2371  errno = EBADF;
2372  ret = p_mbsnbcat_s(NULL, 0, NULL, 10);
2373  ok(ret == EINVAL, "Expected _mbsnbcat_s to return EINVAL, got %d\n", ret);
2374  ok(errno == EINVAL, "Expected errno to be EINVAL, got %d\n", errno);
2375 
2376  memset(dest, 'X', sizeof(dest));
2377  errno = EBADF;
2378  ret = p_mbsnbcat_s(dest, 0, NULL, 0);
2379  ok(ret == EINVAL, "Expected _mbsnbcat_s to return EINVAL, got %d\n", ret);
2380  ok(errno == EINVAL, "Expected errno to be EINVAL, got %d\n", errno);
2381  ok(dest[0] == 'X', "Expected the output buffer to be untouched\n");
2382 
2383  memset(dest, 'X', sizeof(dest));
2384  errno = EBADF;
2385  ret = p_mbsnbcat_s(dest, 0, second, 0);
2386  ok(ret == EINVAL, "Expected _mbsnbcat_s to return EINVAL, got %d\n", ret);
2387  ok(errno == EINVAL, "Expected errno to be EINVAL, got %d\n", errno);
2388  ok(dest[0] == 'X', "Expected the output buffer to be untouched\n");
2389 
2390  memset(dest, 'X', sizeof(dest));
2391  errno = EBADF;
2392  ret = p_mbsnbcat_s(dest, sizeof(dest), NULL, 0);
2393  ok(ret == EINVAL, "Expected _mbsnbcat_s to return EINVAL, got %d\n", ret);
2394  ok(errno == EINVAL, "Expected errno to be EINVAL, got %d\n", errno);
2395  ok(dest[0] == '\0', "Expected the output buffer to be null terminated\n");
2396 
2397  memset(dest, 'X', sizeof(dest));
2398  errno = EBADF;
2399  ret = p_mbsnbcat_s(dest, sizeof(dest), NULL, 10);
2400  ok(ret == EINVAL, "Expected _mbsnbcat_s to return EINVAL, got %d\n", ret);
2401  ok(errno == EINVAL, "Expected errno to be EINVAL, got %d\n", errno);
2402  ok(dest[0] == '\0', "Expected the output buffer to be null terminated\n");
2403 
2404  memset(dest, 'X', sizeof(dest));
2405  dest[0] = '\0';
2406  ret = p_mbsnbcat_s(dest, sizeof(dest), second, sizeof(second));
2407  ok(ret == 0, "Expected _mbsnbcat_s to return 0, got %d\n", ret);
2408  ok(!memcmp(dest, second, sizeof(second)),
2409  "Expected the output buffer string to be \"duck\"\n");
2410 
2411  /* Test source truncation behavior. */
2412  memset(dest, 'X', sizeof(dest));
2413  memcpy(dest, first, sizeof(first));
2414  ret = p_mbsnbcat_s(dest, sizeof(dest), second, 0);
2415  ok(ret == 0, "Expected _mbsnbcat_s to return 0, got %d\n", ret);
2416  ok(!memcmp(dest, first, sizeof(first)),
2417  "Expected the output buffer string to be \"dinosaur\"\n");
2418 
2419  memset(dest, 'X', sizeof(dest));
2420  memcpy(dest, first, sizeof(first));
2421  ret = p_mbsnbcat_s(dest, sizeof(dest), second, sizeof(second));
2422  ok(ret == 0, "Expected _mbsnbcat_s to return 0, got %d\n", ret);
2423  ok(!memcmp(dest, "dinosaurduck", sizeof("dinosaurduck")),
2424  "Expected the output buffer string to be \"dinosaurduck\"\n");
2425 
2426  memset(dest, 'X', sizeof(dest));
2427  memcpy(dest, first, sizeof(first));
2428  ret = p_mbsnbcat_s(dest, sizeof(dest), second, sizeof(second) + 1);
2429  ok(ret == 0, "Expected _mbsnbcat_s to return 0, got %d\n", ret);
2430  ok(!memcmp(dest, "dinosaurduck", sizeof("dinosaurduck")),
2431  "Expected the output buffer string to be \"dinosaurduck\"\n");
2432 
2433  memset(dest, 'X', sizeof(dest));
2434  memcpy(dest, first, sizeof(first));
2435  ret = p_mbsnbcat_s(dest, sizeof(dest), second, sizeof(second) - 1);
2436  ok(ret == 0, "Expected _mbsnbcat_s to return 0, got %d\n", ret);
2437  ok(!memcmp(dest, "dinosaurduck", sizeof("dinosaurduck")),
2438  "Expected the output buffer string to be \"dinosaurduck\"\n");
2439 
2440  memset(dest, 'X', sizeof(dest));
2441  memcpy(dest, first, sizeof(first));
2442  ret = p_mbsnbcat_s(dest, sizeof(dest), second, sizeof(second) - 2);
2443  ok(ret == 0, "Expected _mbsnbcat_s to return 0, got %d\n", ret);
2444  ok(!memcmp(dest, "dinosaurduc", sizeof("dinosaurduc")),
2445  "Expected the output buffer string to be \"dinosaurduc\"\n");
2446 
2447  /* Test destination truncation behavior. */
2448  memset(dest, 'X', sizeof(dest));
2449  memcpy(dest, first, sizeof(first));
2450  errno = EBADF;
2451  ret = p_mbsnbcat_s(dest, sizeof(first) - 1, second, sizeof(second));
2452  ok(ret == EINVAL, "Expected _mbsnbcat_s to return EINVAL, got %d\n", ret);
2453  ok(errno == EINVAL, "Expected errno to be EINVAL, got %d\n", errno);
2454  ok(!memcmp(dest, "\0inosaur", sizeof("\0inosaur") - 1),
2455  "Expected the output buffer string to be \"\\0inosaur\" without ending null terminator\n");
2456 
2457  memset(dest, 'X', sizeof(dest));
2458  memcpy(dest, first, sizeof(first));
2459  errno = EBADF;
2460  ret = p_mbsnbcat_s(dest, sizeof(first), second, sizeof(second));
2461  ok(ret == ERANGE, "Expected _mbsnbcat_s to return ERANGE, got %d\n", ret);
2462  ok(errno == ERANGE, "Expected errno to be ERANGE, got %d\n", errno);
2463  ok(!memcmp(dest, "\0inosaurd", sizeof("\0inosaurd") - 1),
2464  "Expected the output buffer string to be \"\\0inosaurd\" without ending null terminator\n");
2465 
2466  memset(dest, 'X', sizeof(dest));
2467  memcpy(dest, first, sizeof(first));
2468  errno = EBADF;
2469  ret = p_mbsnbcat_s(dest, sizeof(first) + 1, second, sizeof(second));
2470  ok(ret == ERANGE, "Expected _mbsnbcat_s to return ERANGE, got %d\n", ret);
2471  ok(errno == ERANGE, "Expected errno to be ERANGE, got %d\n", errno);
2472  ok(!memcmp(dest, "\0inosaurdu", sizeof("\0inosaurdu") - 1),
2473  "Expected the output buffer string to be \"\\0inosaurdu\" without ending null terminator\n");
2474 }
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 ok(value,...)
Definition: CComObject.cpp:34
#define ERANGE
Definition: acclib.h:92
int ret
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
static char * dest
Definition: rtl.c:135
#define memset(x, y, z)
Definition: compat.h:39
#define win_skip
Definition: test.h:141

Referenced by START_TEST().

◆ test__mbsnbcpy_s()

static void test__mbsnbcpy_s ( void  )
static

Definition at line 879 of file string.c.

880 {
881  unsigned char dest[8];
882  const unsigned char big[] = "atoolongstringforthislittledestination";
883  const unsigned char small[] = "small";
884  int ret;
885 
886  if(!p_mbsnbcpy_s)
887  {
888  win_skip("_mbsnbcpy_s not found\n");
889  return;
890  }
891 
892  memset(dest, 'X', sizeof(dest));
893  ret = p_mbsnbcpy_s(dest, sizeof(dest), small, sizeof(small));
894  ok(ret == 0, "_mbsnbcpy_s: Copying a string into a big enough destination returned %d, expected 0\n", ret);
895  ok(dest[0] == 's' && dest[1] == 'm' && dest[2] == 'a' && dest[3] == 'l' &&
896  dest[4] == 'l' && dest[5] == '\0'&& dest[6] == 'X' && dest[7] == 'X',
897  "Unexpected return data from _mbsnbcpy_s: 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x\n",
898  dest[0], dest[1], dest[2], dest[3], dest[4], dest[5], dest[6], dest[7]);
899 
900  /* WTF? */
901  memset(dest, 'X', sizeof(dest));
902  ret = p_mbsnbcpy_s(dest, sizeof(dest) - 2, big, sizeof(small));
903  ok(ret == ERANGE, "_mbsnbcpy_s: Copying a too long string returned %d, expected ERANGE\n", ret);
904  ok(dest[0] == '\0'&& dest[1] == 't' && dest[2] == 'o' && dest[3] == 'o' &&
905  dest[4] == 'l' && dest[5] == 'o' && dest[6] == 'X' && dest[7] == 'X',
906  "Unexpected return data from _mbsnbcpy_s: 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x\n",
907  dest[0], dest[1], dest[2], dest[3], dest[4], dest[5], dest[6], dest[7]);
908 
909  memset(dest, 'X', sizeof(dest));
910  ret = p_mbsnbcpy_s(dest, sizeof(dest) - 2, big, 4);
911  ok(ret == 0, "_mbsnbcpy_s: Copying a too long string with a count cap returned %d, expected 0\n", ret);
912  ok(dest[0] == 'a' && dest[1] == 't' && dest[2] == 'o' && dest[3] == 'o' &&
913  dest[4] == '\0'&& dest[5] == 'X' && dest[6] == 'X' && dest[7] == 'X',
914  "Unexpected return data from _mbsnbcpy_s: 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x\n",
915  dest[0], dest[1], dest[2], dest[3], dest[4], dest[5], dest[6], dest[7]);
916 
917  memset(dest, 'X', sizeof(dest));
918  ret = p_mbsnbcpy_s(dest, sizeof(dest) - 2, small, sizeof(small) + 10);
919  ok(ret == 0, "_mbsnbcpy_s: Copying more data than the source string len returned %d, expected 0\n", ret);
920  ok(dest[0] == 's' && dest[1] == 'm' && dest[2] == 'a' && dest[3] == 'l' &&
921  dest[4] == 'l' && dest[5] == '\0'&& dest[6] == 'X' && dest[7] == 'X',
922  "Unexpected return data from _mbsnbcpy_s: 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x\n",
923  dest[0], dest[1], dest[2], dest[3], dest[4], dest[5], dest[6], dest[7]);
924 }
#define small
Definition: rpcndr.h:115
#define ok(value,...)
Definition: CComObject.cpp:34
#define ERANGE
Definition: acclib.h:92
int ret
static char * dest
Definition: rtl.c:135
#define memset(x, y, z)
Definition: compat.h:39
#define win_skip
Definition: test.h:141

Referenced by START_TEST().

◆ test__mbstok()

static void test__mbstok ( void  )
static

Definition at line 2589 of file string.c.

2590 {
2591  const unsigned char delim[] = "t";
2592 
2593  char str[] = "!.!test";
2594  unsigned char *ret;
2595 
2596  strtok(str, "!");
2597 
2598  ret = _mbstok(NULL, delim);
2599  /* most versions of msvcrt use the same buffer for strtok and _mbstok */
2600  ok(!ret || broken((char*)ret==str+4),
2601  "_mbstok(NULL, \"t\") = %p, expected NULL (%p)\n", ret, str);
2602 
2603  ret = _mbstok(NULL, delim);
2604  ok(!ret, "_mbstok(NULL, \"t\") = %p, expected NULL\n", ret);
2605 }
_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
#define ok(value,...)
Definition: CComObject.cpp:34
int ret
#define broken(x)
Definition: _sntprintf.h:21
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 2476 of file string.c.

2477 {
2478  errno_t ret;
2479  unsigned char buffer[20];
2480 
2481  if (!p_mbsupr_s)
2482  {
2483  win_skip("Skipping _mbsupr_s tests\n");
2484  return;
2485  }
2486 
2487  errno = EBADF;
2488  ret = p_mbsupr_s(NULL, 0);
2489  ok(ret == 0, "Expected _mbsupr_s to return 0, got %d\n", ret);
2490 
2491  errno = EBADF;
2492  ret = p_mbsupr_s(NULL, sizeof(buffer));
2493  ok(ret == EINVAL, "Expected _mbsupr_s to return EINVAL, got %d\n", ret);
2494  ok(errno == EINVAL, "Expected errno to be EINVAL, got %d\n", errno);
2495 
2496  errno = EBADF;
2497  ret = p_mbsupr_s(buffer, 0);
2498  ok(ret == EINVAL, "Expected _mbsupr_s to return EINVAL, got %d\n", ret);
2499  ok(errno == EINVAL, "Expected errno to be EINVAL, got %d\n", errno);
2500 
2501  memcpy(buffer, "abcdefgh", sizeof("abcdefgh"));
2502  errno = EBADF;
2503  ret = p_mbsupr_s(buffer, sizeof("abcdefgh"));
2504  ok(ret == 0, "Expected _mbsupr_s to return 0, got %d\n", ret);
2505  ok(!memcmp(buffer, "ABCDEFGH", sizeof("ABCDEFGH")),
2506  "Expected the output buffer to be \"ABCDEFGH\", got \"%s\"\n",
2507  buffer);
2508 
2509  memcpy(buffer, "abcdefgh", sizeof("abcdefgh"));
2510  errno = EBADF;
2511  ret = p_mbsupr_s(buffer, sizeof(buffer));
2512  ok(ret == 0, "Expected _mbsupr_s to return 0, got %d\n", ret);
2513  ok(!memcmp(buffer, "ABCDEFGH", sizeof("ABCDEFGH")),
2514  "Expected the output buffer to be \"ABCDEFGH\", got \"%s\"\n",
2515  buffer);
2516 
2517  memcpy(buffer, "abcdefgh", sizeof("abcdefgh"));
2518  errno = EBADF;
2519  ret = p_mbsupr_s(buffer, 4);
2520  ok(ret == EINVAL, "Expected _mbsupr_s to return EINVAL, got %d\n", ret);
2521  ok(errno == EINVAL, "Expected errno to be EINVAL, got %d\n", errno);
2522 
2523  memcpy(buffer, "abcdefgh\0ijklmnop", sizeof("abcdefgh\0ijklmnop"));
2524  errno = EBADF;
2525  ret = p_mbsupr_s(buffer, sizeof(buffer));
2526  ok(ret == 0, "Expected _mbsupr_s to return 0, got %d\n", ret);
2527  ok(!memcmp(buffer, "ABCDEFGH\0ijklmnop", sizeof("ABCDEFGH\0ijklmnop")),
2528  "Expected the output buffer to be \"ABCDEFGH\\0ijklmnop\", got \"%s\"\n",
2529  buffer);
2530 
2531 }
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 ok(value,...)
Definition: CComObject.cpp:34
int ret
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define win_skip
Definition: test.h:141

Referenced by START_TEST().

◆ test__memicmp()

static void test__memicmp ( void  )
static

Definition at line 3271 of file string.c.

3272 {
3273  static const char *s1 = "abc";
3274  static const char *s2 = "aBd";
3275  int ret;
3276 
3277  ret = p__memicmp(NULL, NULL, 0);
3278  ok(!ret, "got %d\n", ret);
3279 
3280  ret = p__memicmp(s1, s2, 2);
3281  ok(!ret, "got %d\n", ret);
3282 
3283  ret = p__memicmp(s1, s2, 3);
3284  ok(ret == -1, "got %d\n", ret);
3285 
3286  if (!p__memicmp_l)
3287  return;
3288 
3289  /* Following calls crash on WinXP/W2k3. */
3290  errno = 0xdeadbeef;
3291  ret = p__memicmp(NULL, NULL, 1);
3292  ok(ret == _NLSCMPERROR, "got %d\n", ret);
3293  ok(errno == EINVAL, "errno is %d, expected EINVAL\n", errno);
3294 
3295  errno = 0xdeadbeef;
3296  ret = p__memicmp(s1, NULL, 1);
3297  ok(ret == _NLSCMPERROR, "got %d\n", ret);
3298  ok(errno == EINVAL, "errno is %d, expected EINVAL\n", errno);
3299 
3300  errno = 0xdeadbeef;
3301  ret = p__memicmp(NULL, s2, 1);
3302  ok(ret == _NLSCMPERROR, "got %d\n", ret);
3303  ok(errno == EINVAL, "errno is %d, expected EINVAL\n", errno);
3304 }
struct S2 s2
Definition: arc.h:39
int errno
smooth NULL
Definition: ftsmooth.c:416
#define ok(value,...)
Definition: CComObject.cpp:34
struct S1 s1
int ret
#define _NLSCMPERROR
Definition: string.h:17

Referenced by START_TEST().

◆ test__memicmp_l()

static void test__memicmp_l ( void  )
static

Definition at line 3306 of file string.c.

3307 {
3308  static const char *s1 = "abc";
3309  static const char *s2 = "aBd";
3310  int ret;
3311 
3312  if (!p__memicmp_l)
3313  {
3314  win_skip("_memicmp_l not found.\n");
3315  return;
3316  }
3317 
3318  errno = 0xdeadbeef;
3319  ret = p__memicmp_l(NULL, NULL, 0, NULL);
3320  ok(!ret, "got %d\n", ret);
3321  ok(errno == 0xdeadbeef, "errno is %d, expected 0xdeadbeef\n", errno);
3322 
3323  errno = 0xdeadbeef;
3324  ret = p__memicmp_l(NULL, NULL, 1, NULL);
3325  ok(ret == _NLSCMPERROR, "got %d\n", ret);
3326  ok(errno == EINVAL, "errno is %d, expected EINVAL\n", errno);
3327 
3328  errno = 0xdeadbeef;
3329  ret = p__memicmp_l(s1, NULL, 1, NULL);
3330  ok(ret == _NLSCMPERROR, "got %d\n", ret);
3331  ok(errno == EINVAL, "errno is %d, expected EINVAL\n", errno);
3332 
3333  errno = 0xdeadbeef;
3334  ret = p__memicmp_l(NULL, s2, 1, NULL);
3335  ok(ret == _NLSCMPERROR, "got %d\n", ret);
3336  ok(errno == EINVAL, "errno is %d, expected EINVAL\n", errno);
3337 
3338  errno = 0xdeadbeef;
3339  ret = p__memicmp_l(s1, s2, 2, NULL);
3340  ok(!ret, "got %d\n", ret);
3341  ok(errno == 0xdeadbeef, "errno is %d, expected 0xdeadbeef\n", errno);
3342 
3343  errno = 0xdeadbeef;
3344  ret = p__memicmp_l(s1, s2, 3, NULL);
3345  ok(ret == -1, "got %d\n", ret);
3346  ok(errno == 0xdeadbeef, "errno is %d, expected 0xdeadbeef\n", errno);
3347 }
struct S2 s2
Definition: arc.h:39
int errno
smooth NULL
Definition: ftsmooth.c:416
#define ok(value,...)
Definition: CComObject.cpp:34
struct S1 s1
int ret
#define _NLSCMPERROR
Definition: string.h:17
#define win_skip
Definition: test.h:141

Referenced by START_TEST().

◆ test__stricmp()

static void test__stricmp ( void  )
static

Definition at line 2891 of file string.c.

2892 {
2893  int ret;
2894 
2895  ret = _stricmp("test", "test");
2896  ok(ret == 0, "_stricmp returned %d\n", ret);
2897  ret = _stricmp("a", "z");
2898  ok(ret < 0, "_stricmp returned %d\n", ret);
2899  ret = _stricmp("z", "a");
2900  ok(ret > 0, "_stricmp returned %d\n", ret);
2901  ret = _stricmp("\xa5", "\xb9");
2902  ok(ret < 0, "_stricmp returned %d\n", ret);
2903 
2904  if(!setlocale(LC_ALL, "polish")) {
2905  win_skip("stricmp tests\n");
2906  return;
2907  }
2908 
2909  ret = _stricmp("test", "test");
2910  ok(ret == 0, "_stricmp returned %d\n", ret);
2911  ret = _stricmp("a", "z");
2912  ok(ret < 0, "_stricmp returned %d\n", ret);
2913  ret = _stricmp("z", "a");
2914  ok(ret > 0, "_stricmp returned %d\n", ret);
2915  ret = _stricmp("\xa5", "\xb9");
2916  ok(ret == 0, "_stricmp returned %d\n", ret);
2917  ret = _stricmp("a", "\xb9");
2918  ok(ret < 0, "_stricmp returned %d\n", ret);
2919 
2920  setlocale(LC_ALL, "C");
2921 }
#define ok(value,...)
Definition: CComObject.cpp:34
#define LC_ALL
Definition: locale.h:25
int _stricmp(const char *str1, const char *str2)
Definition: string.c:11
int ret
#define setlocale(n, s)
Definition: locale.h:46
#define win_skip
Definition: test.h:141

Referenced by START_TEST().

◆ test__strlwr_s()

static void test__strlwr_s ( void  )
static

Definition at line 2253 of file string.c.

2254 {
2255  errno_t ret;
2256  char buffer[20];
2257 
2258  if (!p_strlwr_s)
2259  {
2260  win_skip("Skipping _strlwr_s tests\n");
2261  return;
2262  }
2263 
2264  errno = EBADF;
2265  ret = p_strlwr_s(NULL, 0);
2266  ok(ret == EINVAL, "Expected _strlwr_s to return EINVAL, got %d\n", ret);
2267  ok(errno == EINVAL, "Expected errno to be EINVAL, got %d\n", errno);
2268 
2269  errno = EBADF;
2270  ret = p_strlwr_s(NULL, sizeof(buffer));
2271  ok(ret == EINVAL, "Expected _strlwr_s to return EINVAL, got %d\n", ret);
2272  ok(errno == EINVAL, "Expected errno to be EINVAL, got %d\n", errno);
2273 
2274  errno = EBADF;
2275  ret = p_strlwr_s(buffer, 0);
2276  ok(ret == EINVAL, "Expected _strlwr_s to return EINVAL, got %d\n", ret);
2277  ok(errno == EINVAL, "Expected errno to be EINVAL, got %d\n", errno);
2278 
2279  strcpy(buffer, "GoRrIsTeR");
2280  errno = EBADF;
2281  ret = p_strlwr_s(buffer, 5);
2282  ok(ret == EINVAL, "Expected _strlwr_s to return EINVAL, got %d\n", ret);
2283  ok(errno == EINVAL, "Expected errno to be EINVAL, got %d\n", errno);
2284  ok(!memcmp(buffer, "\0oRrIsTeR", sizeof("\0oRrIsTeR")),
2285  "Expected the output buffer to be \"\\0oRrIsTeR\"\n");
2286 
2287  strcpy(buffer, "GoRrIsTeR");
2288  errno = EBADF;
2289  ret = p_strlwr_s(buffer, sizeof("GoRrIsTeR") - 1);
2290  ok(ret == EINVAL, "Expected _strlwr_s to return EINVAL, got %d\n", ret);
2291  ok(errno == EINVAL, "Expected errno to be EINVAL, got %d\n", errno);
2292  ok(!memcmp(buffer, "\0oRrIsTeR", sizeof("\0oRrIsTeR")),
2293  "Expected the output buffer to be \"\\0oRrIsTeR\"\n");
2294 
2295  strcpy(buffer, "GoRrIsTeR");
2296  ret = p_strlwr_s(buffer, sizeof("GoRrIsTeR"));
2297  ok(ret == 0, "Expected _strlwr_s to return 0, got %d\n", ret);
2298  ok(!strcmp(buffer, "gorrister"),
2299  "Expected the output buffer to be \"gorrister\", got \"%s\"\n",
2300  buffer);
2301 
2302  memcpy(buffer, "GoRrIsTeR\0ELLEN", sizeof("GoRrIsTeR\0ELLEN"));
2303  ret = p_strlwr_s(buffer, sizeof(buffer));
2304  ok(ret == 0, "Expected _strlwr_s to return 0, got %d\n", ret);
2305  ok(!memcmp(buffer, "gorrister\0ELLEN", sizeof("gorrister\0ELLEN")),
2306  "Expected the output buffer to be \"gorrister\\0ELLEN\", got \"%s\"\n",
2307  buffer);
2308 }
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 ok(value,...)
Definition: CComObject.cpp:34
int ret
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
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:141

Referenced by START_TEST().

◆ test__strnset_s()

static void test__strnset_s ( void  )
static

Definition at line 3154 of file string.c.

3155 {
3156  char buf[5] = {0};
3157  int r;
3158 
3159  if(!p__strnset_s) {
3160  win_skip("_strnset_s not available\n");
3161  return;
3162  }
3163 
3164  r = p__strnset_s(NULL, 0, 'a', 0);
3165  ok(r == 0, "r = %d\n", r);
3166 
3167  buf[0] = buf[1] = buf[2] = 'b';
3168  r = p__strnset_s(buf, sizeof(buf), 'a', 2);
3169  ok(r == 0, "r = %d\n", r);
3170  ok(!strcmp(buf, "aab"), "buf = %s\n", buf);
3171 
3172  r = p__strnset_s(buf, 0, 'a', 0);
3173  ok(r == EINVAL, "r = %d\n", r);
3174 
3175  r = p__strnset_s(NULL, 0, 'a', 1);
3176  ok(r == EINVAL, "r = %d\n", r);
3177 
3178  buf[3] = 'b';
3179  r = p__strnset_s(buf, sizeof(buf)-1, 'c', 2);
3180  ok(r == EINVAL, "r = %d\n", r);
3181  ok(!buf[0] && buf[1]=='c' && buf[2]=='b', "buf = %s\n", buf);
3182 }
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: CComObject.cpp:34
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
#define win_skip
Definition: test.h:141

Referenced by START_TEST().

◆ test__strtod()

static void test__strtod ( void  )
static

Definition at line 1787 of file string.c.

1788 {
1789  const char double1[] = "12.1";
1790  const char double2[] = "-13.721";
1791  const char double3[] = "INF";
1792  const char double4[] = ".21e12";
1793  const char double5[] = "214353e-3";
1794  const char double6[] = "NAN";
1795  const char overflow[] = "1d9999999999999999999";
1796  const char white_chars[] = " d10";
1797 
1798  char *end;
1799  double d;
1800 
1801  d = strtod(double1, &end);
1802  ok(almost_equal(d, 12.1), "d = %lf\n", d);
1803  ok(end == double1+4, "incorrect end (%d)\n", (int)(end-double1));
1804 
1805  d = strtod(double2, &end);
1806  ok(almost_equal(d, -13.721), "d = %lf\n", d);
1807  ok(end == double2+7, "incorrect end (%d)\n", (int)(end-double2));
1808 
1809  d = strtod(double3, &end);
1810  ok(almost_equal(d, 0), "d = %lf\n", d);
1811  ok(end == double3, "incorrect end (%d)\n", (int)(end-double3));
1812 
1813  d = strtod(double4, &end);
1814  ok(almost_equal(d, 210000000000.0), "d = %lf\n", d);
1815  ok(end == double4+6, "incorrect end (%d)\n", (int)(end-double4));
1816 
1817  d = strtod(double5, &end);
1818  ok(almost_equal(d, 214.353), "d = %lf\n", d);
1819  ok(end == double5+9, "incorrect end (%d)\n", (int)(end-double5));
1820 
1821  d = strtod(double6, &end);
1822  ok(almost_equal(d, 0), "d = %lf\n", d);
1823  ok(end == double6, "incorrect end (%d)\n", (int)(end-double6));
1824 
1825  d = strtod("12.1d2", NULL);
1826  ok(almost_equal(d, 12.1e2), "d = %lf\n", d);
1827 
1828  d = strtod(white_chars, &end);
1829  ok(almost_equal(d, 0), "d = %lf\n", d);
1830  ok(end == white_chars, "incorrect end (%d)\n", (int)(end-white_chars));
1831 
1832  if (!p__strtod_l)
1833  win_skip("_strtod_l not found\n");
1834  else
1835  {
1836  errno = EBADF;
1837  d = strtod(NULL, NULL);
1838  ok(almost_equal(d, 0.0), "d = %lf\n", d);
1839  ok(errno == EINVAL, "errno = %x\n", errno);
1840 
1841  errno = EBADF;
1842  end = (char *)0xdeadbeef;
1843  d = strtod(NULL, &end);
1844  ok(almost_equal(d, 0.0), "d = %lf\n", d);
1845  ok(errno == EINVAL, "errno = %x\n", errno);
1846  ok(!end, "incorrect end ptr %p\n", end);
1847 
1848  errno = EBADF;
1849  d = p__strtod_l(NULL, NULL, NULL);
1850  ok(almost_equal(d, 0.0), "d = %lf\n", d);
1851  ok(errno == EINVAL, "errno = %x\n", errno);
1852  }
1853 
1854  /* Set locale with non '.' decimal point (',') */
1855  if(!setlocale(LC_ALL, "Polish")) {
1856  win_skip("system with limited locales\n");
1857  return;
1858  }
1859 
1860  d = strtod("12.1", NULL);
1861  ok(almost_equal(d, 12.0), "d = %lf\n", d);
1862 
1863  d = strtod("12,1", NULL);
1864  ok(almost_equal(d, 12.1), "d = %lf\n", d);
1865 
1866  setlocale(LC_ALL, "C");
1867 
1868  /* Precision tests */
1869  d = strtod("0.1", NULL);
1870  ok(almost_equal(d, 0.1), "d = %lf\n", d);
1871  d = strtod("-0.1", NULL);
1872  ok(almost_equal(d, -0.1), "d = %lf\n", d);
1873  d = strtod("0.1281832188491894198128921", NULL);
1874  ok(almost_equal(d, 0.1281832188491894198128921), "d = %lf\n", d);
1875  d = strtod("0.82181281288121", NULL);
1876  ok(almost_equal(d, 0.82181281288121), "d = %lf\n", d);
1877  d = strtod("21921922352523587651128218821", NULL);
1878  ok(almost_equal(d, 21921922352523587651128218821.0), "d = %lf\n", d);
1879  d = strtod("0.1d238", NULL);
1880  ok(almost_equal(d, 0.1e238L), "d = %lf\n", d);
1881  d = strtod("0.1D-4736", NULL);
1882  ok(almost_equal(d, 0.1e-4736L), "d = %lf\n", d);
1883 
1884  errno = 0xdeadbeef;
1885  strtod(overflow, &end);
1886  ok(errno == ERANGE, "errno = %x\n", errno);
1887  ok(end == overflow+21, "incorrect end (%d)\n", (int)(end-overflow));
1888 
1889  errno = 0xdeadbeef;
1890  strtod("-1d309", NULL);
1891  ok(errno == ERANGE, "errno = %x\n", errno);
1892 }
_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 ok(value,...)
Definition: CComObject.cpp:34
#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:1087
static BOOL almost_equal(double d1, double d2)
Definition: string.c:1781
#define setlocale(n, s)
Definition: locale.h:46
#define win_skip
Definition: test.h:141

Referenced by START_TEST().

◆ test__strtoi64()

static void test__strtoi64 ( void  )
static

Definition at line 1636 of file string.c.

1637 {
1638  static const char no1[] = "31923";
1639  static const char no2[] = "-213312";
1640  static const char no3[] = "12aa";
1641  static const char no4[] = "abc12";
1642  static const char overflow[] = "99999999999999999999";
1643  static const char neg_overflow[] = "-99999999999999999999";
1644  static const char hex[] = "0x123";
1645  static const char oct[] = "000123";
1646  static const char blanks[] = " 12 212.31";
1647 
1648  __int64 res;
1649  unsigned __int64 ures;
1650  char *endpos;
1651 
1652  if(!p_strtoi64 || !p_strtoui64) {
1653  win_skip("_strtoi64 or _strtoui64 not found\n");
1654  return;
1655  }
1656 
1657  errno = 0xdeadbeef;
1658  res = p_strtoi64(no1, NULL, 10);
1659  ok(res == 31923, "res != 31923\n");
1660  res = p_strtoi64(no2, NULL, 10);
1661  ok(res == -213312, "res != -213312\n");
1662  res = p_strtoi64(no3, NULL, 10);
1663  ok(res == 12, "res != 12\n");
1664  res = p_strtoi64(no4, &endpos, 10);
1665  ok(res == 0, "res != 0\n");
1666  ok(endpos == no4, "Scanning was not stopped on first character\n");
1667  res = p_strtoi64(hex, &endpos, 10);
1668  ok(res == 0, "res != 0\n");
1669  ok(endpos == hex+1, "Incorrect endpos (%p-%p)\n", hex, endpos);
1670  res = p_strtoi64(oct, &endpos, 10);
1671  ok(res == 123, "res != 123\n");
1672  ok(endpos == oct+strlen(oct), "Incorrect endpos (%p-%p)\n", oct, endpos);
1673  res = p_strtoi64(blanks, &endpos, 10);
1674  ok(res == 12, "res != 12\n");
1675  ok(endpos == blanks+10, "Incorrect endpos (%p-%p)\n", blanks, endpos);
1676  ok(errno == 0xdeadbeef, "errno = %x\n", errno);
1677 
1678  errno = 0xdeadbeef;
1679  res = p_strtoi64(overflow, &endpos, 10);
1680  ok(res == _I64_MAX, "res != _I64_MAX\n");
1681  ok(endpos == overflow+strlen(overflow), "Incorrect endpos (%p-%p)\n", overflow, endpos);
1682  ok(errno == ERANGE, "errno = %x\n", errno);
1683 
1684  errno = 0xdeadbeef;
1685  res = p_strtoi64(neg_overflow, &endpos, 10);
1686  ok(res == _I64_MIN, "res != _I64_MIN\n");
1687  ok(endpos == neg_overflow+strlen(neg_overflow), "Incorrect endpos (%p-%p)\n", neg_overflow, endpos);
1688  ok(errno == ERANGE, "errno = %x\n", errno);
1689 
1690  errno = 0xdeadbeef;
1691  res = p_strtoi64(no1, &endpos, 16);
1692  ok(res == 203043, "res != 203043\n");
1693  ok(endpos == no1+strlen(no1), "Incorrect endpos (%p-%p)\n", no1, endpos);
1694  res = p_strtoi64(no2, &endpos, 16);
1695  ok(res == -2175762, "res != -2175762\n");
1696  ok(endpos == no2+strlen(no2), "Incorrect endpos (%p-%p)\n", no2, endpos);
1697  res = p_strtoi64(no3, &endpos, 16);
1698  ok(res == 4778, "res != 4778\n");
1699  ok(endpos == no3+strlen(no3), "Incorrect endpos (%p-%p)\n", no3, endpos);
1700  res = p_strtoi64(no4, &endpos, 16);
1701  ok(res == 703506, "res != 703506\n");
1702  ok(endpos == no4+strlen(no4), "Incorrect endpos (%p-%p)\n", no4, endpos);
1703  res = p_strtoi64(hex, &endpos, 16);
1704  ok(res == 291, "res != 291\n");
1705  ok(endpos == hex+strlen(hex), "Incorrect endpos (%p-%p)\n", hex, endpos);
1706  res = p_strtoi64(oct, &endpos, 16);
1707  ok(res == 291, "res != 291\n");
1708  ok(endpos == oct+strlen(oct), "Incorrect endpos (%p-%p)\n", oct, endpos);
1709  res = p_strtoi64(blanks, &endpos, 16);
1710  ok(res == 18, "res != 18\n");
1711  ok(endpos == blanks+10, "Incorrect endpos (%p-%p)\n", blanks, endpos);
1712  ok(errno == 0xdeadbeef, "errno = %x\n", errno);
1713 
1714  errno = 0xdeadbeef;
1715  res = p_strtoi64(hex, &endpos, 36);
1716  ok(res == 1541019, "res != 1541019\n");
1717  ok(endpos == hex+strlen(hex), "Incorrect endpos (%p-%p)\n", hex, endpos);
1718  ok(errno == 0xdeadbeef, "errno = %x\n", errno);
1719 
1720  errno = 0xdeadbeef;
1721  res = p_strtoi64(no1, &endpos, 0);
1722  ok(res == 31923, "res != 31923\n");
1723  ok(endpos == no1+strlen(no1), "Incorrect endpos (%p-%p)\n", no1, endpos);
1724  res = p_strtoi64(no2, &endpos, 0);
1725  ok(res == -213312, "res != -213312\n");
1726  ok(endpos == no2+strlen(no2), "Incorrect endpos (%p-%p)\n", no2, endpos);
1727  res = p_strtoi64(no3, &endpos, 10);
1728  ok(res == 12, "res != 12\n");
1729  ok(endpos == no3+2, "Incorrect endpos (%p-%p)\n", no3, endpos);
1730  res = p_strtoi64(no4, &endpos, 10);
1731  ok(res == 0, "res != 0\n");
1732  ok(endpos == no4, "Incorrect endpos (%p-%p)\n", no4, endpos);
1733  res = p_strtoi64(hex, &endpos, 10);
1734  ok(res == 0, "res != 0\n");
1735  ok(endpos == hex+1, "Incorrect endpos (%p-%p)\n", hex, endpos);
1736  res = p_strtoi64(oct, &endpos, 10);
1737  ok(res == 123, "res != 123\n");
1738  ok(endpos == oct+strlen(oct), "Incorrect endpos (%p-%p)\n", oct, endpos);
1739  res = p_strtoi64(blanks, &endpos, 10);
1740  ok(res == 12, "res != 12\n");
1741  ok(endpos == blanks+10, "Incorrect endpos (%p-%p)\n", blanks, endpos);
1742  ok(errno == 0xdeadbeef, "errno = %x\n", errno);
1743 
1744  errno = 0xdeadbeef;
1745  ures = p_strtoui64(no1, &endpos, 0);
1746  ok(ures == 31923, "ures != 31923\n");
1747  ok(endpos == no1+strlen(no1), "Incorrect endpos (%p-%p)\n", no1, endpos);
1748  ures = p_strtoui64(no2, &endpos, 0);
1749  ok(ures == -213312, "ures != -213312\n");
1750  ok(endpos == no2+strlen(no2), "Incorrect endpos (%p-%p)\n", no2, endpos);
1751  ures = p_strtoui64(no3, &endpos, 10);
1752  ok(ures == 12, "ures != 12\n");
1753  ok(endpos == no3+2, "Incorrect endpos (%p-%p)\n", no3, endpos);
1754  ures = p_strtoui64(no4, &endpos, 10);
1755  ok(ures == 0, "ures != 0\n");
1756  ok(endpos == no4, "Incorrect endpos (%p-%p)\n", no4, endpos);
1757  ures = p_strtoui64(hex, &endpos, 10);
1758  ok(ures == 0, "ures != 0\n");
1759  ok(endpos == hex+1, "Incorrect endpos (%p-%p)\n", hex, endpos);
1760  ures = p_strtoui64(oct, &endpos, 10);
1761  ok(ures == 123, "ures != 123\n");
1762  ok(endpos == oct+strlen(oct), "Incorrect endpos (%p-%p)\n", oct, endpos);
1763  ures = p_strtoui64(blanks, &endpos, 10);
1764  ok(ures == 12, "ures != 12\n");
1765  ok(endpos == blanks+10, "Incorrect endpos (%p-%p)\n", blanks, endpos);
1766  ok(errno == 0xdeadbeef, "errno = %x\n", errno);
1767 
1768  errno = 0xdeadbeef;
1769  ures = p_strtoui64(overflow, &endpos, 10);
1770  ok(ures == _UI64_MAX, "ures != _UI64_MAX\n");
1771  ok(endpos == overflow+strlen(overflow), "Incorrect endpos (%p-%p)\n", overflow, endpos);
1772  ok(errno == ERANGE, "errno = %x\n", errno);
1773 
1774  errno = 0xdeadbeef;
1775  ures = p_strtoui64(neg_overflow, &endpos, 10);
1776  ok(ures == 1, "ures != 1\n");
1777  ok(endpos == neg_overflow+strlen(neg_overflow), "Incorrect endpos (%p-%p)\n", neg_overflow, endpos);
1778  ok(errno == ERANGE, "errno = %x\n", errno);
1779 }
#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 ok(value,...)
Definition: CComObject.cpp:34
#define ERANGE
Definition: acclib.h:92
#define _I64_MIN
Definition: limits.h:61
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:141

Referenced by START_TEST().

◆ test__ultoa_s()

static void test__ultoa_s ( void  )
static

Definition at line 2607 of file string.c.

2608 {
2609  errno_t ret;
2610  char buffer[33];
2611 
2612  if (!p_ultoa_s)
2613  {
2614  win_skip("Skipping _ultoa_s tests\n");
2615  return;
2616  }
2617 
2618  errno = EBADF;
2619  ret = p_ultoa_s(0, NULL, 0, 0);
2620  ok(ret == EINVAL, "Expected _ultoa_s to return EINVAL, got %d\n", ret);
2621  ok(errno == EINVAL, "Expected errno to be EINVAL, got %d\n", errno);
2622 
2623  memset(buffer, 'X', sizeof(buffer));
2624  errno = EBADF;
2625  ret = p_ultoa_s(0, buffer, 0, 0);
2626  ok(ret == EINVAL, "Expected _ultoa_s to return EINVAL, got %d\n", ret);
2627  ok(errno == EINVAL, "Expected errno to be EINVAL, got %d\n", errno);
2628  ok(buffer[0] == 'X', "Expected the output buffer to be untouched\n");
2629 
2630  memset(buffer, 'X', sizeof(buffer));
2631  errno = EBADF;
2632  ret = p_ultoa_s(0, buffer, sizeof(buffer), 0);
2633  ok(ret == EINVAL, "Expected _ultoa_s to return EINVAL, got %d\n", ret);
2634  ok(errno == EINVAL, "Expected errno to be EINVAL, got %d\n", errno);
2635  ok(buffer[0] == '\0', "Expected the output buffer to be null terminated\n");
2636 
2637  memset(buffer, 'X', sizeof(buffer));
2638  errno = EBADF;
2639  ret = p_ultoa_s(0, buffer, sizeof(buffer), 64);
2640  ok(ret == EINVAL, "Expected _ultoa_s to return EINVAL, got %d\n", ret);
2641  ok(errno == EINVAL, "Expected errno to be EINVAL, got %d\n", errno);
2642  ok(buffer[0] == '\0', "Expected the output buffer to be null terminated\n");
2643 
2644  memset(buffer, 'X', sizeof(buffer));
2645  errno = EBADF;
2646  ret = p_ultoa_s(12345678, buffer, 4, 10);
2647  ok(ret == ERANGE, "Expected _ultoa_s to return ERANGE, got %d\n", ret);
2648  ok(errno == ERANGE, "Expected errno to be ERANGE, got %d\n", errno);
2649  ok(!memcmp(buffer, "\000765", 4),
2650  "Expected the output buffer to be null terminated with truncated output\n");
2651 
2652  memset(buffer, 'X', sizeof(buffer));
2653  errno = EBADF;
2654  ret = p_ultoa_s(12345678, buffer, 8, 10);
2655  ok(ret == ERANGE, "Expected _ultoa_s to return ERANGE, got %d\n", ret);
2656  ok(errno == ERANGE, "Expected errno to be ERANGE, got %d\n", errno);
2657  ok(!memcmp(buffer, "\0007654321", 8),
2658  "Expected the output buffer to be null terminated with truncated output\n");
2659 
2660  ret = p_ultoa_s(12345678, buffer, 9, 10);
2661  ok(ret == 0, "Expected _ultoa_s to return 0, got %d\n", ret);
2662  ok(!strcmp(buffer, "12345678"),
2663  "Expected output buffer string to be \"12345678\", got \"%s\"\n",
2664  buffer);
2665 
2666  ret = p_ultoa_s(43690, buffer, sizeof(buffer), 2);
2667  ok(ret == 0, "Expected _ultoa_s to return 0, got %d\n", ret);
2668  ok(!strcmp(buffer, "1010101010101010"),
2669  "Expected output buffer string to be \"1010101010101010\", got \"%s\"\n",
2670  buffer);
2671 
2672  ret = p_ultoa_s(1092009, buffer, sizeof(buffer), 36);
2673  ok(ret == 0, "Expected _ultoa_s to return 0, got %d\n", ret);
2674  ok(!strcmp(buffer, "nell"),
2675  "Expected output buffer string to be \"nell\", got \"%s\"\n",
2676  buffer);
2677 
2678  ret = p_ultoa_s(5704, buffer, sizeof(buffer), 18);
2679  ok(ret == 0, "Expected _ultoa_s to return 0, got %d\n", ret);
2680  ok(!strcmp(buffer, "hag"),
2681  "Expected output buffer string to be \"hag\", got \"%s\"\n",
2682  buffer);
2683 }
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 ok(value,...)
Definition: CComObject.cpp:34
#define ERANGE
Definition: acclib.h:92
int ret
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:141

Referenced by START_TEST().

◆ test__wcslwr_s()

static void test__wcslwr_s ( void  )
static

Definition at line 1150 of file string.c.

1151 {
1152  static const WCHAR mixedString[] = {'M', 'i', 'X', 'e', 'D', 'l', 'o', 'w',
1153  'e', 'r', 'U', 'P', 'P', 'E', 'R', 0};
1154  static const WCHAR expectedString[] = {'m', 'i', 'x', 'e', 'd', 'l', 'o',
1155  'w', 'e', 'r', 'u', 'p', 'p', 'e',
1156  'r', 0};
1157  WCHAR buffer[2*sizeof(mixedString)/sizeof(WCHAR)];
1158  int ret;
1159 
1160  if (!p_wcslwr_s)
1161  {
1162  win_skip("_wcslwr_s not found\n");
1163  return;
1164  }
1165 
1166  /* Test NULL input string and invalid size. */
1167  errno = EBADF;
1168  ret = p_wcslwr_s(NULL, 0);
1169  ok(ret == EINVAL, "expected EINVAL, got %d\n", ret);
1170  ok(errno == EINVAL, "expected errno EINVAL, got %d\n", errno);
1171 
1172  /* Test NULL input string and valid size. */
1173  errno = EBADF;
1174  ret = p_wcslwr_s(NULL, sizeof(buffer)/sizeof(buffer[0]));
1175  ok(ret == EINVAL, "expected EINVAL, got %d\n", ret);
1176  ok(errno == EINVAL, "expected errno EINVAL, got %d\n", errno);
1177 
1178  /* Test empty string with zero size. */
1179  errno = EBADF;
1180  buffer[0] = 'a';
1181  ret = p_wcslwr_s(buffer, 0);
1182  ok(ret == EINVAL, "expected EINVAL, got %d\n", ret);
1183  ok(errno == EINVAL, "expected errno EINVAL, got %d\n", errno);
1184  ok(buffer[0] == 0, "expected empty string\n");
1185 
1186  /* Test empty string with size of one. */
1187  buffer[0] = 0;
1188  ret = p_wcslwr_s(buffer, 1);
1189  ok(ret == 0, "got %d\n", ret);
1190  ok(buffer[0] == 0, "expected buffer to be unchanged\n");
1191 
1192  /* Test one-byte buffer with zero size. */
1193  errno = EBADF;
1194  buffer[0] = 'x';
1195  ret = p_wcslwr_s(buffer, 0);
1196  ok(ret == EINVAL, "expected EINVAL, got %d\n", ret);
1197  ok(errno == EINVAL, "expected errno to be EINVAL, got %d\n", errno);
1198  ok(buffer[0] == '\0', "expected empty string\n");
1199 
1200  /* Test one-byte buffer with size of one. */
1201  errno = EBADF;
1202  buffer[0] = 'x';
1203  ret = p_wcslwr_s(buffer, 1);
1204  ok(ret == EINVAL, "expected EINVAL, got %d\n", ret);
1205  ok(errno == EINVAL, "expected errno to be EINVAL, got %d\n", errno);
1206  ok(buffer[0] == '\0', "expected empty string\n");
1207 
1208  /* Test invalid size. */
1209  wcscpy(buffer, mixedString);
1210  errno = EBADF;
1211  ret = p_wcslwr_s(buffer, 0);
1212  ok(ret == EINVAL, "Expected EINVAL, got %d\n", ret);
1213  ok(errno == EINVAL, "expected errno to be EINVAL, got %d\n", errno);
1214  ok(buffer[0] == '\0', "expected empty string\n");
1215 
1216  /* Test normal string uppercasing. */
1217  wcscpy(buffer, mixedString);
1218  ret = p_wcslwr_s(buffer, sizeof(mixedString)/sizeof(WCHAR));
1219  ok(ret == 0, "expected 0, got %d\n", ret);
1220  ok(!wcscmp(buffer, expectedString), "expected lowercase\n");
1221 
1222  /* Test uppercasing with a shorter buffer size count. */
1223  wcscpy(buffer, mixedString);
1224  errno = EBADF;
1225  ret = p_wcslwr_s(buffer, sizeof(mixedString)/sizeof(WCHAR) - 1);
1226  ok(ret == EINVAL, "expected EINVAL, got %d\n", ret);
1227  ok(errno == EINVAL, "expected errno to be EINVAL, got %d\n", errno);
1228  ok(buffer[0] == '\0', "expected empty string\n");
1229 
1230  /* Test uppercasing with a longer buffer size count. */
1231  wcscpy(buffer, mixedString);
1232  ret = p_wcslwr_s(buffer, sizeof(buffer)/sizeof(WCHAR));
1233  ok(ret == 0, "expected 0, got %d\n", ret);
1234  ok(!wcscmp(buffer, expectedString), "expected lowercase\n");
1235 }
__wchar_t WCHAR
Definition: xmlstorage.h:180
Definition: arc.h:39
GLuint buffer
Definition: glext.h:5915
int errno
Definition: arc.h:36
smooth NULL
Definition: ftsmooth.c:416
#define ok(value,...)
Definition: CComObject.cpp:34
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 win_skip
Definition: test.h:141

Referenced by START_TEST().

◆ test__wcsset_s()

static void test__wcsset_s ( void  )
static

Definition at line 3184 of file string.c.

3185 {
3186  wchar_t str[10];
3187  int r;
3188 
3189  if(!p__wcsset_s) {
3190  win_skip("_wcsset_s not available\n");
3191  return;
3192  }
3193 
3194  r = p__wcsset_s(NULL, 0, 'a');
3195  ok(r == EINVAL, "r = %d\n", r);
3196 
3197  str[0] = 'a';
3198  r = p__wcsset_s(str, 0, 'a');
3199  ok(r == EINVAL, "r = %d\n", r);
3200  ok(str[0] == 'a', "str[0] = %d\n", str[0]);
3201 
3202  str[0] = 'a';
3203  str[1] = 'b';
3204  r = p__wcsset_s(str, 2, 'c');
3205  ok(r == EINVAL, "r = %d\n", r);
3206  ok(!str[0], "str[0] = %d\n", str[0]);
3207  ok(str[1] == 'b', "str[1] = %d\n", str[1]);
3208 
3209  str[0] = 'a';
3210  str[1] = 0;
3211  str[2] = 'b';
3212  r = p__wcsset_s(str, 3, 'c');
3213  ok(str[0] == 'c', "str[0] = %d\n", str[0]);
3214  ok(str[1] == 0, "str[1] = %d\n", str[1]);
3215  ok(str[2] == 'b', "str[2] = %d\n", str[2]);
3216 }
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: CComObject.cpp:34
#define win_skip
Definition: test.h:141

Referenced by START_TEST().

◆ test__wcstoi64()

static void test__wcstoi64 ( void  )
static

Definition at line 2923 of file string.c.

2924 {
2925  static const WCHAR digit[] = { '9', 0 };
2926  static const WCHAR space[] = { ' ', 0 };
2927  static const WCHAR stock[] = { 0x3231, 0 }; /* PARENTHESIZED IDEOGRAPH STOCK */
2928  static const WCHAR cjk_1[] = { 0x4e00, 0 }; /* CJK Ideograph, First */
2929  static const WCHAR tamil[] = { 0x0bef, 0 }; /* TAMIL DIGIT NINE */
2930  static const WCHAR thai[] = { 0x0e59, 0 }; /* THAI DIGIT NINE */
2931  static const WCHAR fullwidth[] = { 0xff19, 0 }; /* FULLWIDTH DIGIT NINE */
2932  static const WCHAR superscript1[] = { 0xb9, 0 }; /* SUPERSCRIPT ONE */
2933  static const WCHAR minus_0x91[] = { '-', 0x0e50, 'x', 0xff19, '1', 0 };
2934  static const WCHAR plus_071[] = { '+', 0x0e50, 0xff17, '1', 0 };
2935  static const WCHAR hex[] = { 0xff19, 'f', 0x0e59, 0xff46, 0 };
2936  static const WCHAR zeros[] = {
2937  0x660, 0x6f0, 0x966, 0x9e6, 0xa66, 0xae6, 0xb66, 0xc66, 0xce6,
2938  0xd66, 0xe50, 0xed0, 0xf20, 0x1040, 0x17e0, 0x1810, 0xff10
2939  };
2940  int i;
2941 
2942  __int64 res;
2943  unsigned __int64 ures;
2944  WCHAR *endpos;
2945 
2946  if (!p_wcstoi64 || !p_wcstoui64) {
2947  win_skip("_wcstoi64 or _wcstoui64 not found\n");
2948  return;
2949  }
2950 
2951  res = p_wcstoi64(digit, NULL, 10);
2952  ok(res == 9, "res != 9\n");
2953  res = p_wcstoi64(space, &endpos, 0);
2954  ok(endpos == space, "endpos != space\n");
2955  res = p_wcstoi64(stock, &endpos, 10);
2956  ok(res == 0, "res != 0\n");
2957  ok(endpos == stock, "Incorrect endpos (%p-%p)\n", stock, endpos);
2958  res = p_wcstoi64(cjk_1, NULL, 0);
2959  ok(res == 0, "res != 0\n");
2960  res = p_wcstoi64(tamil, &endpos, 10);
2961  ok(res == 0, "res != 0\n");
2962  ok(endpos == tamil, "Incorrect endpos (%p-%p)\n", tamil, endpos);
2963  res = p_wcstoi64(thai, NULL, 10);
2964  ok(res == 9, "res != 9\n");
2965  res = p_wcstoi64(fullwidth, NULL, 10);
2966  ok(res == 9, "res != 9\n");
2967  res = p_wcstoi64(superscript1, NULL, 10);
2968  ok(res == 0, "res != 0\n");
2969  res = p_wcstoi64(hex, NULL, 16);
2970  ok(res == 0x9f9, "res != 0x9f9\n");
2971  res = p_wcstoi64(minus_0x91, NULL, 0);
2972  ok(res == -0x91, "res != -0x91\n");
2973  res = p_wcstoi64(plus_071, NULL, 0);
2974  ok(res == 071, "res != 071\n");
2975 
2976  ures = p_wcstoui64(digit, NULL, 10);
2977  ok(ures == 9, "ures != 9\n");
2978  ures = p_wcstoui64(space, &endpos, 0);
2979  ok(endpos == space, "endpos != space\n");
2980  ures = p_wcstoui64(stock, &endpos, 10);
2981  ok(ures == 0, "ures != 0\n");
2982  ok(endpos == stock, "Incorrect endpos (%p-%p)\n", stock, endpos);
2983  ures = p_wcstoui64(tamil, &endpos, 10);
2984  ok(ures == 0, "ures != 0\n");
2985  ok(endpos == tamil, "Incorrect endpos (%p-%p)\n", tamil, endpos);
2986  ures = p_wcstoui64(thai, NULL, 10);
2987  ok(ures == 9, "ures != 9\n");
2988  ures = p_wcstoui64(fullwidth, NULL, 10);
2989  ok(ures == 9, "ures != 9\n");
2990  ures = p_wcstoui64(superscript1, NULL, 10);
2991  ok(ures == 0, "ures != 0\n");
2992  ures = p_wcstoui64(hex, NULL, 16);
2993  ok(ures == 0x9f9, "ures != 0x9f9\n");
2994  ures = p_wcstoui64(plus_071, NULL, 0);
2995  ok(ures == 071, "ures != 071\n");
2996 
2997  /* Test various unicode digits */
2998  for (i = 0; i < sizeof(zeros) / sizeof(zeros[0]); ++i) {
2999  WCHAR tmp[] = {zeros[i] + 4, zeros[i], zeros[i] + 5, 0};
3000  res = p_wcstoi64(tmp, NULL, 0);
3001  ok(res == 405, "with zero = U+%04X: got %d, expected 405\n", zeros[i], (int)res);
3002  tmp[1] = zeros[i] + 10;
3003  res = p_wcstoi64(tmp, NULL, 16);
3004  ok(res == 4, "with zero = U+%04X: got %d, expected 4\n", zeros[i], (int)res);
3005  }
3006 
3007  return;
3008 }
__wchar_t WCHAR
Definition: xmlstorage.h:180
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
#define ok(value,...)
Definition: CComObject.cpp:34
GLuint res
Definition: glext.h:9613
#define win_skip
Definition: test.h:141

Referenced by START_TEST().

◆ test__wcsupr_s()

static void test__wcsupr_s ( void  )
static

Definition at line 1063 of file string.c.

1064 {
1065  static const WCHAR mixedString[] = {'M', 'i', 'X', 'e', 'D', 'l', 'o', 'w',
1066  'e', 'r', 'U', 'P', 'P', 'E', 'R', 0};
1067  static const WCHAR expectedString[] = {'M', 'I', 'X', 'E', 'D', 'L', 'O',
1068  'W', 'E', 'R', 'U', 'P', 'P', 'E',
1069  'R', 0};
1070  WCHAR testBuffer[2*sizeof(mixedString)/sizeof(WCHAR)];
1071  int ret;
1072 
1073  if (!p_wcsupr_s)
1074  {
1075  win_skip("_wcsupr_s not found\n");
1076  return;
1077  }
1078 
1079  /* Test NULL input string and invalid size. */
1080  errno = EBADF;
1081  ret = p_wcsupr_s(NULL, 0);
1082  ok(ret == EINVAL, "Expected _wcsupr_s to fail with EINVAL, got %d\n", ret);
1083  ok(errno == EINVAL, "Expected errno to be EINVAL, got %d\n", errno);
1084 
1085  /* Test NULL input string and valid size. */
1086  errno = EBADF;
1087  ret = p_wcsupr_s(NULL, sizeof(testBuffer)/sizeof(WCHAR));
1088  ok(ret == EINVAL, "Expected _wcsupr_s to fail with EINVAL, got %d\n", ret);
1089  ok(errno == EINVAL, "Expected errno to be EINVAL, got %d\n", errno);
1090 
1091  /* Test empty string with zero size. */
1092  errno = EBADF;
1093  testBuffer[0] = '\0';
1094  ret = p_wcsupr_s(testBuffer, 0);
1095  ok(ret == EINVAL, "Expected _wcsupr_s to fail with EINVAL, got %d\n", ret);
1096  ok(errno == EINVAL, "Expected errno to be EINVAL, got %d\n", errno);
1097  ok(testBuffer[0] == '\0', "Expected the buffer to be unchanged\n");
1098 
1099  /* Test empty string with size of one. */
1100  testBuffer[0] = '\0';
1101  ret = p_wcsupr_s(testBuffer, 1);
1102  ok(ret == 0, "Expected _wcsupr_s to succeed, got %d\n", ret);
1103  ok(testBuffer[0] == '\0', "Expected the buffer to be unchanged\n");
1104 
1105  /* Test one-byte buffer with zero size. */
1106  errno = EBADF;
1107  testBuffer[0] = 'x';
1108  ret = p_wcsupr_s(testBuffer, 0);
1109  ok(ret == EINVAL, "Expected _wcsupr_s to fail with EINVAL, got %d\n", ret);
1110  ok(errno == EINVAL, "Expected errno to be EINVAL, got %d\n", errno);
1111  ok(testBuffer[0] == '\0', "Expected the first buffer character to be null\n");
1112 
1113  /* Test one-byte buffer with size of one. */
1114  errno = EBADF;
1115  testBuffer[0] = 'x';
1116  ret = p_wcsupr_s(testBuffer, 1);
1117  ok(ret == EINVAL, "Expected _wcsupr_s to fail with EINVAL, got %d\n", ret);
1118  ok(errno == EINVAL, "Expected errno to be EINVAL, got %d\n", errno);
1119  ok(testBuffer[0] == '\0', "Expected the first buffer character to be null\n");
1120 
1121  /* Test invalid size. */
1122  wcscpy(testBuffer, mixedString);
1123  errno = EBADF;
1124  ret = p_wcsupr_s(testBuffer, 0);
1125  ok(ret == EINVAL, "Expected _wcsupr_s to fail with EINVAL, got %d\n", ret);
1126  ok(errno == EINVAL, "Expected errno to be EINVAL, got %d\n", errno);
1127  ok(testBuffer[0] == '\0', "Expected the first buffer character to be null\n");
1128 
1129  /* Test normal string uppercasing. */
1130  wcscpy(testBuffer, mixedString);
1131  ret = p_wcsupr_s(testBuffer, sizeof(mixedString)/sizeof(WCHAR));
1132  ok(ret == 0, "Expected _wcsupr_s to succeed, got %d\n", ret);
1133  ok(!wcscmp(testBuffer, expectedString), "Expected the string to be fully upper-case\n");
1134 
1135  /* Test uppercasing with a shorter buffer size count. */
1136  wcscpy(testBuffer, mixedString);
1137  errno = EBADF;
1138  ret = p_wcsupr_s(testBuffer, sizeof(mixedString)/sizeof(WCHAR) - 1);
1139  ok(ret == EINVAL, "Expected _wcsupr_s to fail with EINVAL, got %d\n", ret);
1140  ok(errno == EINVAL, "Expected errno to be EINVAL, got %d\n", errno);
1141  ok(testBuffer[0] == '\0', "Expected the first buffer character to be null\n");
1142 
1143  /* Test uppercasing with a longer buffer size count. */
1144  wcscpy(testBuffer, mixedString);
1145  ret = p_wcsupr_s(testBuffer, sizeof(testBuffer)/sizeof(WCHAR));
1146  ok(ret == 0, "Expected _wcsupr_s to succeed, got %d\n", ret);
1147  ok(!wcscmp(testBuffer, expectedString), "Expected the string to be fully upper-case\n");
1148 }
__wchar_t WCHAR
Definition: xmlstorage.h:180
Definition: arc.h:39
int errno
Definition: arc.h:36
smooth NULL
Definition: ftsmooth.c:416
#define ok(value,...)
Definition: CComObject.cpp:34
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 win_skip
Definition: test.h:141

Referenced by START_TEST().

◆ test_atof()

static void test_atof ( void  )
static

Definition at line 3027 of file string.c.

3028 {
3029  double d;
3030 
3031  d = atof("0.0");
3032  ok(almost_equal(d, 0.0), "d = %lf\n", d);
3033 
3034  d = atof("1.0");
3035  ok(almost_equal(d, 1.0), "d = %lf\n", d);
3036 
3037  d = atof("-1.0");
3038  ok(almost_equal(d, -1.0), "d = %lf\n", d);
3039 
3040  if (!p__atof_l)
3041  {
3042  win_skip("_atof_l not found\n");
3043  return;
3044  }
3045 
3046  errno = EBADF;
3047  d = atof(NULL);
3048  ok(almost_equal(d, 0.0), "d = %lf\n", d);
3049  ok(errno == EINVAL, "errno = %x\n", errno);
3050 
3051  errno = EBADF;
3052  d = p__atof_l(NULL, NULL);
3053  ok(almost_equal(d, 0.0), "d = %lf\n", d);
3054  ok(errno == EINVAL, "errno = %x\n", errno);
3055 }
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 ok(value,...)
Definition: CComObject.cpp:34
#define d
Definition: ke_i.h:81
static BOOL almost_equal(double d1, double d2)
Definition: string.c:1781
#define win_skip
Definition: test.h:141

Referenced by START_TEST().

◆ test_atoi()

static void test_atoi ( void  )
static

Definition at line 3010 of file string.c.

3011 {
3012  int r;
3013 
3014  r = atoi("0");
3015  ok(r == 0, "atoi(0) = %d\n", r);
3016 
3017  r = atoi("-1");
3018  ok(r == -1, "atoi(-1) = %d\n", r);
3019 
3020  r = atoi("1");
3021  ok(r == 1, "atoi(1) = %d\n", r);
3022 
3023  r = atoi("4294967296");
3024  ok(r == 0, "atoi(4294967296) = %d\n", r);
3025 }
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
#define ok(value,...)
Definition: CComObject.cpp:34
_Check_return_ int __cdecl atoi(_In_z_ const char *_Str)

Referenced by START_TEST().

◆ test_cp_table()

static void test_cp_table ( int  cp,
int result 
)
static

Definition at line 191 of file string.c.

192 {
193  int i;
194  int count = 0;
195  int curr = 0;
196  _setmbcp(cp);
197  for (i = 0; i < 256; i++)
198  {
199  if (count == 0)
200  {
201  curr = result[0];
202  count = result[1];
203  result += 2;
204  }
205  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);
206  count--;
207  }
208 }
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
#define ok(value,...)
Definition: CComObject.cpp:34
int __cdecl _setmbcp(int)
Definition: _setmbcp.c:218
static unsigned char * p_mbctype
Definition: string.c:85
POINT cp
Definition: magnifier.c:60
GLuint64EXT * result
Definition: glext.h:11304

◆ test_gcvt()

static void test_gcvt ( void  )
static

Definition at line 2122 of file string.c.

2123 {
2124  char buf[1024], *res;
2125  errno_t err;
2126 
2127  if(!p_gcvt_s) {
2128  win_skip("Skipping _gcvt tests\n");
2129  return;
2130  }
2131 
2132  errno = 0;
2133  res = _gcvt(1.2, -1, buf);
2134  ok(res == NULL, "res != NULL\n");
2135  ok(errno == ERANGE, "errno = %d\n", errno);
2136 
2137  errno = 0;
2138  res = _gcvt(1.2, 5, NULL);
2139  ok(res == NULL, "res != NULL\n");
2140  ok(errno == EINVAL, "errno = %d\n", errno);
2141 
2142  res = gcvt(1.2, 5, buf);
2143  ok(res == buf, "res != buf\n");
2144  ok(!strcmp(buf, "1.2"), "buf = %s\n", buf);
2145 
2146  buf[0] = 'x';
2147  err = p_gcvt_s(buf, 5, 1.2, 10);
2148  ok(err == ERANGE, "err = %d\n", err);
2149  ok(buf[0] == '\0', "buf[0] = %c\n", buf[0]);
2150 
2151  buf[0] = 'x';
2152  err = p_gcvt_s(buf, 4, 123456, 2);
2153  ok(err == ERANGE, "err = %d\n", err);
2154  ok(buf[0] == '\0', "buf[0] = %c\n", buf[0]);
2155 }
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 ok(value,...)
Definition: CComObject.cpp:34
#define ERANGE
Definition: acclib.h:92
#define err(...)
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:141

Referenced by START_TEST().

◆ test_ismbckata()

static void test_ismbckata ( void  )
static

Definition at line 1398 of file string.c.

1398  {
1399  struct katakana_pair {
1400  UINT c;
1401  BOOL exp;
1402  };
1403  static const struct katakana_pair tests[] = {
1404  {0x8152, FALSE}, {0x8153, FALSE}, {0x8154, FALSE}, {0x8155, FALSE},
1405  {0x82a0, FALSE}, {0x833f, FALSE}, {0x8340, TRUE }, {0x837e, TRUE },
1406  {0x837f, FALSE}, {0x8380, TRUE }, {0x8396, TRUE }, {0x8397, FALSE},
1407  {0xa5, FALSE}, {0xb0, FALSE}, {0xdd, FALSE}
1408  };
1409  unsigned int prev_cp = _getmbcp();
1410  int ret;
1411  unsigned int i;
1412 
1414  for (i = 0; i < sizeof(tests)/sizeof(tests[0]); i++) {
1415  ret = _ismbckata(tests[i].c);
1416  ok(!ret, "expected 0, got %d for %04x\n", ret, tests[i].c);
1417  }
1418 
1419  _setmbcp(932);
1420  for (i = 0; i < sizeof(tests)/sizeof(tests[0]); i++) {
1421  ret = _ismbckata(tests[i].c);
1422  ok(!!ret == tests[i].exp, "expected %d, got %d for %04x\n",
1423  tests[i].exp, !!ret, tests[i].c);
1424  }
1425 
1426  _setmbcp(prev_cp);
1427 }
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
#define ok(value,...)
Definition: CComObject.cpp:34
unsigned int BOOL
Definition: ntddk_ex.h:94
int __cdecl _setmbcp(int)
Definition: _setmbcp.c:218
const GLubyte * c
Definition: glext.h:8905
unsigned int UINT
Definition: ndis.h:50
_Check_return_ _CRTIMP int __cdecl _ismbckata(_In_ unsigned int _Ch)
int ret
#define c
Definition: ke_i.h:80
DWORD exp
Definition: msg.c:15681

Referenced by START_TEST().

◆ test_ismbclegal()

static void test_ismbclegal ( void  )
static

Definition at line 1429 of file string.c.

1429  {
1430  unsigned int prev_cp = _getmbcp();
1431  int ret, exp, err;
1432  unsigned int i;
1433 
1434  _setmbcp(932); /* Japanese */
1435  err = 0;
1436  for(i = 0; i < 0x10000; i++) {
1437  ret = _ismbclegal(i);
1438  exp = ((HIBYTE(i) >= 0x81 && HIBYTE(i) <= 0x9F) ||
1439  (HIBYTE(i) >= 0xE0 && HIBYTE(i) <= 0xFC)) &&
1440  ((LOBYTE(i) >= 0x40 && LOBYTE(i) <= 0x7E) ||
1441  (LOBYTE(i) >= 0x80 && LOBYTE(i) <= 0xFC));
1442  if(ret != exp) {
1443  err = 1;
1444  break;
1445  }
1446  }
1447  ok(!err, "_ismbclegal (932) : Expected 0x%x, got 0x%x (0x%x)\n", exp, ret, i);
1448  _setmbcp(936); /* Chinese (GBK) */
1449  err = 0;
1450  for(i = 0; i < 0x10000; i++) {
1451  ret = _ismbclegal(i);
1452  exp = HIBYTE(i) >= 0x81 && HIBYTE(i) <= 0xFE &&
1453  LOBYTE(i) >= 0x40 && LOBYTE(i) <= 0xFE;
1454  if(ret != exp) {
1455  err = 1;
1456  break;
1457  }
1458  }
1459  ok(!err, "_ismbclegal (936) : Expected 0x%x, got 0x%x (0x%x)\n", exp, ret, i);
1460  _setmbcp(949); /* Korean */
1461  err = 0;
1462  for(i = 0; i < 0x10000; i++) {
1463  ret = _ismbclegal(i);
1464  exp = HIBYTE(i) >= 0x81 && HIBYTE(i) <= 0xFE &&
1465  LOBYTE(i) >= 0x41 && LOBYTE(i) <= 0xFE;
1466  if(ret != exp) {
1467  err = 1;
1468  break;
1469  }
1470  }
1471  ok(!err, "_ismbclegal (949) : Expected 0x%x, got 0x%x (0x%x)\n", exp, ret, i);
1472  _setmbcp(950); /* Chinese (Big5) */
1473  err = 0;
1474  for(i = 0; i < 0x10000; i++) {
1475  ret = _ismbclegal(i);
1476  exp = HIBYTE(i) >= 0x81 && HIBYTE(i) <= 0xFE &&
1477  ((LOBYTE(i) >= 0x40 && LOBYTE(i) <= 0x7E) ||
1478  (LOBYTE(i) >= 0xA1 && LOBYTE(i) <= 0xFE));
1479  if(ret != exp) {
1480  err = 1;
1481  break;
1482  }
1483  }
1484  ok(!err, "_ismbclegal (950) : Expected 0x%x, got 0x%x (0x%x)\n", exp, ret, i);
1485  _setmbcp(1361); /* Korean (Johab) */
1486  err = 0;
1487  for(i = 0; i < 0x10000; i++) {
1488  ret = _ismbclegal(i);
1489  exp = ((HIBYTE(i) >= 0x81 && HIBYTE(i) <= 0xD3) ||
1490  (HIBYTE(i) >= 0xD8 && HIBYTE(i) <= 0xF9)) &&
1491  ((LOBYTE(i) >= 0x31 && LOBYTE(i) <= 0x7E) ||
1492  (LOBYTE(i) >= 0x81 && LOBYTE(i) <= 0xFE)) &&
1493  HIBYTE(i) != 0xDF;
1494  if(ret != exp) {
1495  err = 1;
1496  break;
1497  }
1498  }
1499  todo_wine ok(!err, "_ismbclegal (1361) : Expected 0x%x, got 0x%x (0x%x)\n", exp, ret, i);
1500 
1501  _setmbcp(prev_cp);
1502 }
#define LOBYTE(W)
Definition: jmemdos.c:487
#define HIBYTE(W)
Definition: jmemdos.c:486
_CRTIMP int __cdecl _getmbcp(void)
Definition: locale.c:1472
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define ok(value,...)
Definition: CComObject.cpp:34
_Check_return_ _CRTIMP int __cdecl _ismbclegal(_In_ unsigned int _Ch)
int __cdecl _setmbcp(int)
Definition: _setmbcp.c:218
int ret
#define todo_wine
Definition: test.h:154
#define err(...)
DWORD exp
Definition: msg.c:15681

Referenced by START_TEST().

◆ test_mbbtombc()

static void test_mbbtombc ( void  )
static

Definition at line 1350 of file string.c.

1351 {
1352  static const unsigned int mbbmbc[][2] = {
1353  {0x1f, 0x1f}, {0x20, 0x8140}, {0x39, 0x8258}, {0x40, 0x8197},
1354  {0x41, 0x8260}, {0x5e, 0x814f}, {0x7e, 0x8150}, {0x7f, 0x7f},
1355  {0x80, 0x80}, {0x81, 0x81}, {0xa0, 0xa0}, {0xa7, 0x8340},
1356  {0xb0, 0x815b}, {0xd1, 0x8380}, {0xff, 0xff}, {0,0}};
1357  int cp[] = { 932, 936, 939, 950, 1361, _MB_CP_SBCS };
1358  int i, j;
1359  int prev_cp = _getmbcp();
1360 
1361  for (i = 0; i < sizeof(cp)/sizeof(cp[0]); i++)
1362  {
1363  _setmbcp(cp[i]);
1364  for (j = 0; mbbmbc[j][0] != 0; j++)
1365  {
1366  unsigned int exp, ret;
1367  ret = _mbbtombc(mbbmbc[j][0]);
1368  exp = (cp[i] == 932) ? mbbmbc[j][1] : mbbmbc[j][0];
1369  ok(ret == exp, "Expected 0x%x, got 0x%x (0x%x, codepage %d)\n",
1370  exp, ret, mbbmbc[j][0], cp[i]);
1371  }
1372  }
1373  _setmbcp(prev_cp);
1374 }
_Check_return_ _CRTIMP unsigned int __cdecl _mbbtombc(_In_ unsigned int _Ch)
_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
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 ok(value,...)
Definition: CComObject.cpp:34
int __cdecl _setmbcp(int)
Definition: _setmbcp.c:218
int ret
POINT cp
Definition: magnifier.c:60
DWORD exp
Definition: msg.c:15681

Referenced by START_TEST().

◆ test_mbcjisjms()

static void test_mbcjisjms ( void  )
static

Definition at line 1237 of file string.c.

1238 {
1239  /* List of value-pairs to test. The test assumes the last pair to be {0, ..} */
1240  unsigned int jisjms[][2] = { {0x2020, 0}, {0x2021, 0}, {0x2120, 0}, {0x2121, 0x8140},
1241  {0x7f7f, 0}, {0x7f7e, 0}, {0x7e7f, 0}, {0x7e7e, 0xeffc},
1242  {0x255f, 0x837e}, {0x2560, 0x8380}, {0x2561, 0x8381},
1243  {0x2121FFFF, 0}, {0x2223, 0x81a1}, {0x237e, 0x829e}, {0, 0}};
1244  int cp[] = { 932, 936, 939, 950, 1361, _MB_CP_SBCS };
1245  unsigned int i, j;
1246  int prev_cp = _getmbcp();
1247 
1248  for (i = 0; i < sizeof(cp)/sizeof(cp[0]); i++)
1249  {
1250  _setmbcp(cp[i]);
1251  for (j = 0; jisjms[j][0] != 0; j++)
1252  {
1253  unsigned int ret, exp;
1254  ret = _mbcjistojms(jisjms[j][0]);
1255  exp = (cp[i] == 932) ? jisjms[j][1] : jisjms[j][0];
1256  ok(ret == exp, "Expected 0x%x, got 0x%x (0x%x, codepage=%d)\n",
1257  exp, ret, jisjms[j][0], cp[i]);
1258  }
1259  }
1260  _setmbcp(prev_cp);
1261 }
_Check_return_ _CRTIMP unsigned int __cdecl _mbcjistojms(_In_ unsigned int _Ch)
_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
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 ok(value,...)
Definition: CComObject.cpp:34
int __cdecl _setmbcp(int)
Definition: _setmbcp.c:218
int ret
POINT cp
Definition: magnifier.c:60
DWORD exp
Definition: msg.c:15681

Referenced by START_TEST().

◆ test_mbcjmsjis()

static void test_mbcjmsjis ( void  )
static

Definition at line 1263 of file string.c.

1264 {
1265  /* List of value-pairs to test. The test assumes the last pair to be {0, ..} */
1266  unsigned int jmsjis[][2] = { {0x80fc, 0}, {0x813f, 0}, {0x8140, 0x2121},
1267  {0x817e, 0x215f}, {0x817f, 0}, {0x8180, 0x2160},
1268  {0x819e, 0x217e}, {0x819f, 0x2221}, {0x81fc, 0x227e},
1269  {0x81fd, 0}, {0x9ffc, 0x5e7e}, {0x9ffd, 0},
1270  {0xa040, 0}, {0xdffc, 0}, {0xe040, 0x5f21},
1271  {0xeffc, 0x7e7e}, {0xf040, 0}, {0x21, 0}, {0, 0}};
1272  int cp[] = { 932, 936, 939, 950, 1361, _MB_CP_SBCS };
1273  unsigned int i, j;
1274  int prev_cp = _getmbcp();
1275 
1276  for (i = 0; i < sizeof(cp)/sizeof(cp[0]); i++)
1277  {
1278  _setmbcp(cp[i]);
1279  for (j = 0; jmsjis[j][0] != 0; j++)
1280  {
1281  unsigned int ret, exp;
1282  ret = _mbcjmstojis(jmsjis[j][0]);
1283  exp = (cp[i] == 932) ? jmsjis[j][1] : jmsjis[j][0];
1284  ok(ret == exp, "Expected 0x%x, got 0x%x (0x%x, codepage=%d)\n",
1285  exp, ret, jmsjis[j][0], cp[i]);
1286  }
1287  }
1288  _setmbcp(prev_cp);
1289 }
_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
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 ok(value,...)
Definition: CComObject.cpp:34
int __cdecl _setmbcp(int)
Definition: _setmbcp.c:218
int ret
_Check_return_ _CRTIMP unsigned int __cdecl _mbcjmstojis(_In_ unsigned int _Ch)
POINT cp
Definition: magnifier.c:60
DWORD exp
Definition: msg.c:15681

Referenced by START_TEST().

◆ test_mbcp()

static void test_mbcp ( void  )
static

Definition at line 214 of file string.c.

215 {
216  int mb_orig_max = *p__mb_cur_max;
217  int curr_mbcp = _getmbcp();
218  unsigned char *mbstring = (unsigned char *)"\xb0\xb1\xb2 \xb3\xb4 \xb5"; /* incorrect string */
219  unsigned char *mbstring2 = (unsigned char *)"\xb0\xb1\xb2\xb3Q\xb4\xb5"; /* correct string */
220  unsigned char *mbsonlylead = (unsigned char *)"\xb0\0\xb1\xb2 \xb3";
221  unsigned char buf[16];
222  int step;
223  CPINFO cp_info;
224 
225  /* _mbtype tests */
226 
227  /* An SBCS codepage test. The ctype of characters on e.g. CP1252 or CP1250 differs slightly
228  * between versions of Windows. Also Windows 9x seems to ignore the codepage and always uses
229  * CP1252 (or the ACP?) so we test only a few ASCII characters */
230  _setmbcp(1252);
231  expect_eq(p_mbctype[10], 0, char, "%x");
232  expect_eq(p_mbctype[50], 0, char, "%x");
233  expect_eq(p_mbctype[66], _SBUP, char, "%x");
234  expect_eq(p_mbctype[100], _SBLOW, char, "%x");
235  expect_eq(p_mbctype[128], 0, char, "%x");
236  _setmbcp(1250);
237  expect_eq(p_mbctype[10], 0, char, "%x");
238  expect_eq(p_mbctype[50], 0, char, "%x");
239  expect_eq(p_mbctype[66], _SBUP, char, "%x");
240  expect_eq(p_mbctype[100], _SBLOW, char, "%x");
241  expect_eq(p_mbctype[128], 0, char, "%x");
242 
243  /* double byte code pages */
244  test_codepage(932);
245  test_codepage(936);
246  test_codepage(949);
247  test_codepage(950);
248 
249  _setmbcp(936);
250  ok(*p__mb_cur_max == mb_orig_max, "__mb_cur_max shouldn't be updated (is %d != %d)\n", *p__mb_cur_max, mb_orig_max);
251  ok(_ismbblead('\354'), "\354 should be a lead byte\n");
252  ok(_ismbblead(' ') == FALSE, "' ' should not be a lead byte\n");
253  ok(_ismbblead(0x1234b0), "0x1234b0 should not be a lead byte\n");
254  ok(_ismbblead(0x123420) == FALSE, "0x123420 should not be a lead byte\n");
255  ok(_ismbbtrail('\xb0'), "\xa0 should be a trail byte\n");
256  ok(_ismbbtrail(' ') == FALSE, "' ' should not be a trail byte\n");
257 
258  /* _ismbslead */
259  expect_eq(_ismbslead(mbstring, &mbstring[0]), -1, int, "%d");
260  expect_eq(_ismbslead(mbstring, &mbstring[1]), FALSE, int, "%d");
261  expect_eq(_ismbslead(mbstring, &mbstring[2]), -1, int, "%d");
262  expect_eq(_ismbslead(mbstring, &mbstring[3]), FALSE, int, "%d");
263  expect_eq(_ismbslead(mbstring, &mbstring[4]), -1, int, "%d");
264  expect_eq(_ismbslead(mbstring, &mbstring[5]), FALSE, int, "%d");
265  expect_eq(_ismbslead(mbstring, &mbstring[6]), FALSE, int, "%d");
266  expect_eq(_ismbslead(mbstring, &mbstring[7]), -1, int, "%d");
267  expect_eq(_ismbslead(mbstring, &mbstring[8]), FALSE, int, "%d");
268 
269  expect_eq(_ismbslead(mbsonlylead, &mbsonlylead[0]), -1, int, "%d");
270  expect_eq(_ismbslead(mbsonlylead, &mbsonlylead[1]), FALSE, int, "%d");
271  expect_eq(_ismbslead(mbsonlylead, &mbsonlylead[2]), FALSE, int, "%d");
272  expect_eq(_ismbslead(mbsonlylead, &mbsonlylead[5]), FALSE, int, "%d");
273 
274  /* _ismbstrail */
275  expect_eq(_ismbstrail(mbstring, &mbstring[0]), FALSE, int, "%d");
276  expect_eq(_ismbstrail(mbstring, &mbstring[1]), -1, int, "%d");
277  expect_eq(_ismbstrail(mbstring, &mbstring[2]), FALSE, int, "%d");
278  expect_eq(_ismbstrail(mbstring, &mbstring[3]), -1, int, "%d");
279  expect_eq(_ismbstrail(mbstring, &mbstring[4]), FALSE, int, "%d");
280  expect_eq(_ismbstrail(mbstring, &mbstring[5]), -1, int, "%d");
281  expect_eq(_ismbstrail(mbstring, &mbstring[6]), FALSE, int, "%d");
282  expect_eq(_ismbstrail(mbstring, &mbstring[7]), FALSE, int, "%d");
283  expect_eq(_ismbstrail(mbstring, &mbstring[8]), -1, int, "%d");
284 
285  expect_eq(_ismbstrail(mbsonlylead, &mbsonlylead[0]), FALSE, int, "%d");
286  expect_eq(_ismbstrail(mbsonlylead, &mbsonlylead[1]), -1, int, "%d");
287  expect_eq(_ismbstrail(mbsonlylead, &mbsonlylead[2]), FALSE, int, "%d");
288  expect_eq(_ismbstrail(mbsonlylead, &mbsonlylead[3]), FALSE, int, "%d");
289  expect_eq(_ismbstrail(mbsonlylead, &mbsonlylead[4]), FALSE, int, "%d");
290  expect_eq(_ismbstrail(mbsonlylead, &mbsonlylead[5]), FALSE, int, "%d");
291 
292  /* _mbsbtype */
293  expect_eq(_mbsbtype(mbstring, 0), _MBC_LEAD, int, "%d");
294  expect_eq(_mbsbtype(mbstring, 1), _MBC_TRAIL, int, "%d");
295  expect_eq(_mbsbtype(mbstring, 2), _MBC_LEAD, int, "%d");
296  expect_eq(_mbsbtype(mbstring, 3), _MBC_ILLEGAL, int, "%d");
297  expect_eq(_mbsbtype(mbstring, 4), _MBC_LEAD, int, "%d");
298  expect_eq(_mbsbtype(mbstring, 5), _MBC_TRAIL, int, "%d");
299  expect_eq(_mbsbtype(mbstring, 6), _MBC_SINGLE, int, "%d");
300  expect_eq(_mbsbtype(mbstring, 7), _MBC_LEAD, int, "%d");
301  expect_eq(_mbsbtype(mbstring, 8), _MBC_ILLEGAL, int, "%d");
302 
303  expect_eq(_mbsbtype(mbsonlylead, 0), _MBC_LEAD, int, "%d");
304  expect_eq(_mbsbtype(mbsonlylead, 1), _MBC_ILLEGAL, int, "%d");
305  expect_eq(_mbsbtype(mbsonlylead, 2), _MBC_ILLEGAL, int, "%d");
306  expect_eq(_mbsbtype(mbsonlylead, 3), _MBC_ILLEGAL, int, "%d");
307  expect_eq(_mbsbtype(mbsonlylead, 4), _MBC_ILLEGAL, int, "%d");
308  expect_eq(_mbsbtype(mbsonlylead, 5), _MBC_ILLEGAL, int, "%d");
309 
310  /* _mbsnextc */
311  expect_eq(_mbsnextc(mbstring), 0xb0b1, int, "%x");
312  expect_eq(_mbsnextc(&mbstring[2]), 0xb220, int, "%x"); /* lead + invalid tail */
313  expect_eq(_mbsnextc(&mbstring[3]), 0x20, int, "%x"); /* single char */
314 
315  /* _mbclen/_mbslen */
316  expect_eq(_mbclen(mbstring), 2, int, "%d");
317  expect_eq(_mbclen(&mbstring[2]), 2, int, "%d");
318  expect_eq(_mbclen(&mbstring[3]), 1, int, "%d");
319  expect_eq(_mbslen(mbstring2), 4, int, "%d");
320  expect_eq(_mbslen(mbsonlylead), 0, int, "%d"); /* lead + NUL not counted as character */
321  expect_eq(_mbslen(mbstring), 4, int, "%d"); /* lead + invalid trail counted */
322 
323  if(!p__mbsnlen) {
324  win_skip("_mbsnlen tests\n");
325  }else {
326  expect_eq(p__mbsnlen(mbstring, 8), 8, int, "%d");
327  expect_eq(p__mbsnlen(mbstring, 9), 4, int, "%d");
328  expect_eq(p__mbsnlen(mbstring, 10), 4, int, "%d");
329  expect_eq(p__mbsnlen(mbsonlylead, 0), 0, int, "%d");
330  expect_eq(p__mbsnlen(mbsonlylead, 1), 1, int, "%d");
331  expect_eq(p__mbsnlen(mbsonlylead, 2), 0, int, "%d");
332  expect_eq(p__mbsnlen(mbstring2, 7), 7, int, "%d");
333  expect_eq(p__mbsnlen(mbstring2, 8), 4, int, "%d");
334  expect_eq(p__mbsnlen(mbstring2, 9), 4, int, "%d");
335  }
336 
337  /* mbrlen */
338  if(!setlocale(LC_ALL, ".936") || !p_mbrlen) {
339  win_skip("mbrlen tests\n");
340  }else {
341  mbstate_t state = 0;
342  expect_eq(p_mbrlen((const char*)mbstring, 2, NULL), 2, int, "%d");
343  expect_eq(p_mbrlen((const char*)&mbstring[2], 2, NULL), 2, int, "%d");
344  expect_eq(p_mbrlen((const char*)&mbstring[3], 2, NULL), 1, int, "%d");
345  expect_eq(p_mbrlen((const char*)mbstring, 1, NULL), -2, int, "%d");
346  expect_eq(p_mbrlen((const char*)mbstring, 1, &state), -2, int, "%d");
347  ok(state == mbstring[0], "incorrect state value (%x)\n", state);
348  expect_eq(p_mbrlen((const char*)&mbstring[1], 1, &state), 2, int, "%d");
349  }
350 
351  /* mbrtowc */
352  if(!setlocale(LC_ALL, ".936") || !p_mbrtowc) {
353  win_skip("mbrtowc tests\n");
354  }else {
355  mbstate_t state = 0;
356  wchar_t dst;
357  expect_eq(p_mbrtowc(&dst, (const char*)mbstring, 2, NULL), 2, int, "%d");
358  ok(dst == 0x6c28, "dst = %x, expected 0x6c28\n", dst);
359  expect_eq(p_mbrtowc(&dst, (const char*)mbstring+2, 2, NULL), 2, int, "%d");
360  ok(dst == 0x3f, "dst = %x, expected 0x3f\n", dst);
361  expect_eq(p_mbrtowc(&dst, (const char*)mbstring+3, 2, NULL), 1, int, "%d");
362  ok(dst == 0x20, "dst = %x, expected 0x20\n", dst);
363  expect_eq(p_mbrtowc(&dst, (const char*)mbstring, 1, NULL), -2, int, "%d");
364  ok(dst == 0, "dst = %x, expected 0\n", dst);
365  expect_eq(p_mbrtowc(&dst, (const char*)mbstring, 1, &state), -2, int, "%d");
366  ok(dst == 0, "dst = %x, expected 0\n", dst);
367  ok(state == mbstring[0], "incorrect state value (%x)\n", state);
368  expect_eq(p_mbrtowc(&dst, (const char*)mbstring+1, 1, &state), 2, int, "%d");
369  ok(dst == 0x6c28, "dst = %x, expected 0x6c28\n", dst);
370  ok(state == 0, "incorrect state value (%x)\n", state);
371  }
372  setlocale(LC_ALL, "C");
373 
374  /* _mbccpy/_mbsncpy */
375  memset(buf, 0xff, sizeof(buf));
376  _mbccpy(buf, mbstring);
377  expect_bin(buf, "\xb0\xb1\xff", 3);
378 
379  if(!p__mbccpy_s) {
380  win_skip("_mbccpy_s tests\n");
381  }else {
382  int err, copied;
383 
384  memset(buf, 0xff, sizeof(buf));
385  copied = -1;
386  err = p__mbccpy_s(buf, 0, &copied, mbstring);
387  ok(err == EINVAL, "_mbccpy_s returned %d\n", err);
388  ok(!copied, "copied = %d\n", copied);
389  ok(buf[0] == 0xff, "buf[0] = %x\n", buf[0]);
390 
391  memset(buf, 0xff, sizeof(buf));
392  copied = -1;
393  err = p__mbccpy_s(buf, 1, &copied, mbstring);
394  ok(err == ERANGE, "_mbccpy_s returned %d\n", err);
395  ok(!copied, "copied = %d\n", copied);
396  ok(!buf[0], "buf[0] = %x\n", buf[0]);
397 
398  memset(buf, 0xff, sizeof(buf));
399  copied = -1;
400  err = p__mbccpy_s(buf, 2, &copied, mbstring);
401  ok(!err, "_mbccpy_s returned %d\n", err);
402  ok(copied == 2, "copied = %d\n", copied);
403  expect_bin(buf, "\xb0\xb1\xff", 3);
404 
405  memset(buf, 0xff, sizeof(buf));
406  copied = -1;
407  err = p__mbccpy_s(buf, 2, &copied, (unsigned char *)"\xb0");
408  ok(err == EILSEQ, "_mbccpy_s returned %d\n", err);
409  ok(copied == 1, "copied = %d\n", copied);
410  expect_bin(buf, "\x00\xff", 2);
411  }
412 
413  memset(buf, 0xff, sizeof(buf));
414  _mbsncpy(buf, mbstring, 1);
415  expect_bin(buf, "\xb0\xb1\xff", 3);
416  memset(buf, 0xff, sizeof(buf));
417  _mbsncpy(buf, mbstring, 2);
418  expect_bin(buf, "\xb0\xb1\xb2 \xff", 5);
419  memset(buf, 0xff, sizeof(buf));
420  _mbsncpy(buf, mbstring, 3);
421  expect_bin(buf, "\xb0\xb1\xb2 \xb3\xb4\xff", 7);
422  memset(buf, 0xff, sizeof(buf));
423  _mbsncpy(buf, mbstring, 4);
424  expect_bin(buf, "\xb0\xb1\xb2 \xb3\xb4 \xff", 8);
425  memset(buf, 0xff, sizeof(buf));
426  _mbsncpy(buf, mbstring, 5);
427  expect_bin(buf, "\xb0\xb1\xb2 \xb3\xb4 \0\0\xff", 10);
428  memset(buf, 0xff, sizeof(buf));
429  _mbsncpy(buf, mbsonlylead, 6);
430  expect_bin(buf, "\0\0\0\0\0\0\0\xff", 8);
431 
432  memset(buf, 0xff, sizeof(buf));
433  _mbsnbcpy(buf, mbstring2, 2);
434  expect_bin(buf, "\xb0\xb1\xff", 3);
435  _mbsnbcpy(buf, mbstring2, 3);
436  expect_bin(buf, "\xb0\xb1\0\xff", 4);
437  _mbsnbcpy(buf, mbstring2, 4);
438  expect_bin(buf, "\xb0\xb1\xb2\xb3\xff", 5);
439  memset(buf, 0xff, sizeof(buf));
440  _mbsnbcpy(buf, mbsonlylead, 5);
441  expect_bin(buf, "\0\0\0\0\0\xff", 6);
442 
443  /* _mbsinc/mbsdec */
444  step = _mbsinc(mbstring) - mbstring;
445  ok(step == 2, "_mbsinc adds %d (exp. 2)\n", step);
446  step = _mbsinc(&mbstring[2]) - &mbstring[2]; /* lead + invalid tail */
447  ok(step == 2, "_mbsinc adds %d (exp. 2)\n", step);
448 
449  step = _mbsninc(mbsonlylead, 1) - mbsonlylead;
450  ok(step == 0, "_mbsninc adds %d (exp. 0)\n", step);
451  step = _mbsninc(mbsonlylead, 2) - mbsonlylead; /* lead + NUL byte + lead + char */
452  ok(step == 0, "_mbsninc adds %d (exp. 0)\n", step);
453  step = _mbsninc(mbstring2, 0) - mbstring2;
454  ok(step == 0, "_mbsninc adds %d (exp. 2)\n", step);
455  step = _mbsninc(mbstring2, 1) - mbstring2;
456  ok(step == 2, "_mbsninc adds %d (exp. 2)\n", step);
457  step = _mbsninc(mbstring2, 2) - mbstring2;
458  ok(step == 4, "_mbsninc adds %d (exp. 4)\n", step);
459  step = _mbsninc(mbstring2, 3) - mbstring2;
460  ok(step == 5, "_mbsninc adds %d (exp. 5)\n", step);
461  step = _mbsninc(mbstring2, 4) - mbstring2;
462  ok(step == 7, "_mbsninc adds %d (exp. 7)\n", step);
463  step = _mbsninc(mbstring2, 5) - mbstring2;
464  ok(step == 7, "_mbsninc adds %d (exp. 7)\n", step);
465  step = _mbsninc(mbstring2, 17) - mbstring2;
466  ok(step == 7, "_mbsninc adds %d (exp. 7)\n", step);
467 
468  /* functions that depend on locale codepage, not mbcp.
469  * we hope the current locale to be SBCS because setlocale(LC_ALL, ".1252") seems not to work yet
470  * (as of Wine 0.9.43)
471  */
472  GetCPInfo(GetACP(), &cp_info);
473  if (cp_info.MaxCharSize == 1)
474  {
475  expect_eq(mblen((char *)mbstring, 3), 1, int, "%x");
476  expect_eq(_mbstrlen((char *)mbstring2), 7, int, "%d");
477  }
478  else
479  skip("Current locale has double-byte charset - could lead to false positives\n");
480 
481  _setmbcp(1361);
482  expect_eq(_ismbblead(0x80), 0, int, "%d");
483  todo_wine {
484  expect_eq(_ismbblead(0x81), 1, int, "%d");
485  expect_eq(_ismbblead(0x83), 1, int, "%d");
486  }
487  expect_eq(_ismbblead(0x84), 1, int, "%d");
488  expect_eq(_ismbblead(0xd3), 1, int, "%d");
489  expect_eq(_ismbblead(0xd7), 0, int, "%d");
490  expect_eq(_ismbblead(0xd8), 1, int, "%d");
491  expect_eq(_ismbblead(0xd9), 1, int, "%d");
492 
493  expect_eq(_ismbbtrail(0x30), 0, int, "%d");
494  expect_eq(_ismbbtrail(0x31), 1, int, "%d");
495  expect_eq(_ismbbtrail(0x7e), 1, int, "%d");
496  expect_eq(_ismbbtrail(0x7f), 0, int, "%d");
497  expect_eq(_ismbbtrail(0x80), 0, int, "%d");
498  expect_eq(_ismbbtrail(0x81), 1, int, "%d");
499  expect_eq(_ismbbtrail(0xfe), 1, int, "%d");
500  expect_eq(_ismbbtrail(0xff), 0, int, "%d");
501 
502  _setmbcp(curr_mbcp);
503 }
BOOL WINAPI GetCPInfo(UINT CodePage, LPCPINFO CodePageInfo)
Definition: nls.c:1813
#define EILSEQ
Definition: errno.h:97
_Check_return_ _CRTIMP int __cdecl _ismbbtrail(_In_ unsigned int _C)
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
#define _MBC_ILLEGAL
Definition: msvcrt.h:826
Definition: arc.h:39
_Check_return_ _CRTIMP unsigned char *__cdecl _mbsninc(_In_reads_bytes_(_Count) _Pre_z_ const unsigned char *_Str, _In_ size_t _Count)
_Check_return_ _CRTIMP size_t __cdecl _mbslen(_In_z_ const unsigned char *_Str)
#define expect_eq(expr, value, type, format)
Definition: string.c:52
_CRTIMP int __cdecl _getmbcp(void)
Definition: locale.c:1472
_CRTIMP void __cdecl _mbccpy(_Out_writes_bytes_(2) unsigned char *_Dst, _In_z_ const unsigned char *_Src)
_CRTIMP unsigned char *__cdecl _mbsnbcpy(_Out_writes_(_Count) _Post_maybez_ unsigned char *_Dest, _In_z_ const unsigned char *_Source, _In_ size_t _Count)
_Check_return_ _CRTIMP size_t __cdecl _mbstrlen(_In_z_ const char *_Str)
smooth NULL
Definition: ftsmooth.c:416
UINT WINAPI GetACP(VOID)
Definition: nls.c:2078
#define ok(value,...)
Definition: CComObject.cpp:34
#define LC_ALL
Definition: locale.h:25
#define _MBC_SINGLE
Definition: msvcrt.h:823
#define expect_bin(buf, value, len)
Definition: string.c:53
int __cdecl _setmbcp(int)
Definition: _setmbcp.c:218
static unsigned char * p_mbctype
Definition: string.c:85
#define _SBUP
Definition: msvcrt.h:820
_CRTIMP unsigned char *__cdecl _mbsncpy(_Pre_notnull_ _Out_writes_(2 *_Count) _Post_maybez_ unsigned char *_Dest, _In_z_ const unsigned char *_Source, _In_ size_t _Count)
#define ERANGE
Definition: acclib.h:92
_Check_return_ _CRTIMP unsigned char *__cdecl _mbsinc(_In_z_ const unsigned char *_Ptr)
#define _MBC_TRAIL
Definition: msvcrt.h:825
_Check_return_ _CRTIMP unsigned int __cdecl _mbsnextc(_In_z_ const unsigned char *_Str)
#define todo_wine
Definition: test.h:154
static int state
Definition: maze.c:121
#define err(...)
int __cdecl _ismbstrail(const unsigned char *start, const unsigned char *str)
Definition: ismbtrl.c:32
_Check_return_ int __cdecl mblen(_In_reads_bytes_opt_(_MaxCount) _Pre_opt_z_ const char *_Ch, _In_ size_t _MaxCount)
#define skip(...)
Definition: CString.cpp:57
GLenum GLenum dst
Definition: glext.h:6340
_CRTIMP int __cdecl _mbsbtype(_In_reads_bytes_(_Pos) _Pre_z_ const unsigned char *_Str, _In_ size_t _Pos)
#define test_codepage(num)
Definition: string.c:210
int __cdecl _ismbblead(unsigned int)
Definition: ismblead.c:20
#define _SBLOW
Definition: msvcrt.h:821
#define setlocale(n, s)
Definition: locale.h:46
#define _MBC_LEAD
Definition: msvcrt.h:824