Commit 4a4621f4 authored by Piotr Caban's avatar Piotr Caban Committed by Alexandre Julliard

msvcrt/tests: Use wide-char string literals.

parent b0a302cc
......@@ -138,36 +138,6 @@ static void test_makepath(void)
}
}
static const WCHAR expected0[] = {'\0','X','X','X','X','X','X','X','X','X','X','X','X'};
static const WCHAR expected1[] = {'\0','X','X','X','X','X','X','X','X','X','X','X','X'};
static const WCHAR expected2[] = {'\0',':','X','X','X','X','X','X','X','X','X','X','X'};
static const WCHAR expected3[] = {'\0',':','d','X','X','X','X','X','X','X','X','X','X'};
static const WCHAR expected4[] = {'\0',':','d','\\','X','X','X','X','X','X','X','X','X'};
static const WCHAR expected5[] = {'\0',':','d','\\','f','X','X','X','X','X','X','X','X'};
static const WCHAR expected6[] = {'\0',':','d','\\','f','i','X','X','X','X','X','X','X'};
static const WCHAR expected7[] = {'\0',':','d','\\','f','i','l','X','X','X','X','X','X'};
static const WCHAR expected8[] = {'\0',':','d','\\','f','i','l','e','X','X','X','X','X'};
static const WCHAR expected9[] = {'\0',':','d','\\','f','i','l','e','.','X','X','X','X'};
static const WCHAR expected10[] = {'\0',':','d','\\','f','i','l','e','.','e','X','X','X'};
static const WCHAR expected11[] = {'\0',':','d','\\','f','i','l','e','.','e','x','X','X'};
static const WCHAR expected12[] = {'\0',':','X','X','X','X','X','X','X','X'};
static const WCHAR expected13[] = {'\0',':','d','X','X','X','X','X','X','X'};
static const WCHAR expected14[] = {'\0',':','d','i','X','X','X','X','X','X'};
static const WCHAR expected15[] = {'\0',':','d','i','r','X','X','X','X','X'};
static const WCHAR expected16[] = {'\0',':','d','i','r','\\','X','X','X','X'};
static const WCHAR expected17[] = {'\0','o','o'};
static const WCHAR expected18[] = {'\0','o','o','\0','X'};
static const WCHAR expected19[] = {'\0','o','o','\0'};
static const WCHAR expected20[] = {'\0','o','o','\0','X','X','X','X','X'};
static const WCHAR expected21[] = {'\0','o','o','\\','f','i','l','X','X'};
static const WCHAR expected22[] = {'\0','o','o','\0','X','X','X','X','X','X','X','X','X'};
static const WCHAR expected23[] = {'\0','o','o','\\','f','i','l','X','X','X','X','X','X'};
static const WCHAR expected24[] = {'\0','o','o','\\','f','i','l','e','.','e','x','X','X'};
static const WCHAR expected25[] = {'\0','o','o','\0','X','X','X','X'};
static const WCHAR expected26[] = {'\0','o','o','.','e','x','X','X'};
typedef struct
{
const char* buffer;
......@@ -184,35 +154,35 @@ typedef struct
static const makepath_s_case makepath_s_cases[] =
{
/* Behavior with directory parameter containing backslash. */
{NULL, 1, "c:", "d\\", "file", "ext", "\0XXXXXXXXXXXX", expected0, 13},
{NULL, 2, "c:", "d\\", "file", "ext", "\0XXXXXXXXXXXX", expected1, 13},
{NULL, 3, "c:", "d\\", "file", "ext", "\0:XXXXXXXXXXX", expected2, 13},
{NULL, 4, "c:", "d\\", "file", "ext", "\0:dXXXXXXXXXX", expected3, 13},
{NULL, 5, "c:", "d\\", "file", "ext", "\0:d\\XXXXXXXXX", expected4, 13},
{NULL, 6, "c:", "d\\", "file", "ext", "\0:d\\fXXXXXXXX", expected5, 13},
{NULL, 7, "c:", "d\\", "file", "ext", "\0:d\\fiXXXXXXX", expected6, 13},
{NULL, 8, "c:", "d\\", "file", "ext", "\0:d\\filXXXXXX", expected7, 13},
{NULL, 9, "c:", "d\\", "file", "ext", "\0:d\\fileXXXXX", expected8, 13},
{NULL, 10, "c:", "d\\", "file", "ext", "\0:d\\file.XXXX", expected9, 13},
{NULL, 11, "c:", "d\\", "file", "ext", "\0:d\\file.eXXX", expected10, 13},
{NULL, 12, "c:", "d\\", "file", "ext", "\0:d\\file.exXX", expected11, 13},
{NULL, 1, "c:", "d\\", "file", "ext", "\0XXXXXXXXXXXX", L"\0XXXXXXXXXXXX", 13},
{NULL, 2, "c:", "d\\", "file", "ext", "\0XXXXXXXXXXXX", L"\0XXXXXXXXXXXX", 13},
{NULL, 3, "c:", "d\\", "file", "ext", "\0:XXXXXXXXXXX", L"\0:XXXXXXXXXXX", 13},
{NULL, 4, "c:", "d\\", "file", "ext", "\0:dXXXXXXXXXX", L"\0:dXXXXXXXXXX", 13},
{NULL, 5, "c:", "d\\", "file", "ext", "\0:d\\XXXXXXXXX", L"\0:d\\XXXXXXXXX", 13},
{NULL, 6, "c:", "d\\", "file", "ext", "\0:d\\fXXXXXXXX", L"\0:d\\fXXXXXXXX", 13},
{NULL, 7, "c:", "d\\", "file", "ext", "\0:d\\fiXXXXXXX", L"\0:d\\fiXXXXXXX", 13},
{NULL, 8, "c:", "d\\", "file", "ext", "\0:d\\filXXXXXX", L"\0:d\\filXXXXXX", 13},
{NULL, 9, "c:", "d\\", "file", "ext", "\0:d\\fileXXXXX", L"\0:d\\fileXXXXX", 13},
{NULL, 10, "c:", "d\\", "file", "ext", "\0:d\\file.XXXX", L"\0:d\\file.XXXX", 13},
{NULL, 11, "c:", "d\\", "file", "ext", "\0:d\\file.eXXX", L"\0:d\\file.eXXX", 13},
{NULL, 12, "c:", "d\\", "file", "ext", "\0:d\\file.exXX", L"\0:d\\file.exXX", 13},
/* Behavior with directory parameter lacking backslash. */
{NULL, 3, "c:", "dir", "f", "ext", "\0:XXXXXXXX", expected12, 10},
{NULL, 4, "c:", "dir", "f", "ext", "\0:dXXXXXXX", expected13, 10},
{NULL, 5, "c:", "dir", "f", "ext", "\0:diXXXXXX", expected14, 10},
{NULL, 6, "c:", "dir", "f", "ext", "\0:dirXXXXX", expected15, 10},
{NULL, 7, "c:", "dir", "f", "ext", "\0:dir\\XXXX", expected16, 10},
{NULL, 3, "c:", "dir", "f", "ext", "\0:XXXXXXXX", L"\0:XXXXXXXX", 10},
{NULL, 4, "c:", "dir", "f", "ext", "\0:dXXXXXXX", L"\0:dXXXXXXX", 10},
{NULL, 5, "c:", "dir", "f", "ext", "\0:diXXXXXX", L"\0:diXXXXXX", 10},
{NULL, 6, "c:", "dir", "f", "ext", "\0:dirXXXXX", L"\0:dirXXXXX", 10},
{NULL, 7, "c:", "dir", "f", "ext", "\0:dir\\XXXX", L"\0:dir\\XXXX", 10},
/* Behavior with overlapped buffer. */
{"foo", 2, USE_BUFF, NULL, NULL, NULL, "\0oo", expected17, 3},
{"foo", 4, NULL, USE_BUFF, NULL, NULL, "\0oo\0X", expected18, 5},
{"foo", 3, NULL, NULL, USE_BUFF, NULL, "\0oo\0", expected19, 4},
{"foo", 4, NULL, USE_BUFF, "file", NULL, "\0oo\0XXXXX", expected20, 9},
{"foo", 8, NULL, USE_BUFF, "file", NULL, "\0oo\\filXX", expected21, 9},
{"foo", 4, NULL, USE_BUFF, "file", "ext", "\0oo\0XXXXXXXXX", expected22, 13},
{"foo", 8, NULL, USE_BUFF, "file", "ext", "\0oo\\filXXXXXX", expected23, 13},
{"foo", 12, NULL, USE_BUFF, "file", "ext", "\0oo\\file.exXX", expected24, 13},
{"foo", 4, NULL, NULL, USE_BUFF, "ext", "\0oo\0XXXX", expected25, 8},
{"foo", 7, NULL, NULL, USE_BUFF, "ext", "\0oo.exXX", expected26, 8},
{"foo", 2, USE_BUFF, NULL, NULL, NULL, "\0oo", L"\0oo", 3},
{"foo", 4, NULL, USE_BUFF, NULL, NULL, "\0oo\0X", L"\0oo\0X", 5},
{"foo", 3, NULL, NULL, USE_BUFF, NULL, "\0oo\0", L"\0oo", 4},
{"foo", 4, NULL, USE_BUFF, "file", NULL, "\0oo\0XXXXX", L"\0oo\0XXXXX", 9},
{"foo", 8, NULL, USE_BUFF, "file", NULL, "\0oo\\filXX", L"\0oo\\filXX", 9},
{"foo", 4, NULL, USE_BUFF, "file", "ext", "\0oo\0XXXXXXXXX", L"\0oo\0XXXXXXXXX", 13},
{"foo", 8, NULL, USE_BUFF, "file", "ext", "\0oo\\filXXXXXX", L"\0oo\\filXXXXXX", 13},
{"foo", 12, NULL, USE_BUFF, "file", "ext", "\0oo\\file.exXX", L"\0oo\\file.exXX", 13},
{"foo", 4, NULL, NULL, USE_BUFF, "ext", "\0oo\0XXXX", L"\0oo\0XXXX", 8},
{"foo", 7, NULL, NULL, USE_BUFF, "ext", "\0oo.exXX", L"\0oo.exXX", 8},
};
static void test_makepath_s(void)
......@@ -438,10 +408,6 @@ static void test_searchenv(void)
"\\search_env_test\\dir3longer\\3.dat"
};
const WCHAR env_w[] = {'T','E','S','T','_','P','A','T','H',0};
const WCHAR dat1_w[] = {'1','.','d','a','t',0};
const WCHAR dat3_w[] = {'3','.','d','a','t',0};
char env1[4*MAX_PATH], env2[4*MAX_PATH], tmppath[MAX_PATH], path[2*MAX_PATH];
char result[MAX_PATH], exp[2*MAX_PATH];
WCHAR result_w[MAX_PATH];
......@@ -510,13 +476,13 @@ static void test_searchenv(void)
}
memset(result_w, 'x', sizeof(result_w));
_wsearchenv(dat1_w, env_w, result_w);
_wsearchenv(L"1.dat", L"TEST_PATH", result_w);
WideCharToMultiByte(CP_ACP, 0, result_w, -1, result, MAX_PATH, NULL, NULL);
ok(!strcmp(result, exp), "got %s, expected '%s'\n", result, exp);
if (p_wsearchenv_s) {
memset(result_w, 'x', sizeof(result_w));
i = p_wsearchenv_s(dat1_w, env_w, result_w, MAX_PATH);
i = p_wsearchenv_s(L"1.dat", L"TEST_PATH", result_w, MAX_PATH);
ok(!i, "wsearchenv_s returned %d\n", i);
ok(!strcmp(result, exp), "got %s, expected '%s'\n", result, exp);
}
......@@ -535,13 +501,13 @@ static void test_searchenv(void)
}
memset(result_w, 'x', sizeof(result_w));
_wsearchenv(dat3_w, env_w, result_w);
_wsearchenv(L"3.dat", L"TEST_PATH", result_w);
WideCharToMultiByte(CP_ACP, 0, result_w, -1, result, MAX_PATH, NULL, NULL);
ok(!strcmp(result, exp), "got %s, expected '%s'\n", result, exp);
if (p_wsearchenv_s) {
memset(result_w, 'x', sizeof(result_w));
i = p_wsearchenv_s(dat3_w, env_w, result_w, MAX_PATH);
i = p_wsearchenv_s(L"3.dat", L"TEST_PATH", result_w, MAX_PATH);
ok(!i, "wsearchenv_s returned %d\n", i);
ok(!strcmp(result, exp), "got %s, expected '%s'\n", result, exp);
}
......@@ -561,13 +527,13 @@ static void test_searchenv(void)
}
memset(result_w, 'x', sizeof(result_w));
_wsearchenv(dat1_w, env_w, result_w);
_wsearchenv(L"1.dat", L"TEST_PATH", result_w);
WideCharToMultiByte(CP_ACP, 0, result_w, -1, result, MAX_PATH, NULL, NULL);
ok(!strcmp(result, exp), "got %s, expected '%s'\n", result, exp);
if (p_wsearchenv_s) {
memset(result_w, 'x', sizeof(result_w));
i = p_wsearchenv_s(dat1_w, env_w, result_w, MAX_PATH);
i = p_wsearchenv_s(L"1.dat", L"TEST_PATH", result_w, MAX_PATH);
ok(!i, "wsearchenv_s returned %d\n", i);
ok(!strcmp(result, exp), "got %s, expected '%s'\n", result, exp);
}
......@@ -586,13 +552,13 @@ static void test_searchenv(void)
}
memset(result_w, 'x', sizeof(result_w));
_wsearchenv(dat3_w, env_w, result_w);
_wsearchenv(L"3.dat", L"TEST_PATH", result_w);
WideCharToMultiByte(CP_ACP, 0, result_w, -1, result, MAX_PATH, NULL, NULL);
ok(!strcmp(result, exp), "got %s, expected '%s'\n", result, exp);
if (p_wsearchenv_s) {
memset(result_w, 'x', sizeof(result_w));
i = p_wsearchenv_s(dat3_w, env_w, result_w, MAX_PATH);
i = p_wsearchenv_s(L"3.dat", L"TEST_PATH", result_w, MAX_PATH);
ok(!i, "wsearchenv_s returned %d\n", i);
ok(!strcmp(result, exp), "got %s, expected '%s'\n", result, exp);
}
......
......@@ -137,9 +137,6 @@ static void test__environ(void)
static void test__wenviron(void)
{
static const WCHAR cat_eq_dogW[] = {'c','a','t','=','d','o','g',0};
static const WCHAR cat_eqW[] = {'c','a','t','=',0};
int argc;
char **argv, **envp = NULL;
WCHAR **wargv, **wenvp = NULL;
......@@ -191,9 +188,9 @@ static void test__wenviron(void)
/* _wenviron isn't initialized until __wgetmainargs is called or
* one of the Unicode environment manipulation functions is called. */
ok( _wputenv(cat_eq_dogW) == 0, "failed setting cat=dog\n" );
ok( _wputenv(L"cat=dog") == 0, "failed setting cat=dog\n" );
ok( *p_wenviron != NULL, "Expected _wenviron to be non-NULL\n" );
ok( _wputenv(cat_eqW) == 0, "failed deleting cat\n" );
ok( _wputenv(L"cat=") == 0, "failed deleting cat\n" );
__wgetmainargs(&argc, &wargv, &wenvp, 0, &mode);
......
......@@ -1944,12 +1944,6 @@ static void test_fopen_s( void )
static void test__wfopen_s( void )
{
const char name[] = "empty1";
const WCHAR wname[] = {
'e','m','p','t','y','1',0
};
const WCHAR wmode[] = {
'w',0
};
char buff[16];
FILE *file;
int ret;
......@@ -1961,7 +1955,7 @@ static void test__wfopen_s( void )
return;
}
/* testing _wfopen_s */
ret = p__wfopen_s(&file, wname, wmode);
ret = p__wfopen_s(&file, L"empty1", L"w");
ok(ret == 0, "_wfopen_s failed with %d\n", ret);
ok(file != 0, "_wfopen_s failed to return value\n");
fwrite(name, sizeof(name), 1, file);
......
......@@ -644,13 +644,7 @@ static void test_setlocale(void)
static void test_crtGetStringTypeW(void)
{
static const wchar_t str0[] = { '0', '\0' };
static const wchar_t strA[] = { 'A', '\0' };
static const wchar_t str_space[] = { ' ', '\0' };
static const wchar_t str_null[] = { '\0', '\0' };
static const wchar_t str_rand[] = { 1234, '\0' };
const wchar_t *str[] = { str0, strA, str_space, str_null, str_rand };
const wchar_t *str[] = { L"0", L"A", L" ", L"\0", L"\x04d2" };
WORD out_crt, out;
BOOL ret_crt, ret;
......
......@@ -401,23 +401,17 @@ static void test_sprintf( void )
static void test_swprintf( void )
{
wchar_t buffer[100];
const wchar_t I64d[] = {'%','I','6','4','d',0};
double pnumber=789456123;
const wchar_t TwentyThreePoint15e[]= {'%','+','#','2','3','.','1','5','e',0};
const wchar_t e008[] = {'e','+','0','0','8',0};
const wchar_t string_w[] = {'s','t','r','i','n','g',0};
double pnumber = 789456123;
const char string[] = "string";
const wchar_t S[]={'%','S',0};
const wchar_t hs[] = {'%', 'h', 's', 0};
swprintf(buffer,TwentyThreePoint15e,pnumber);
ok(wcsstr(buffer,e008) != 0,"Sprintf different\n");
swprintf(buffer,I64d,((ULONGLONG)0xffffffff)*0xffffffff);
ok(wcslen(buffer) == 11,"Problem with long long\n");
swprintf(buffer,S,string);
ok(wcslen(buffer) == 6,"Problem with \"%%S\" interpretation\n");
swprintf(buffer, hs, string);
ok( wcscmp(string_w,buffer) == 0, "swprintf failed with %%hs\n");
swprintf(buffer, L"%+#23.15e", pnumber);
ok(wcsstr(buffer, L"e+008") != 0, "Sprintf different\n");
swprintf(buffer, L"%I64d", ((ULONGLONG)0xffffffff)*0xffffffff);
ok(wcslen(buffer) == 11, "Problem with long long\n");
swprintf(buffer, L"%S", string);
ok(wcslen(buffer) == 6, "Problem with \"%%S\" interpretation\n");
swprintf(buffer, L"%hs", string);
ok(!wcscmp(L"string", buffer), "swprintf failed with %%hs\n");
}
static void test_snprintf (void)
......@@ -450,10 +444,7 @@ static void test_snprintf (void)
static void test_fprintf(void)
{
static const char file_name[] = "fprintf.tst";
static const WCHAR utf16_test[] = {'u','n','i','c','o','d','e','\n',0};
FILE *fp = fopen(file_name, "wb");
FILE *fp = fopen("fprintf.tst", "wb");
char buf[1024];
int ret;
......@@ -467,14 +458,14 @@ static void test_fprintf(void)
ret = ftell(fp);
ok(ret == 26, "ftell returned %d\n", ret);
ret = fwprintf(fp, utf16_test);
ret = fwprintf(fp, L"unicode\n");
ok(ret == 8, "ret = %d\n", ret);
ret = ftell(fp);
ok(ret == 42, "ftell returned %d\n", ret);
fclose(fp);
fp = fopen(file_name, "rb");
fp = fopen("fprintf.tst", "rb");
ret = fscanf(fp, "%[^\n] ", buf);
ok(ret == 1, "ret = %d\n", ret);
ret = ftell(fp);
......@@ -490,12 +481,11 @@ static void test_fprintf(void)
fgets(buf, sizeof(buf), fp);
ret = ftell(fp);
ok(ret == 41, "ret = %d\n", ret);
ok(!memcmp(buf, utf16_test, sizeof(utf16_test)),
"buf = %s\n", wine_dbgstr_w((WCHAR*)buf));
ok(!wcscmp((wchar_t*)buf, L"unicode\n"), "buf = %s\n", wine_dbgstr_w((WCHAR*)buf));
fclose(fp);
fp = fopen(file_name, "wt");
fp = fopen("fprintf.tst", "wt");
ret = fprintf(fp, "simple test\n");
ok(ret == 12, "ret = %d\n", ret);
......@@ -507,14 +497,14 @@ static void test_fprintf(void)
ret = ftell(fp);
ok(ret == 28, "ftell returned %d\n", ret);
ret = fwprintf(fp, utf16_test);
ret = fwprintf(fp, L"unicode\n");
ok(ret == 8, "ret = %d\n", ret);
ret = ftell(fp);
ok(ret == 37, "ftell returned %d\n", ret);
fclose(fp);
fp = fopen(file_name, "rb");
fp = fopen("fprintf.tst", "rb");
ret = fscanf(fp, "%[^\n] ", buf);
ok(ret == 1, "ret = %d\n", ret);
ret = ftell(fp);
......@@ -532,7 +522,7 @@ static void test_fprintf(void)
ok(!strcmp(buf, "unicode\r\n"), "buf = %s\n", buf);
fclose(fp);
unlink(file_name);
unlink("fprintf.tst");
}
static void test_fcvt(void)
......@@ -800,25 +790,19 @@ static int WINAPIV _vsnwprintf_wrapper(wchar_t *str, size_t len, const wchar_t *
static void test_vsnwprintf(void)
{
const wchar_t format[] = {'%','w','s','%','w','s','%','w','s',0};
const wchar_t one[] = {'o','n','e',0};
const wchar_t two[] = {'t','w','o',0};
const wchar_t three[] = {'t','h','r','e','e',0};
int ret;
wchar_t str[32];
char buf[32];
ret = _vsnwprintf_wrapper( str, ARRAY_SIZE(str), format, one, two, three );
ret = _vsnwprintf_wrapper( str, ARRAY_SIZE(str), L"%ws%ws%ws", L"one", L"two", L"three" );
ok( ret == 11, "got %d expected 11\n", ret );
WideCharToMultiByte( CP_ACP, 0, str, -1, buf, sizeof(buf), NULL, NULL );
ok( !strcmp(buf, "onetwothree"), "got %s expected 'onetwothree'\n", buf );
ret = _vsnwprintf_wrapper( str, 0, format, one, two, three );
ret = _vsnwprintf_wrapper( str, 0, L"%ws%ws%ws", L"one", L"two", L"three" );
ok( ret == -1, "got %d, expected -1\n", ret );
ret = _vsnwprintf_wrapper( NULL, 0, format, one, two, three );
ret = _vsnwprintf_wrapper( NULL, 0, L"%ws%ws%ws", L"one", L"two", L"three" );
ok( ret == 11 || broken(ret == -1 /* Win2k */), "got %d, expected 11\n", ret );
}
......@@ -884,11 +868,7 @@ static int WINAPIV _vswprintf_p_l_wrapper(wchar_t *str, size_t size, const wchar
static void test_vswprintf(void)
{
const wchar_t format[] = {'%','s',' ','%','d',0};
const wchar_t number[] = {'n','u','m','b','e','r',0};
const wchar_t out[] = {'n','u','m','b','e','r',' ','1','2','3',0};
wchar_t buf[20];
int ret;
if (!p_vswprintf || !p__vswprintf || !p__vswprintf_l ||!p__vswprintf_c
......@@ -898,39 +878,39 @@ static void test_vswprintf(void)
return;
}
ret = vswprintf_wrapper(buf, format, number, 123);
ret = vswprintf_wrapper(buf, L"%s %d", L"number", 123);
ok(ret == 10, "got %d, expected 10\n", ret);
ok(!memcmp(buf, out, sizeof(out)), "buf = %s\n", wine_dbgstr_w(buf));
ok(!wcscmp(buf, L"number 123"), "buf = %s\n", wine_dbgstr_w(buf));
memset(buf, 0, sizeof(buf));
ret = _vswprintf_wrapper(buf, format, number, 123);
ret = _vswprintf_wrapper(buf, L"%s %d", L"number", 123);
ok(ret == 10, "got %d, expected 10\n", ret);
ok(!memcmp(buf, out, sizeof(out)), "buf = %s\n", wine_dbgstr_w(buf));
ok(!wcscmp(buf, L"number 123"), "buf = %s\n", wine_dbgstr_w(buf));
memset(buf, 0, sizeof(buf));
ret = _vswprintf_l_wrapper(buf, format, NULL, number, 123);
ret = _vswprintf_l_wrapper(buf, L"%s %d", NULL, L"number", 123);
ok(ret == 10, "got %d, expected 10\n", ret);
ok(!memcmp(buf, out, sizeof(out)), "buf = %s\n", wine_dbgstr_w(buf));
ok(!wcscmp(buf, L"number 123"), "buf = %s\n", wine_dbgstr_w(buf));
memset(buf, 0, sizeof(buf));
ret = _vswprintf_c_wrapper(buf, 20, format, number, 123);
ret = _vswprintf_c_wrapper(buf, 20, L"%s %d", L"number", 123);
ok(ret == 10, "got %d, expected 10\n", ret);
ok(!memcmp(buf, out, sizeof(out)), "buf = %s\n", wine_dbgstr_w(buf));
ok(!wcscmp(buf, L"number 123"), "buf = %s\n", wine_dbgstr_w(buf));
memset(buf, 'x', sizeof(buf));
ret = _vswprintf_c_wrapper(buf, 10, format, number, 123);
ret = _vswprintf_c_wrapper(buf, 10, L"%s %d", L"number", 123);
ok(ret == -1, "got %d, expected -1\n", ret);
ok(!wcscmp(buf, L"number 12"), "buf = %s\n", wine_dbgstr_w(buf));
memset(buf, 0, sizeof(buf));
ret = _vswprintf_c_l_wrapper(buf, 20, format, NULL, number, 123);
ret = _vswprintf_c_l_wrapper(buf, 20, L"%s %d", NULL, L"number", 123);
ok(ret == 10, "got %d, expected 10\n", ret);
ok(!memcmp(buf, out, sizeof(out)), "buf = %s\n", wine_dbgstr_w(buf));
ok(!wcscmp(buf, L"number 123"), "buf = %s\n", wine_dbgstr_w(buf));
memset(buf, 0, sizeof(buf));
ret = _vswprintf_p_l_wrapper(buf, 20, format, NULL, number, 123);
ret = _vswprintf_p_l_wrapper(buf, 20, L"%s %d", NULL, L"number", 123);
ok(ret == 10, "got %d, expected 10\n", ret);
ok(!memcmp(buf, out, sizeof(out)), "buf = %s\n", wine_dbgstr_w(buf));
ok(!wcscmp(buf, L"number 123"), "buf = %s\n", wine_dbgstr_w(buf));
}
static int WINAPIV _vscprintf_wrapper(const char *format, ...)
......@@ -969,9 +949,6 @@ static int WINAPIV _vscwprintf_wrapper(const wchar_t *format, ...)
static void test_vscwprintf(void)
{
const wchar_t format[] = {'%','s',' ','%','d',0};
const wchar_t number[] = {'n','u','m','b','e','r',0};
int ret;
if (!p__vscwprintf)
......@@ -980,7 +957,7 @@ static void test_vscwprintf(void)
return;
}
ret = _vscwprintf_wrapper( format, number, 1 );
ret = _vscwprintf_wrapper(L"%s %d", L"number", 1 );
ok( ret == 8, "got %d expected 8\n", ret );
}
......@@ -997,13 +974,8 @@ static int WINAPIV _vsnwprintf_s_wrapper(wchar_t *str, size_t sizeOfBuffer,
static void test_vsnwprintf_s(void)
{
const wchar_t format[] = { 'A','B','%','u','C',0 };
const wchar_t out7[] = { 'A','B','1','2','3','C',0 };
const wchar_t out6[] = { 'A','B','1','2','3',0 };
const wchar_t out2[] = { 'A',0 };
const wchar_t out1[] = { 0 };
wchar_t buffer[14] = { 0 };
int exp, got;
int ret;
if (!p__vsnwprintf_s)
{
......@@ -1012,34 +984,30 @@ static void test_vsnwprintf_s(void)
}
/* Enough room. */
exp = wcslen(out7);
ret = _vsnwprintf_s_wrapper(buffer, 14, _TRUNCATE, L"AB%uC", 123);
ok( ret == 6, "length wrong, expect=6, got=%d\n", ret);
ok( !wcscmp(L"AB123C", buffer), "buffer wrong, got=%s\n", wine_dbgstr_w(buffer));
got = _vsnwprintf_s_wrapper(buffer, 14, _TRUNCATE, format, 123);
ok( exp == got, "length wrong, expect=%d, got=%d\n", exp, got);
ok( !wcscmp(out7, buffer), "buffer wrong, got=%s\n", wine_dbgstr_w(buffer));
ret = _vsnwprintf_s_wrapper(buffer, 12, _TRUNCATE, L"AB%uC", 123);
ok( ret == 6, "length wrong, expect=6, got=%d\n", ret);
ok( !wcscmp(L"AB123C", buffer), "buffer wrong, got=%s\n", wine_dbgstr_w(buffer));
got = _vsnwprintf_s_wrapper(buffer, 12, _TRUNCATE, format, 123);
ok( exp == got, "length wrong, expect=%d, got=%d\n", exp, got);
ok( !wcscmp(out7, buffer), "buffer wrong, got=%s\n", wine_dbgstr_w(buffer));
got = _vsnwprintf_s_wrapper(buffer, 7, _TRUNCATE, format, 123);
ok( exp == got, "length wrong, expect=%d, got=%d\n", exp, got);
ok( !wcscmp(out7, buffer), "buffer wrong, got=%s\n", wine_dbgstr_w(buffer));
ret = _vsnwprintf_s_wrapper(buffer, 7, _TRUNCATE, L"AB%uC", 123);
ok( ret == 6, "length wrong, expect=6, got=%d\n", ret);
ok( !wcscmp(L"AB123C", buffer), "buffer wrong, got=%s\n", wine_dbgstr_w(buffer));
/* Not enough room. */
exp = -1;
got = _vsnwprintf_s_wrapper(buffer, 6, _TRUNCATE, format, 123);
ok( exp == got, "length wrong, expect=%d, got=%d\n", exp, got);
ok( !wcscmp(out6, buffer), "buffer wrong, got=%s\n", wine_dbgstr_w(buffer));
ret = _vsnwprintf_s_wrapper(buffer, 6, _TRUNCATE, L"AB%uC", 123);
ok( ret == -1, "length wrong, expect=-1, got=%d\n", ret);
ok( !wcscmp(L"AB123", buffer), "buffer wrong, got=%s\n", wine_dbgstr_w(buffer));
got = _vsnwprintf_s_wrapper(buffer, 2, _TRUNCATE, format, 123);
ok( exp == got, "length wrong, expect=%d, got=%d\n", exp, got);
ok( !wcscmp(out2, buffer), "buffer wrong, got=%s\n", wine_dbgstr_w(buffer));
ret = _vsnwprintf_s_wrapper(buffer, 2, _TRUNCATE, L"AB%uC", 123);
ok( ret == -1, "length wrong, expect=-1, got=%d\n", ret);
ok( !wcscmp(L"A", buffer), "buffer wrong, got=%s\n", wine_dbgstr_w(buffer));
got = _vsnwprintf_s_wrapper(buffer, 1, _TRUNCATE, format, 123);
ok( exp == got, "length wrong, expect=%d, got=%d\n", exp, got);
ok( !wcscmp(out1, buffer), "buffer wrong, got=%s\n", wine_dbgstr_w(buffer));
ret = _vsnwprintf_s_wrapper(buffer, 1, _TRUNCATE, L"AB%uC", 123);
ok( ret == -1, "length wrong, expect=-1, got=%d\n", ret);
ok( !wcscmp(L"", buffer), "buffer wrong, got=%s\n", wine_dbgstr_w(buffer));
}
static int WINAPIV _vsprintf_p_wrapper(char *str, size_t sizeOfBuffer,
......
......@@ -404,15 +404,13 @@ static void test_swscanf( void )
{
wchar_t buffer[100], results[100];
int result, ret;
static const WCHAR formatd[] = {'%','d',0};
const WCHAR format2[] = {'a',0x1234,'%',0x1234,'%','c',0};
WCHAR c;
/* check WEOF */
/* WEOF is an unsigned short -1 but swscanf returns int
so it should be sign-extended */
buffer[0] = 0;
ret = swscanf(buffer, formatd, &result);
ret = swscanf(buffer, L"%d", &result);
/* msvcrt returns 0 but should return -1 (later versions do) */
ok( ret == (short)WEOF || broken(ret == 0),
"swscanf returns %x instead of %x\n", ret, WEOF );
......@@ -425,16 +423,13 @@ static void test_swscanf( void )
buffer[1] = 0x1234;
buffer[2] = 0x1234;
buffer[3] = 'b';
ret = swscanf(buffer, format2, &c);
ret = swscanf(buffer, L"a\x1234%\x1234%c", &c);
ok(ret == 1, "swscanf returned %d\n", ret);
ok(c == 'b', "c = %x\n", c);
}
static void test_swscanf_s(void)
{
static const wchar_t fmt1[] = {'%','c',0};
static const wchar_t fmt2[] = {'%','[','a','-','z',']',0};
int (WINAPIV *pswscanf_s)(const wchar_t*,const wchar_t*,...);
HMODULE hmod = GetModuleHandleA("msvcrt.dll");
wchar_t buf[2], out[2];
......@@ -449,15 +444,15 @@ static void test_swscanf_s(void)
buf[0] = 'a';
buf[1] = '1';
out[1] = 'b';
ret = pswscanf_s(buf, fmt1, out, 1);
ret = pswscanf_s(buf, L"%c", out, 1);
ok(ret == 1, "swscanf_s returned %d\n", ret);
ok(out[0] == 'a', "out[0] = %x\n", out[0]);
ok(out[1] == 'b', "out[1] = %x\n", out[1]);
ret = pswscanf_s(buf, fmt2, out, 1);
ret = pswscanf_s(buf, L"%[a-z]", out, 1);
ok(!ret, "swscanf_s returned %d\n", ret);
ret = pswscanf_s(buf, fmt2, out, 2);
ret = pswscanf_s(buf, L"%[a-z]", out, 2);
ok(ret == 1, "swscanf_s returned %d\n", ret);
ok(out[0] == 'a', "out[0] = %x\n", out[0]);
ok(!out[1], "out[1] = %x\n", out[1]);
......
......@@ -1103,7 +1103,7 @@ static void test__mbscpy_s(void)
static void test_wcscpy_s(void)
{
static const WCHAR szLongText[] = { 'T','h','i','s','A','L','o','n','g','s','t','r','i','n','g',0 };
static const WCHAR szLongText[] = L"ThisALongstring";
static WCHAR szDest[18];
static WCHAR szDestShort[8];
int ret;
......@@ -1209,11 +1209,8 @@ static void test_wcscpy_s(void)
static void test__wcsupr_s(void)
{
static const WCHAR mixedString[] = {'M', 'i', 'X', 'e', 'D', 'l', 'o', 'w',
'e', 'r', 'U', 'P', 'P', 'E', 'R', 0};
static const WCHAR expectedString[] = {'M', 'I', 'X', 'E', 'D', 'L', 'O',
'W', 'E', 'R', 'U', 'P', 'P', 'E',
'R', 0};
static const WCHAR mixedString[] = L"MiXeDlowerUPPER";
static const WCHAR expectedString[] = L"MIXEDLOWERUPPER";
WCHAR testBuffer[2*ARRAY_SIZE(mixedString)];
int ret;
......@@ -1296,11 +1293,8 @@ static void test__wcsupr_s(void)
static void test__wcslwr_s(void)
{
static const WCHAR mixedString[] = {'M', 'i', 'X', 'e', 'D', 'l', 'o', 'w',
'e', 'r', 'U', 'P', 'P', 'E', 'R', 0};
static const WCHAR expectedString[] = {'m', 'i', 'x', 'e', 'd', 'l', 'o',
'w', 'e', 'r', 'u', 'p', 'p', 'e',
'r', 0};
static const WCHAR mixedString[] = L"MiXeDlowerUPPER";
static const WCHAR expectedString[] = L"mixedlowerupper";
WCHAR buffer[2*ARRAY_SIZE(mixedString)];
int ret;
......@@ -2043,12 +2037,10 @@ static void test__strtod(void)
static void test_mbstowcs(void)
{
static const wchar_t wSimple[] = { 't','e','x','t',0 };
static const wchar_t wHiragana[] = { 0x3042,0x3043,0 };
static const wchar_t wEmpty[] = { 0 };
static const wchar_t wSimple[] = L"text";
static const wchar_t wHiragana[] = L"\x3042\x3043";
static const char mSimple[] = "text";
static const char mHiragana[] = { 0x82,0xa0,0x82,0xa1,0 };
static const char mEmpty[] = { 0 };
const wchar_t *pwstr;
wchar_t wOut[6];
......@@ -2077,12 +2069,12 @@ static void test_mbstowcs(void)
ok(!memcmp(wOut, wSimple, 4*sizeof(wchar_t)), "wOut = %s\n", wine_dbgstr_w(wOut));
ok(wOut[4] == '!', "wOut[4] != \'!\'\n");
ret = mbstowcs(NULL, mEmpty, 1);
ret = mbstowcs(NULL, "", 1);
ok(ret == 0, "mbstowcs did not return 0, got %d\n", (int)ret);
ret = mbstowcs(wOut, mEmpty, 1);
ret = mbstowcs(wOut, "", 1);
ok(ret == 0, "mbstowcs did not return 0, got %d\n", (int)ret);
ok(!memcmp(wOut, wEmpty, sizeof(wEmpty)), "wOut = %s\n", wine_dbgstr_w(wOut));
ok(!wOut[0], "wOut = %s\n", wine_dbgstr_w(wOut));
ret = wcstombs(NULL, wSimple, 0);
ok(ret == 4, "wcstombs did not return 4\n");
......@@ -2095,12 +2087,12 @@ static void test_mbstowcs(void)
ok(ret == 2, "wcstombs did not return 2\n");
ok(!memcmp(mOut, mSimple, 5*sizeof(char)), "mOut = %s\n", mOut);
ret = wcstombs(NULL, wEmpty, 1);
ret = wcstombs(NULL, L"", 1);
ok(ret == 0, "wcstombs did not return 0, got %d\n", (int)ret);
ret = wcstombs(mOut, wEmpty, 1);
ret = wcstombs(mOut, L"", 1);
ok(ret == 0, "wcstombs did not return 0, got %d\n", (int)ret);
ok(!memcmp(mOut, mEmpty, sizeof(mEmpty)), "mOut = %s\n", mOut);
ok(!mOut[0], "mOut = %s\n", mOut);
if(!setlocale(LC_ALL, "Japanese_Japan.932")) {
win_skip("Japanese_Japan.932 locale not available\n");
......@@ -2111,9 +2103,9 @@ static void test_mbstowcs(void)
ok(ret == 2, "mbstowcs did not return 2\n");
ok(!memcmp(wOut, wHiragana, sizeof(wHiragana)), "wOut = %s\n", wine_dbgstr_w(wOut));
ret = mbstowcs(wOut, mEmpty, 6);
ret = mbstowcs(wOut, "", 6);
ok(ret == 0, "mbstowcs did not return 0, got %d\n", (int)ret);
ok(!memcmp(wOut, wEmpty, sizeof(wEmpty)), "wOut = %s\n", wine_dbgstr_w(wOut));
ok(!wOut[0], "wOut = %s\n", wine_dbgstr_w(wOut));
errno = 0xdeadbeef;
ret = mbstowcs(wOut, mHiragana+1, 5);
......@@ -2124,9 +2116,9 @@ static void test_mbstowcs(void)
ok(ret == 4, "wcstombs did not return 4\n");
ok(!memcmp(mOut, mHiragana, sizeof(mHiragana)), "mOut = %s\n", mOut);
ret = wcstombs(mOut, wEmpty, 6);
ret = wcstombs(mOut, L"", 6);
ok(ret == 0, "wcstombs did not return 0, got %d\n", (int)ret);
ok(!memcmp(mOut, mEmpty, sizeof(mEmpty)), "mOut = %s\n", mOut);
ok(!mOut[0], "mOut = %s\n", mOut);
if(!pmbstowcs_s || !pwcstombs_s) {
setlocale(LC_ALL, "C");
......@@ -2149,10 +2141,10 @@ static void test_mbstowcs(void)
ok(ret == 3, "mbstowcs_s did not return 3\n");
ok(!memcmp(wOut, wHiragana, sizeof(wHiragana)), "wOut = %s\n", wine_dbgstr_w(wOut));
err = pmbstowcs_s(&ret, wOut, 6, mEmpty, _TRUNCATE);
err = pmbstowcs_s(&ret, wOut, 6, "", _TRUNCATE);
ok(err == 0, "err = %d\n", err);
ok(ret == 1, "mbstowcs_s did not return 1, got %d\n", (int)ret);
ok(!memcmp(wOut, wEmpty, sizeof(wEmpty)), "wOut = %s\n", wine_dbgstr_w(wOut));
ok(!wOut[0], "wOut = %s\n", wine_dbgstr_w(wOut));
err = pmbstowcs_s(&ret, NULL, 0, mHiragana, 1);
ok(err == 0, "err = %d\n", err);
......@@ -2168,10 +2160,10 @@ static void test_mbstowcs(void)
ok(ret == 5, "wcstombs_s did not return 5\n");
ok(!memcmp(mOut, mHiragana, sizeof(mHiragana)), "mOut = %s\n", mOut);
err = pwcstombs_s(&ret, mOut, 6, wEmpty, _TRUNCATE);
err = pwcstombs_s(&ret, mOut, 6, L"", _TRUNCATE);
ok(err == 0, "err = %d\n", err);
ok(ret == 1, "wcstombs_s did not return 1, got %d\n", (int)ret);
ok(!memcmp(mOut, mEmpty, sizeof(mEmpty)), "mOut = %s\n", mOut);
ok(!mOut[0], "mOut = %s\n", mOut);
err = pwcstombs_s(&ret, NULL, 0, wHiragana, 1);
ok(err == 0, "err = %d\n", err);
......@@ -2538,7 +2530,6 @@ static void test__strlwr_s(void)
static void test_wcsncat_s(void)
{
static wchar_t abcW[] = {'a','b','c',0};
int ret;
wchar_t dst[4];
wchar_t src[4];
......@@ -2549,7 +2540,7 @@ static void test_wcsncat_s(void)
return;
}
memcpy(src, abcW, sizeof(abcW));
wcscpy(src, L"abc");
dst[0] = 0;
ret = p_wcsncat_s(NULL, 4, src, 4);
ok(ret == EINVAL, "err = %d\n", ret);
......@@ -2569,7 +2560,7 @@ static void test_wcsncat_s(void)
ok(ret == STRUNCATE, "err = %d\n", ret);
ok(dst[0] == 'a' && dst[1] == 0, "dst is %s\n", wine_dbgstr_w(dst));
memcpy(dst, abcW, sizeof(abcW));
wcscpy(dst, L"abc");
dst[3] = 'd';
ret = p_wcsncat_s(dst, 4, src, 4);
ok(ret == EINVAL, "err = %d\n", ret);
......@@ -3627,7 +3618,7 @@ static void test__strnset_s(void)
static void test__wcsnset_s(void)
{
wchar_t text[] = { 't','e','x','t',0 };
wchar_t text[] = L"text";
int r;
if(!p__wcsnset_s) {
......
......@@ -442,13 +442,12 @@ static void test_wstrdate(void)
{
wchar_t date[16], * result;
int month, day, year, count, len;
wchar_t format[] = { '%','0','2','d','/','%','0','2','d','/','%','0','2','d',0 };
result = _wstrdate(date);
ok(result == date, "Wrong return value\n");
len = wcslen(date);
ok(len == 8, "Wrong length: returned %d, should be 8\n", len);
count = swscanf(date, format, &month, &day, &year);
count = swscanf(date, L"%02d/%02d/%02d", &month, &day, &year);
ok(count == 3, "Wrong format: count = %d, should be 3\n", count);
}
......@@ -456,13 +455,12 @@ static void test_wstrtime(void)
{
wchar_t time[16], * result;
int hour, minute, second, count, len;
wchar_t format[] = { '%','0','2','d',':','%','0','2','d',':','%','0','2','d',0 };
result = _wstrtime(time);
ok(result == time, "Wrong return value\n");
len = wcslen(time);
ok(len == 8, "Wrong length: returned %d, should be 8\n", len);
count = swscanf(time, format, &hour, &minute, &second);
count = swscanf(time, L"%02d:%02d:%02d", &hour, &minute, &second);
ok(count == 3, "Wrong format: count = %d, should be 3\n", count);
}
......@@ -728,8 +726,6 @@ static void test_strftime(void)
{ "mon1", "mon2", "mon3", "mon4", "mon5", "mon6", "mon7", "mon8", "mon9", "mon10", "mon11", "mon12" },
"tam", "tpm"
};
static const wchar_t cW[] = { '%','c',0 };
time_t gmt;
struct tm* gmt_tm;
char buf[256], bufA[256];
......@@ -801,7 +797,7 @@ static void test_strftime(void)
}
retA = p_strftime(bufA, 256, "%c", gmt_tm);
retW = p_wcsftime(bufW, 256, cW, gmt_tm);
retW = p_wcsftime(bufW, 256, L"%c", gmt_tm);
ok(retW == 17, "expected 17, got %ld\n", retW);
ok(retA == retW, "expected %ld, got %ld\n", retA, retW);
buf[0] = 0;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment