[glib] utils: Improve test coverage



commit 2a1ea40920b3a65420e085c3828da9e406e7afa0
Author: Matthias Clasen <mclasen redhat com>
Date:   Sat Apr 7 11:32:36 2012 -0400

    utils: Improve test coverage
    
    Add a test for some of our gettext variants.

 glib/tests/utils.c |   19 +++++++++++++++++++
 1 files changed, 19 insertions(+), 0 deletions(-)
---
diff --git a/glib/tests/utils.c b/glib/tests/utils.c
index 721a813..1c53be3 100644
--- a/glib/tests/utils.c
+++ b/glib/tests/utils.c
@@ -26,6 +26,7 @@
 #include "glib.h"
 
 #include <stdlib.h>
+#include <string.h>
 #include <stdarg.h>
 
 static gboolean
@@ -322,6 +323,23 @@ test_basename (void)
   g_assert_cmpstr (b, ==, "down.sh");
 }
 
+extern const gchar *glib_pgettext (const gchar *msgidctxt, gsize msgidoffset);
+
+static void
+test_gettext (void)
+{
+  const gchar *am0, *am1, *am2, *am3;
+
+  am0 = glib_pgettext ("GDateTime\004AM", strlen ("GDateTime") + 1);
+  am1 = g_dpgettext ("glib20", "GDateTime\004AM", strlen ("GDateTime") + 1);
+  am2 = g_dpgettext ("glib20", "GDateTime|AM", 0);
+  am3 = g_dpgettext2 ("glib20", "GDateTime", "AM");
+
+  g_assert_cmpstr (am0, ==, am1);
+  g_assert_cmpstr (am1, ==, am2);
+  g_assert_cmpstr (am2, ==, am3);
+}
+
 int
 main (int   argc,
       char *argv[])
@@ -347,6 +365,7 @@ main (int   argc,
   g_test_add_func ("/utils/debug", test_debug);
   g_test_add_func ("/utils/codeset", test_codeset);
   g_test_add_func ("/utils/basename", test_basename);
+  g_test_add_func ("/utils/gettext", test_gettext);
 
   return g_test_run();
 }



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