Improve printf test coverage

This commit is contained in:
Matthias Clasen 2010-08-23 00:37:37 -04:00
parent 7d970fadbc
commit fa6926e5d4

View File

@ -641,6 +641,25 @@ test_positional_params2 (void)
g_test_trap_assert_stdout ("*abcabc*");
}
static void
test_positional_params3 (void)
{
gchar buf[128];
gint res;
res = g_sprintf (buf, "%2$c %1$c", 'b', 'a');
g_assert_cmpint (res, ==, 3);
g_assert_cmpstr (buf, ==, "a b");
res = g_sprintf (buf, "%1$*2$.*3$s", "abc", 5, 2);
g_assert_cmpint (res, ==, 5);
g_assert_cmpstr (buf, ==, " ab");
res = g_sprintf (buf, "%1$s%1$s", "abc");
g_assert_cmpint (res, ==, 6);
g_assert_cmpstr (buf, ==, "abcabc");
}
static void
test_percent2 (void)
{
@ -920,5 +939,7 @@ main (int argc,
g_test_add_func ("/printf/test-positional-params", test_positional_params2);
g_test_add_func ("/printf/test-64bit", test_64bit2);
g_test_add_func ("/sprintf/test-positional-params", test_positional_params3);
return g_test_run();
}