ucrtbase: Add printf %a format tests.
Signed-off-by: Piotr Caban <piotr@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
111e4221ac
commit
e30b853e3f
|
@ -648,6 +648,67 @@ static void test_printf_natural_string(void)
|
|||
ok(!lstrcmpW(wbuffer, wide_out), "buffer wrong, got=%s\n", wine_dbgstr_w(wbuffer));
|
||||
}
|
||||
|
||||
static void test_printf_fp(void)
|
||||
{
|
||||
static const int flags[] = {
|
||||
0,
|
||||
_CRT_INTERNAL_PRINTF_LEGACY_MSVCRT_COMPATIBILITY,
|
||||
_CRT_INTERNAL_PRINTF_LEGACY_THREE_DIGIT_EXPONENTS,
|
||||
_CRT_INTERNAL_PRINTF_LEGACY_MSVCRT_COMPATIBILITY
|
||||
| _CRT_INTERNAL_PRINTF_LEGACY_THREE_DIGIT_EXPONENTS
|
||||
};
|
||||
static const struct {
|
||||
const char *fmt;
|
||||
double d;
|
||||
const char *res[ARRAY_SIZE(flags)];
|
||||
} tests[] = {
|
||||
{ "%a", 0, { "0x0.0000000000000p+0" }},
|
||||
{ "%A", 0, { "0X0.0000000000000P+0" }},
|
||||
{ "%a", 0.5, { "0x1.0000000000000p-1" }},
|
||||
{ "%a", 1, { "0x1.0000000000000p+0" }},
|
||||
{ "%a", 20, { "0x1.4000000000000p+4" }},
|
||||
{ "%a", -1, { "-0x1.0000000000000p+0" }},
|
||||
{ "%a", 0.1, { "0x1.999999999999ap-4" }},
|
||||
{ "%24a", 0.1, { " 0x1.999999999999ap-4" }},
|
||||
{ "%024a", 0.1, { "0x00001.999999999999ap-4" }},
|
||||
{ "%.2a", 0.1, { "0x1.9ap-4" }},
|
||||
{ "%.20a", 0.1, { "0x1.999999999999a0000000p-4" }},
|
||||
{ "%.a", 0.1e-20, { "0x1p-70" }},
|
||||
{ "%a", 0.1e-20, { "0x1.2e3b40a0e9b4fp-70" }},
|
||||
{ "%a", 4.9406564584124654e-324, { "0x0.0000000000001p-1022" }},
|
||||
{ "%.0a", -1.5, { "-0x1p+0" }},
|
||||
{ "%.0a", -0.5, { "-0x1p-1" }},
|
||||
{ "%.0a", 0.5, { "0x1p-1" }},
|
||||
{ "%.0a", 1.5, { "0x1p+0" }},
|
||||
{ "%.0a", 1.99, { "0x2p+0" }},
|
||||
{ "%.0a", 2, { "0x1p+1" }},
|
||||
{ "%.0a", 9.5, { "0x1p+3" }},
|
||||
{ "%.0a", 10.5, { "0x1p+3" }},
|
||||
{ "%#.0a", -1.5, { "-0x1.p+0" }},
|
||||
{ "%#.0a", -0.5, { "-0x1.p-1" }},
|
||||
{ "%#.0a", 0.5, { "0x1.p-1" }},
|
||||
{ "%#.0a", 1.5, { "0x1.p+0" }},
|
||||
};
|
||||
|
||||
const char *res = NULL;
|
||||
char buf[100];
|
||||
int i, j, r;
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(tests); i++)
|
||||
{
|
||||
for (j = 0; j < ARRAY_SIZE(flags); j++)
|
||||
{
|
||||
if (tests[i].res[j]) res = tests[i].res[j];
|
||||
|
||||
r = vsprintf_wrapper(flags[j], buf, sizeof(buf), tests[i].fmt, tests[i].d);
|
||||
ok(r == strlen(res), "%d,%d) r = %d, expected %d\n",
|
||||
i, j, r, strlen(res));
|
||||
ok(!strcmp(buf, res), "%d,%d) buf = %s, expected %s\n",
|
||||
i, j, buf, res);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
START_TEST(printf)
|
||||
{
|
||||
ok(_set_invalid_parameter_handler(test_invalid_parameter_handler) == NULL,
|
||||
|
@ -664,4 +725,5 @@ START_TEST(printf)
|
|||
test_printf_legacy_three_digit_exp();
|
||||
test_printf_c99();
|
||||
test_printf_natural_string();
|
||||
test_printf_fp();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue