msvcrt/tests: Add tests for mbstowcs and wcstombs with empty strings.
Signed-off-by: Akihiro Sagawa <sagawa.aki@gmail.com> Signed-off-by: Piotr Caban <piotr@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
d6f36ca18f
commit
82bf4edf36
|
@ -1833,8 +1833,10 @@ static void test_mbstowcs(void)
|
||||||
{
|
{
|
||||||
static const wchar_t wSimple[] = { 't','e','x','t',0 };
|
static const wchar_t wSimple[] = { 't','e','x','t',0 };
|
||||||
static const wchar_t wHiragana[] = { 0x3042,0x3043,0 };
|
static const wchar_t wHiragana[] = { 0x3042,0x3043,0 };
|
||||||
|
static const wchar_t wEmpty[] = { 0 };
|
||||||
static const char mSimple[] = "text";
|
static const char mSimple[] = "text";
|
||||||
static const char mHiragana[] = { 0x82,0xa0,0x82,0xa1,0 };
|
static const char mHiragana[] = { 0x82,0xa0,0x82,0xa1,0 };
|
||||||
|
static const char mEmpty[] = { 0 };
|
||||||
|
|
||||||
const wchar_t *pwstr;
|
const wchar_t *pwstr;
|
||||||
wchar_t wOut[6];
|
wchar_t wOut[6];
|
||||||
|
@ -1863,6 +1865,13 @@ static void test_mbstowcs(void)
|
||||||
ok(!memcmp(wOut, wSimple, 4*sizeof(wchar_t)), "wOut = %s\n", wine_dbgstr_w(wOut));
|
ok(!memcmp(wOut, wSimple, 4*sizeof(wchar_t)), "wOut = %s\n", wine_dbgstr_w(wOut));
|
||||||
ok(wOut[4] == '!', "wOut[4] != \'!\'\n");
|
ok(wOut[4] == '!', "wOut[4] != \'!\'\n");
|
||||||
|
|
||||||
|
ret = mbstowcs(NULL, mEmpty, 1);
|
||||||
|
ok(ret == 0, "mbstowcs did not return 0, got %d\n", (int)ret);
|
||||||
|
|
||||||
|
ret = mbstowcs(wOut, mEmpty, 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));
|
||||||
|
|
||||||
ret = wcstombs(NULL, wSimple, 0);
|
ret = wcstombs(NULL, wSimple, 0);
|
||||||
ok(ret == 4, "wcstombs did not return 4\n");
|
ok(ret == 4, "wcstombs did not return 4\n");
|
||||||
|
|
||||||
|
@ -1874,6 +1883,13 @@ static void test_mbstowcs(void)
|
||||||
ok(ret == 2, "wcstombs did not return 2\n");
|
ok(ret == 2, "wcstombs did not return 2\n");
|
||||||
ok(!memcmp(mOut, mSimple, 5*sizeof(char)), "mOut = %s\n", mOut);
|
ok(!memcmp(mOut, mSimple, 5*sizeof(char)), "mOut = %s\n", mOut);
|
||||||
|
|
||||||
|
ret = wcstombs(NULL, wEmpty, 1);
|
||||||
|
ok(ret == 0, "wcstombs did not return 0, got %d\n", (int)ret);
|
||||||
|
|
||||||
|
ret = wcstombs(mOut, wEmpty, 1);
|
||||||
|
ok(ret == 0, "wcstombs did not return 0, got %d\n", (int)ret);
|
||||||
|
ok(!memcmp(mOut, mEmpty, sizeof(mEmpty)), "mOut = %s\n", mOut);
|
||||||
|
|
||||||
if(!setlocale(LC_ALL, "Japanese_Japan.932")) {
|
if(!setlocale(LC_ALL, "Japanese_Japan.932")) {
|
||||||
win_skip("Japanese_Japan.932 locale not available\n");
|
win_skip("Japanese_Japan.932 locale not available\n");
|
||||||
return;
|
return;
|
||||||
|
@ -1883,10 +1899,18 @@ static void test_mbstowcs(void)
|
||||||
ok(ret == 2, "mbstowcs did not return 2\n");
|
ok(ret == 2, "mbstowcs did not return 2\n");
|
||||||
ok(!memcmp(wOut, wHiragana, sizeof(wHiragana)), "wOut = %s\n", wine_dbgstr_w(wOut));
|
ok(!memcmp(wOut, wHiragana, sizeof(wHiragana)), "wOut = %s\n", wine_dbgstr_w(wOut));
|
||||||
|
|
||||||
|
ret = mbstowcs(wOut, mEmpty, 6);
|
||||||
|
todo_wine 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));
|
||||||
|
|
||||||
ret = wcstombs(mOut, wHiragana, 6);
|
ret = wcstombs(mOut, wHiragana, 6);
|
||||||
ok(ret == 4, "wcstombs did not return 4\n");
|
ok(ret == 4, "wcstombs did not return 4\n");
|
||||||
ok(!memcmp(mOut, mHiragana, sizeof(mHiragana)), "mOut = %s\n", mOut);
|
ok(!memcmp(mOut, mHiragana, sizeof(mHiragana)), "mOut = %s\n", mOut);
|
||||||
|
|
||||||
|
ret = wcstombs(mOut, wEmpty, 6);
|
||||||
|
ok(ret == 0, "wcstombs did not return 0, got %d\n", (int)ret);
|
||||||
|
ok(!memcmp(mOut, mEmpty, sizeof(mEmpty)), "mOut = %s\n", mOut);
|
||||||
|
|
||||||
if(!pmbstowcs_s || !pwcstombs_s) {
|
if(!pmbstowcs_s || !pwcstombs_s) {
|
||||||
setlocale(LC_ALL, "C");
|
setlocale(LC_ALL, "C");
|
||||||
win_skip("mbstowcs_s or wcstombs_s not available\n");
|
win_skip("mbstowcs_s or wcstombs_s not available\n");
|
||||||
|
@ -1903,6 +1927,11 @@ static void test_mbstowcs(void)
|
||||||
ok(ret == 3, "mbstowcs_s did not return 3\n");
|
ok(ret == 3, "mbstowcs_s did not return 3\n");
|
||||||
ok(!memcmp(wOut, wHiragana, sizeof(wHiragana)), "wOut = %s\n", wine_dbgstr_w(wOut));
|
ok(!memcmp(wOut, wHiragana, sizeof(wHiragana)), "wOut = %s\n", wine_dbgstr_w(wOut));
|
||||||
|
|
||||||
|
err = pmbstowcs_s(&ret, wOut, 6, mEmpty, _TRUNCATE);
|
||||||
|
todo_wine ok(err == 0, "err = %d\n", err);
|
||||||
|
todo_wine 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));
|
||||||
|
|
||||||
err = pmbstowcs_s(&ret, NULL, 0, mHiragana, 1);
|
err = pmbstowcs_s(&ret, NULL, 0, mHiragana, 1);
|
||||||
ok(err == 0, "err = %d\n", err);
|
ok(err == 0, "err = %d\n", err);
|
||||||
ok(ret == 3, "mbstowcs_s did not return 3\n");
|
ok(ret == 3, "mbstowcs_s did not return 3\n");
|
||||||
|
@ -1917,6 +1946,11 @@ static void test_mbstowcs(void)
|
||||||
ok(ret == 5, "wcstombs_s did not return 5\n");
|
ok(ret == 5, "wcstombs_s did not return 5\n");
|
||||||
ok(!memcmp(mOut, mHiragana, sizeof(mHiragana)), "mOut = %s\n", mOut);
|
ok(!memcmp(mOut, mHiragana, sizeof(mHiragana)), "mOut = %s\n", mOut);
|
||||||
|
|
||||||
|
err = pwcstombs_s(&ret, mOut, 6, wEmpty, _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);
|
||||||
|
|
||||||
err = pwcstombs_s(&ret, NULL, 0, wHiragana, 1);
|
err = pwcstombs_s(&ret, NULL, 0, wHiragana, 1);
|
||||||
ok(err == 0, "err = %d\n", err);
|
ok(err == 0, "err = %d\n", err);
|
||||||
ok(ret == 5, "wcstombs_s did not return 5\n");
|
ok(ret == 5, "wcstombs_s did not return 5\n");
|
||||||
|
|
Loading…
Reference in New Issue