[glib] Improve test coverage



commit ef4ae742cecf696acb0449ab08ad4dac2a91aac2
Author: Matthias Clasen <mclasen redhat com>
Date:   Mon Nov 21 01:53:29 2011 -0500

    Improve test coverage

 glib/tests/test-printf.c |   23 +++++++++++++++++++++++
 1 files changed, 23 insertions(+), 0 deletions(-)
---
diff --git a/glib/tests/test-printf.c b/glib/tests/test-printf.c
index 42f3f7c..7f48b9e 100644
--- a/glib/tests/test-printf.c
+++ b/glib/tests/test-printf.c
@@ -914,6 +914,28 @@ test_64bit2 (void)
 #endif
 }
 
+static gsize
+upper_bound (const gchar *format, ...)
+{
+  va_list args;
+  gsize res;
+
+  va_start (args, format);
+  res = g_printf_string_upper_bound (format, args);
+  va_end (args);
+
+  return res;
+}
+
+static void
+test_upper_bound (void)
+{
+  gsize res;
+
+  res = upper_bound ("bla %s %d: %g\n", "bla", 123, 0.123);
+  g_assert_cmpint (res, ==, 20);
+}
+
 int
 main (int   argc,
       char *argv[])
@@ -940,6 +962,7 @@ main (int   argc,
   g_test_add_func ("/printf/test-64bit", test_64bit2);
 
   g_test_add_func ("/sprintf/test-positional-params", test_positional_params3);
+  g_test_add_func ("/sprintf/upper-bound", test_upper_bound);
 
   return g_test_run();
 }



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]