[glib] Improve printf test coverage
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib] Improve printf test coverage
- Date: Mon, 23 Aug 2010 04:39:22 +0000 (UTC)
commit fa6926e5d4ff7fc7efde46222ff70f2a75298ac4
Author: Matthias Clasen <mclasen redhat com>
Date: Mon Aug 23 00:37:37 2010 -0400
Improve printf test coverage
glib/tests/printf.c | 21 +++++++++++++++++++++
1 files changed, 21 insertions(+), 0 deletions(-)
---
diff --git a/glib/tests/printf.c b/glib/tests/printf.c
index 55fa483..42f3f7c 100644
--- a/glib/tests/printf.c
+++ b/glib/tests/printf.c
@@ -642,6 +642,25 @@ test_positional_params2 (void)
}
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)
{
gint res;
@@ -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();
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]