summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2011-06-19 01:04:48 -0400
committerMatthias Clasen <mclasen@redhat.com>2011-06-19 01:04:48 -0400
commite1d4e06ab3dc9be6e239eb27f2f168e277ae273c (patch)
treef020921a03af23124847cc528390ef00a8956050
parented3ac87afe51de67b631abf5f8dc50622b141a8b (diff)
logging: improve test coverage
-rw-r--r--glib/tests/logging.c39
1 files changed, 39 insertions, 0 deletions
diff --git a/glib/tests/logging.c b/glib/tests/logging.c
index ae7054d7f..0c83b80fe 100644
--- a/glib/tests/logging.c
+++ b/glib/tests/logging.c
@@ -132,6 +132,43 @@ test_fatal_log_mask (void)
g_log_set_fatal_mask ("bu", flags);
}
+static gint my_print_count = 0;
+static void
+my_print_handler (const gchar *text)
+{
+ my_print_count++;
+}
+
+static void
+test_print_handler (void)
+{
+ GPrintFunc old_print_handler;
+
+ old_print_handler = g_set_print_handler (my_print_handler);
+ g_assert (old_print_handler == NULL);
+
+ my_print_count = 0;
+ g_print ("bu ba");
+ g_assert_cmpint (my_print_count, ==, 1);
+
+ g_set_print_handler (NULL);
+}
+
+static void
+test_printerr_handler (void)
+{
+ GPrintFunc old_printerr_handler;
+
+ old_printerr_handler = g_set_printerr_handler (my_print_handler);
+ g_assert (old_printerr_handler == NULL);
+
+ my_print_count = 0;
+ g_printerr ("bu ba");
+ g_assert_cmpint (my_print_count, ==, 1);
+
+ g_set_printerr_handler (NULL);
+}
+
int
main (int argc, char *argv[])
{
@@ -141,6 +178,8 @@ main (int argc, char *argv[])
g_test_add_func ("/logging/warnings", test_warnings);
g_test_add_func ("/logging/fatal-log-mask", test_fatal_log_mask);
g_test_add_func ("/logging/set-handler", test_set_handler);
+ g_test_add_func ("/logging/print-handler", test_print_handler);
+ g_test_add_func ("/logging/printerr-handler", test_printerr_handler);
return g_test_run ();
}