Commit 465f3cf3 authored by Piotr Caban's avatar Piotr Caban Committed by Alexandre Julliard

msvcrt: Simplify printf tests table.

parent ab77c7bb
......@@ -92,7 +92,6 @@ static void test_sprintf( void )
{
struct {
const char *format;
int r;
const char *out;
enum {
NO_ARG,
......@@ -106,137 +105,137 @@ static void test_sprintf( void )
double arg_d;
const void *arg_ptr;
} tests[] = {
{ "%+#23.15e", 23, "+7.894561230000000e+008", DOUBLE_ARG, 0, 0, 789456123 },
{ "%-#23.15e", 23, "7.894561230000000e+008 ", DOUBLE_ARG, 0, 0, 789456123 },
{ "%#23.15e", 23, " 7.894561230000000e+008", DOUBLE_ARG, 0, 0, 789456123 },
{ "%#1.1g", 7, "8.e+008", DOUBLE_ARG, 0, 0, 789456123 },
{ "%I64d", 11, "-8589934591", ULONGLONG_ARG, 0, ((ULONGLONG)0xffffffff)*0xffffffff },
{ "%+8I64d", 8, " +100", ULONGLONG_ARG, 0, 100 },
{ "%+.8I64d", 9, "+00000100", ULONGLONG_ARG, 0, 100 },
{ "%+10.8I64d", 10, " +00000100", ULONGLONG_ARG, 0, 100 },
{ "%_1I64d", 6, "_1I64d", ULONGLONG_ARG, 0, 100 },
{ "%-1.5I64d", 6, "-00100", ULONGLONG_ARG, 0, -100 },
{ "%5I64d", 5, " 100", ULONGLONG_ARG, 0, 100 },
{ "%5I64d", 5, " -100", ULONGLONG_ARG, 0, -100 },
{ "%-5I64d", 5, "100 ", ULONGLONG_ARG, 0, 100 },
{ "%-5I64d", 5, "-100 ", ULONGLONG_ARG, 0, -100 },
{ "%-.5I64d", 5, "00100", ULONGLONG_ARG, 0, 100 },
{ "%-.5I64d", 6, "-00100", ULONGLONG_ARG, 0, -100 },
{ "%-8.5I64d", 8, "00100 ", ULONGLONG_ARG, 0, 100 },
{ "%-8.5I64d", 8, "-00100 ", ULONGLONG_ARG, 0, -100 },
{ "%05I64d", 5, "00100", ULONGLONG_ARG, 0, 100 },
{ "%05I64d", 5, "-0100", ULONGLONG_ARG, 0, -100 },
{ "% I64d", 4, " 100", ULONGLONG_ARG, 0, 100 },
{ "% I64d", 4, "-100", ULONGLONG_ARG, 0, -100 },
{ "% 5I64d", 5, " 100", ULONGLONG_ARG, 0, 100 },
{ "% 5I64d", 5, " -100", ULONGLONG_ARG, 0, -100 },
{ "% .5I64d", 6, " 00100", ULONGLONG_ARG, 0, 100 },
{ "% .5I64d", 6, "-00100", ULONGLONG_ARG, 0, -100 },
{ "% 8.5I64d", 8, " 00100", ULONGLONG_ARG, 0, 100 },
{ "% 8.5I64d", 8, " -00100", ULONGLONG_ARG, 0, -100 },
{ "%.0I64d", 0, "", ULONGLONG_ARG },
{ "%#+21.18I64x", 21, " 0x00ffffffffffffff9c", ULONGLONG_ARG, 0, -100 },
{ "%#.25I64o", 25, "0001777777777777777777634", ULONGLONG_ARG, 0, -100 },
{ "%#+24.20I64o", 24, " 01777777777777777777634", ULONGLONG_ARG, 0, -100 },
{ "%#+18.21I64X", 23, "0X00000FFFFFFFFFFFFFF9C", ULONGLONG_ARG, 0, -100 },
{ "%#+20.24I64o", 24, "001777777777777777777634", ULONGLONG_ARG, 0, -100 },
{ "%#+25.22I64u", 25, " 0018446744073709551615", ULONGLONG_ARG, 0, -1 },
{ "%#+25.22I64u", 25, " 0018446744073709551615", ULONGLONG_ARG, 0, -1 },
{ "%#+30.25I64u", 30, " 0000018446744073709551615", ULONGLONG_ARG, 0, -1 },
{ "%+#25.22I64d", 25, " -0000000000000000000001", ULONGLONG_ARG, 0, -1 },
{ "%#-8.5I64o", 8, "00144 ", ULONGLONG_ARG, 0, 100 },
{ "%#-+ 08.5I64d", 8, "+00100 ", ULONGLONG_ARG, 0, 100 },
{ "%.80I64d", 80,
{ "%+#23.15e", "+7.894561230000000e+008", DOUBLE_ARG, 0, 0, 789456123 },
{ "%-#23.15e", "7.894561230000000e+008 ", DOUBLE_ARG, 0, 0, 789456123 },
{ "%#23.15e", " 7.894561230000000e+008", DOUBLE_ARG, 0, 0, 789456123 },
{ "%#1.1g", "8.e+008", DOUBLE_ARG, 0, 0, 789456123 },
{ "%I64d", "-8589934591", ULONGLONG_ARG, 0, ((ULONGLONG)0xffffffff)*0xffffffff },
{ "%+8I64d", " +100", ULONGLONG_ARG, 0, 100 },
{ "%+.8I64d", "+00000100", ULONGLONG_ARG, 0, 100 },
{ "%+10.8I64d", " +00000100", ULONGLONG_ARG, 0, 100 },
{ "%_1I64d", "_1I64d", ULONGLONG_ARG, 0, 100 },
{ "%-1.5I64d", "-00100", ULONGLONG_ARG, 0, -100 },
{ "%5I64d", " 100", ULONGLONG_ARG, 0, 100 },
{ "%5I64d", " -100", ULONGLONG_ARG, 0, -100 },
{ "%-5I64d", "100 ", ULONGLONG_ARG, 0, 100 },
{ "%-5I64d", "-100 ", ULONGLONG_ARG, 0, -100 },
{ "%-.5I64d", "00100", ULONGLONG_ARG, 0, 100 },
{ "%-.5I64d", "-00100", ULONGLONG_ARG, 0, -100 },
{ "%-8.5I64d", "00100 ", ULONGLONG_ARG, 0, 100 },
{ "%-8.5I64d", "-00100 ", ULONGLONG_ARG, 0, -100 },
{ "%05I64d", "00100", ULONGLONG_ARG, 0, 100 },
{ "%05I64d", "-0100", ULONGLONG_ARG, 0, -100 },
{ "% I64d", " 100", ULONGLONG_ARG, 0, 100 },
{ "% I64d", "-100", ULONGLONG_ARG, 0, -100 },
{ "% 5I64d", " 100", ULONGLONG_ARG, 0, 100 },
{ "% 5I64d", " -100", ULONGLONG_ARG, 0, -100 },
{ "% .5I64d", " 00100", ULONGLONG_ARG, 0, 100 },
{ "% .5I64d", "-00100", ULONGLONG_ARG, 0, -100 },
{ "% 8.5I64d", " 00100", ULONGLONG_ARG, 0, 100 },
{ "% 8.5I64d", " -00100", ULONGLONG_ARG, 0, -100 },
{ "%.0I64d", "", ULONGLONG_ARG },
{ "%#+21.18I64x", " 0x00ffffffffffffff9c", ULONGLONG_ARG, 0, -100 },
{ "%#.25I64o", "0001777777777777777777634", ULONGLONG_ARG, 0, -100 },
{ "%#+24.20I64o", " 01777777777777777777634", ULONGLONG_ARG, 0, -100 },
{ "%#+18.21I64X", "0X00000FFFFFFFFFFFFFF9C", ULONGLONG_ARG, 0, -100 },
{ "%#+20.24I64o", "001777777777777777777634", ULONGLONG_ARG, 0, -100 },
{ "%#+25.22I64u", " 0018446744073709551615", ULONGLONG_ARG, 0, -1 },
{ "%#+25.22I64u", " 0018446744073709551615", ULONGLONG_ARG, 0, -1 },
{ "%#+30.25I64u", " 0000018446744073709551615", ULONGLONG_ARG, 0, -1 },
{ "%+#25.22I64d", " -0000000000000000000001", ULONGLONG_ARG, 0, -1 },
{ "%#-8.5I64o", "00144 ", ULONGLONG_ARG, 0, 100 },
{ "%#-+ 08.5I64d", "+00100 ", ULONGLONG_ARG, 0, 100 },
{ "%.80I64d",
"00000000000000000000000000000000000000000000000000000000000000000000000000000001",
ULONGLONG_ARG, 0, 1 },
{ "% .80I64d", 81,
{ "% .80I64d",
" 00000000000000000000000000000000000000000000000000000000000000000000000000000001",
ULONGLONG_ARG, 0, 1 },
{ "% .80d", 81,
{ "% .80d",
" 00000000000000000000000000000000000000000000000000000000000000000000000000000001",
INT_ARG, 1 },
{ "%I", 1, "I", INT_ARG, 1 },
{ "%I0d", 3, "I0d", INT_ARG, 1 },
{ "%I64D", 1, "D", ULONGLONG_ARG, 0, -1 },
{ "%zx", 2, "zx", INT_ARG, 1 },
{ "% d", 2, " 1", INT_ARG, 1 },
{ "%+ d", 2, "+1", INT_ARG, 1 },
{ "%S", 4, "wide", PTR_ARG, 0, 0, 0, L"wide" },
{ "%04c", 4, "0001", INT_ARG, '1' },
{ "%-04c", 4, "1 ", INT_ARG, '1' },
{ "%#012x", 12, "0x0000000001", INT_ARG, 1 },
{ "%#012x", 12, "000000000000", INT_ARG, 0 },
{ "%#04.8x", 10, "0x00000001", INT_ARG, 1 },
{ "%#04.8x", 8, "00000000", INT_ARG, 0 },
{ "%#-08.2x", 8, "0x01 ", INT_ARG, 1 },
{ "%#-08.2x", 8, "00 ", INT_ARG, 0 },
{ "%#.0x", 3, "0x1", INT_ARG, 1 },
{ "%#.0x", 0, "", INT_ARG, 0 },
{ "%#08o", 8, "00000001", INT_ARG, 1 },
{ "%#o", 2, "01", INT_ARG, 1 },
{ "%#o", 1, "0", INT_ARG, 0 },
{ "%04s", 4, "0foo", PTR_ARG, 0, 0, 0, "foo" },
{ "%.1s", 1, "f", PTR_ARG, 0, 0, 0, "foo" },
{ "hello", 5, "hello", NO_ARG },
{ "%ws", 4, "wide", PTR_ARG, 0, 0, 0, L"wide" },
{ "%-10ws", 10, "wide ", PTR_ARG, 0, 0, 0, L"wide" },
{ "%10ws", 10, " wide", PTR_ARG, 0, 0, 0, L"wide" },
{ "%#+ -03whlls", 4, "wide", PTR_ARG, 0, 0, 0, L"wide" },
{ "%w0s", 2, "0s", PTR_ARG, 0, 0, 0, L"wide" },
{ "%w-s", 2, "-s", PTR_ARG, 0, 0, 0, L"wide" },
{ "%ls", 4, "wide", PTR_ARG, 0, 0, 0, L"wide" },
{ "%Ls", 8, "not wide", PTR_ARG, 0, 0, 0, "not wide" },
{ "%b", 1, "b", NO_ARG },
{ "%3c", 3, " a", INT_ARG, 'a' },
{ "%3d", 4, "1234", INT_ARG, 1234 },
{ "%3h", 0, "", NO_ARG },
{ "%j%k%m%q%r%t%v%y%z", 9, "jkmqrtvyz", NO_ARG },
{ "%-1d", 1, "2", INT_ARG, 2 },
{ "%2.4f", 6, "8.6000", DOUBLE_ARG, 0, 0, 8.6 },
{ "%0f", 8, "0.600000", DOUBLE_ARG, 0, 0, 0.6 },
{ "%.0f", 1, "1", DOUBLE_ARG, 0, 0, 0.6 },
{ "%2.4e", 11, "8.6000e+000", DOUBLE_ARG, 0, 0, 8.6 },
{ "% 2.4e", 12, " 8.6000e+000", DOUBLE_ARG, 0, 0, 8.6 },
{ "% 014.4e", 14, " 008.6000e+000", DOUBLE_ARG, 0, 0, 8.6 },
{ "% 2.4e", 12, "-8.6000e+000", DOUBLE_ARG, 0, 0, -8.6 },
{ "%+2.4e", 12, "+8.6000e+000", DOUBLE_ARG, 0, 0, 8.6 },
{ "%2.4g", 3, "8.6", DOUBLE_ARG, 0, 0, 8.6 },
{ "%-i", 2, "-1", INT_ARG, -1 },
{ "%-i", 1, "1", INT_ARG, 1 },
{ "%+i", 2, "+1", INT_ARG, 1 },
{ "%o", 2, "12", INT_ARG, 10 },
{ "%s", 6, "(null)", PTR_ARG, 0, 0, 0, NULL },
{ "%s", 4, "%%%%", PTR_ARG, 0, 0, 0, "%%%%" },
{ "%u", 10, "4294967295", INT_ARG, -1 },
{ "%w", 0, "", INT_ARG, -1 },
{ "%h", 0, "", INT_ARG, -1 },
{ "%z", 1, "z", INT_ARG, -1 },
{ "%j", 1, "j", INT_ARG, -1 },
{ "%F", 0, "", INT_ARG, -1 },
{ "%N", 0, "", INT_ARG, -1 },
{ "%H", 1, "H", INT_ARG, -1 },
{ "x%cx", 3, "xXx", INT_ARG, 0x100+'X' },
{ "%%0", 2, "%0", NO_ARG },
{ "%hx", 4, "2345", INT_ARG, 0x12345 },
{ "%hhx", 3, "123", INT_ARG, 0x123 },
{ "%hhx", 4, "2345", INT_ARG, 0x12345 },
{ "%lf", 9, "-1.#IND00", DOUBLE_ARG, 0, 0, IND },
{ "%lf", 8, "1.#QNAN0", DOUBLE_ARG, 0, 0, NAN },
{ "%lf", 8, "1.#INF00", DOUBLE_ARG, 0, 0, INFINITY },
{ "%le", 14, "-1.#IND00e+000", DOUBLE_ARG, 0, 0, IND },
{ "%le", 13, "1.#QNAN0e+000", DOUBLE_ARG, 0, 0, NAN },
{ "%le", 13, "1.#INF00e+000", DOUBLE_ARG, 0, 0, INFINITY },
{ "%lg", 7, "-1.#IND", DOUBLE_ARG, 0, 0, IND },
{ "%lg", 7, "1.#QNAN", DOUBLE_ARG, 0, 0, NAN },
{ "%lg", 6, "1.#INF", DOUBLE_ARG, 0, 0, INFINITY },
{ "%010.2lf", 10, "-000001.#J", DOUBLE_ARG, 0, 0, IND },
{ "%010.2lf", 10, "0000001.#R", DOUBLE_ARG, 0, 0, NAN },
{ "%010.2lf", 10, "0000001.#J", DOUBLE_ARG, 0, 0, INFINITY },
{ "%c", 1, "a", INT_ARG, 'a' },
{ "%c", 1, "\x82", INT_ARG, 0xa082 },
{ "%C", 1, "a", INT_ARG, 'a' },
{ "%C", 0, "", INT_ARG, 0x3042 },
{ "a%Cb", 2, "ab", INT_ARG, 0x3042 },
{ "%I", "I", INT_ARG, 1 },
{ "%I0d", "I0d", INT_ARG, 1 },
{ "%I64D", "D", ULONGLONG_ARG, 0, -1 },
{ "%zx", "zx", INT_ARG, 1 },
{ "% d", " 1", INT_ARG, 1 },
{ "%+ d", "+1", INT_ARG, 1 },
{ "%S", "wide", PTR_ARG, 0, 0, 0, L"wide" },
{ "%04c", "0001", INT_ARG, '1' },
{ "%-04c", "1 ", INT_ARG, '1' },
{ "%#012x", "0x0000000001", INT_ARG, 1 },
{ "%#012x", "000000000000", INT_ARG, 0 },
{ "%#04.8x", "0x00000001", INT_ARG, 1 },
{ "%#04.8x", "00000000", INT_ARG, 0 },
{ "%#-08.2x", "0x01 ", INT_ARG, 1 },
{ "%#-08.2x", "00 ", INT_ARG, 0 },
{ "%#.0x", "0x1", INT_ARG, 1 },
{ "%#.0x", "", INT_ARG, 0 },
{ "%#08o", "00000001", INT_ARG, 1 },
{ "%#o", "01", INT_ARG, 1 },
{ "%#o", "0", INT_ARG, 0 },
{ "%04s", "0foo", PTR_ARG, 0, 0, 0, "foo" },
{ "%.1s", "f", PTR_ARG, 0, 0, 0, "foo" },
{ "hello", "hello", NO_ARG },
{ "%ws", "wide", PTR_ARG, 0, 0, 0, L"wide" },
{ "%-10ws", "wide ", PTR_ARG, 0, 0, 0, L"wide" },
{ "%10ws", " wide", PTR_ARG, 0, 0, 0, L"wide" },
{ "%#+ -03whlls", "wide", PTR_ARG, 0, 0, 0, L"wide" },
{ "%w0s", "0s", PTR_ARG, 0, 0, 0, L"wide" },
{ "%w-s", "-s", PTR_ARG, 0, 0, 0, L"wide" },
{ "%ls", "wide", PTR_ARG, 0, 0, 0, L"wide" },
{ "%Ls", "not wide", PTR_ARG, 0, 0, 0, "not wide" },
{ "%b", "b", NO_ARG },
{ "%3c", " a", INT_ARG, 'a' },
{ "%3d", "1234", INT_ARG, 1234 },
{ "%3h", "", NO_ARG },
{ "%j%k%m%q%r%t%v%y%z", "jkmqrtvyz", NO_ARG },
{ "%-1d", "2", INT_ARG, 2 },
{ "%2.4f", "8.6000", DOUBLE_ARG, 0, 0, 8.6 },
{ "%0f", "0.600000", DOUBLE_ARG, 0, 0, 0.6 },
{ "%.0f", "1", DOUBLE_ARG, 0, 0, 0.6 },
{ "%2.4e", "8.6000e+000", DOUBLE_ARG, 0, 0, 8.6 },
{ "% 2.4e", " 8.6000e+000", DOUBLE_ARG, 0, 0, 8.6 },
{ "% 014.4e", " 008.6000e+000", DOUBLE_ARG, 0, 0, 8.6 },
{ "% 2.4e", "-8.6000e+000", DOUBLE_ARG, 0, 0, -8.6 },
{ "%+2.4e", "+8.6000e+000", DOUBLE_ARG, 0, 0, 8.6 },
{ "%2.4g", "8.6", DOUBLE_ARG, 0, 0, 8.6 },
{ "%-i", "-1", INT_ARG, -1 },
{ "%-i", "1", INT_ARG, 1 },
{ "%+i", "+1", INT_ARG, 1 },
{ "%o", "12", INT_ARG, 10 },
{ "%s", "(null)", PTR_ARG, 0, 0, 0, NULL },
{ "%s", "%%%%", PTR_ARG, 0, 0, 0, "%%%%" },
{ "%u", "4294967295", INT_ARG, -1 },
{ "%w", "", INT_ARG, -1 },
{ "%h", "", INT_ARG, -1 },
{ "%z", "z", INT_ARG, -1 },
{ "%j", "j", INT_ARG, -1 },
{ "%F", "", INT_ARG, -1 },
{ "%N", "", INT_ARG, -1 },
{ "%H", "H", INT_ARG, -1 },
{ "x%cx", "xXx", INT_ARG, 0x100+'X' },
{ "%%0", "%0", NO_ARG },
{ "%hx", "2345", INT_ARG, 0x12345 },
{ "%hhx", "123", INT_ARG, 0x123 },
{ "%hhx", "2345", INT_ARG, 0x12345 },
{ "%lf", "-1.#IND00", DOUBLE_ARG, 0, 0, IND },
{ "%lf", "1.#QNAN0", DOUBLE_ARG, 0, 0, NAN },
{ "%lf", "1.#INF00", DOUBLE_ARG, 0, 0, INFINITY },
{ "%le", "-1.#IND00e+000", DOUBLE_ARG, 0, 0, IND },
{ "%le", "1.#QNAN0e+000", DOUBLE_ARG, 0, 0, NAN },
{ "%le", "1.#INF00e+000", DOUBLE_ARG, 0, 0, INFINITY },
{ "%lg", "-1.#IND", DOUBLE_ARG, 0, 0, IND },
{ "%lg", "1.#QNAN", DOUBLE_ARG, 0, 0, NAN },
{ "%lg", "1.#INF", DOUBLE_ARG, 0, 0, INFINITY },
{ "%010.2lf", "-000001.#J", DOUBLE_ARG, 0, 0, IND },
{ "%010.2lf", "0000001.#R", DOUBLE_ARG, 0, 0, NAN },
{ "%010.2lf", "0000001.#J", DOUBLE_ARG, 0, 0, INFINITY },
{ "%c", "a", INT_ARG, 'a' },
{ "%c", "\x82", INT_ARG, 0xa082 },
{ "%C", "a", INT_ARG, 'a' },
{ "%C", "", INT_ARG, 0x3042 },
{ "a%Cb", "ab", INT_ARG, 0x3042 },
};
char buffer[100];
......@@ -261,7 +260,7 @@ static void test_sprintf( void )
break;
}
ok(r == tests[i].r, "%d) r = %d, expected %d\n", i, r, tests[i].r);
ok(r == strlen(tests[i].out), "%d) r = %d, expected %d\n", i, r, strlen(tests[i].out));
ok(!strcmp(buffer, tests[i].out), "%d) buffer = \"%s\"\n", i, buffer);
}
......
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