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

msvcrt/tests: Use wide-char string literals.

parent b0a302cc
......@@ -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;
......
......@@ -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