user32/tests: Add wsprintfW %S conversion tests.
Signed-off-by: Akihiro Sagawa <sagawa.aki@gmail.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
6c692dc1af
commit
c8f46313e4
|
@ -123,7 +123,25 @@ static void wsprintfWTest(void)
|
|||
static const WCHAR fmt_010ld[] = {'%','0','1','0','l','d','\0'};
|
||||
static const WCHAR res_010ld[] = {'-','0','0','0','0','0','0','0','0','1', '\0'};
|
||||
static const WCHAR fmt_I64x[] = {'%','I','6','4','x',0};
|
||||
static const WCHAR fmt_dot3S[] = {'%','.','3','S',0};
|
||||
static const WCHAR fmt__4S[] = {'%','-','4','S',0};
|
||||
static const WCHAR stars[] = {'*', 0x2606, 0x2605, 0};
|
||||
static const WCHAR nul_spc[] = {'*', 0, ' ', ' ', 0};
|
||||
WCHAR def_spc[] = {'*','?', 0x2605, ' ', 0};
|
||||
WCHAR buf[25], fmt[25], res[25];
|
||||
char stars_mb[8], partial00[8], partialFF[8];
|
||||
const struct {
|
||||
const char *input;
|
||||
const WCHAR *fmt;
|
||||
const WCHAR *str;
|
||||
int rc;
|
||||
}
|
||||
testcase[] = {
|
||||
{ stars_mb, fmt_dot3S, stars, 3 },
|
||||
{ partial00, fmt__4S, nul_spc, 4 },
|
||||
{ partialFF, fmt__4S, def_spc, 4 },
|
||||
};
|
||||
CPINFOEXW cpinfoex;
|
||||
unsigned int i;
|
||||
int rc;
|
||||
|
||||
|
@ -150,6 +168,36 @@ static void wsprintfWTest(void)
|
|||
ok(rc == lstrlenW(res), "%u: wsprintfW length failure: rc=%d\n", i, rc);
|
||||
ok(!lstrcmpW(buf, res), "%u: wrong result [%s]\n", i, wine_dbgstr_w(buf));
|
||||
}
|
||||
|
||||
if (!GetCPInfoExW(CP_ACP, 0, &cpinfoex) || cpinfoex.MaxCharSize <= 1)
|
||||
{
|
||||
skip("Multi-byte wsprintfW test isn't available for the current codepage\n");
|
||||
return;
|
||||
}
|
||||
def_spc[1] = cpinfoex.UnicodeDefaultChar;
|
||||
|
||||
rc = WideCharToMultiByte(CP_ACP, 0, stars, -1, stars_mb, sizeof(stars_mb), NULL, NULL);
|
||||
ok(rc == 6, "expected 6, got %d\n", rc);
|
||||
strcpy(partial00, stars_mb);
|
||||
partial00[2] = '\0';
|
||||
strcpy(partialFF, stars_mb);
|
||||
partialFF[2] = 0xff;
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(testcase); i++)
|
||||
{
|
||||
memset(buf, 0x11, sizeof(buf));
|
||||
rc = wsprintfW(buf, testcase[i].fmt, testcase[i].input);
|
||||
|
||||
todo_wine_if (i == 2)
|
||||
ok(rc == testcase[i].rc,
|
||||
"%u: expected %d, got %d\n",
|
||||
i, testcase[i].rc, rc);
|
||||
|
||||
todo_wine ok(!memcmp(buf, testcase[i].str, (testcase[i].rc + 1) * sizeof(WCHAR)),
|
||||
"%u: expected %s, got %s\n", i,
|
||||
wine_dbgstr_wn(testcase[i].str, testcase[i].rc + 1),
|
||||
wine_dbgstr_wn(buf, rc + 1));
|
||||
}
|
||||
}
|
||||
|
||||
/* Test if the CharUpper / CharLower functions return true 16 bit results,
|
||||
|
|
Loading…
Reference in New Issue