[glib] Improve test coverage
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib] Improve test coverage
- Date: Sat, 15 Oct 2011 04:09:55 +0000 (UTC)
commit 8bc8cd7aa05900dcfad943b91c3720caa7b611ee
Author: Matthias Clasen <mclasen redhat com>
Date: Sat Oct 15 00:09:20 2011 -0400
Improve test coverage
glib/tests/Makefile.am | 3 ++
glib/tests/mainloop.c | 58 ++++++++++++++++++++++++++++++++++++++++++++++-
glib/tests/strfuncs.c | 15 ++++++++++++
3 files changed, 74 insertions(+), 2 deletions(-)
---
diff --git a/glib/tests/Makefile.am b/glib/tests/Makefile.am
index 6c9c7bc..23514d6 100644
--- a/glib/tests/Makefile.am
+++ b/glib/tests/Makefile.am
@@ -215,6 +215,9 @@ slice_LDADD = $(progs_ldadd)
TEST_PROGS += hook
hook_LDADD = $(progs_ldadd)
+TEST_PROGS += mainloop
+mainloop_LDADD = $(progs_ldadd)
+
TEST_PROGS += private
private_LDADD = $(progs_ldadd)
diff --git a/glib/tests/mainloop.c b/glib/tests/mainloop.c
index 14034a9..de780b7 100644
--- a/glib/tests/mainloop.c
+++ b/glib/tests/mainloop.c
@@ -23,8 +23,61 @@
#include <glib.h>
static void
-test_unref (void)
+test_maincontext_basic (void)
{
+ GMainContext *ctx;
+ GSource *source;
+ GSourceFuncs funcs;
+ guint id;
+
+ ctx = g_main_context_new ();
+
+ g_assert (!g_main_context_pending (ctx));
+ g_assert (!g_main_context_iteration (ctx, FALSE));
+
+ source = g_source_new (&funcs, sizeof (GSource));
+ g_assert (g_source_get_priority (source) == G_PRIORITY_DEFAULT);
+
+ g_assert (!g_source_get_can_recurse (source));
+ g_assert (g_source_get_name (source) == NULL);
+
+ g_source_set_can_recurse (source, TRUE);
+ g_source_set_name (source, "d");
+
+ g_assert (g_source_get_can_recurse (source));
+ g_assert_cmpstr (g_source_get_name (source), ==, "d");
+
+ g_assert (g_main_context_find_source_by_user_data (ctx, NULL) == NULL);
+ g_assert (g_main_context_find_source_by_funcs_user_data (ctx, &funcs, NULL) == NULL);
+
+ id = g_source_attach (source, ctx);
+ g_assert_cmpint (g_source_get_id (source), ==, id);
+ g_assert (g_main_context_find_source_by_id (ctx, id) == source);
+
+ g_source_set_priority (source, G_PRIORITY_HIGH);
+ g_assert (g_source_get_priority (source) == G_PRIORITY_HIGH);
+
+ g_main_context_unref (ctx);
+}
+
+static void
+test_mainloop_basic (void)
+{
+ GMainLoop *loop;
+ GMainContext *ctx;
+
+ loop = g_main_loop_new (NULL, FALSE);
+
+ g_assert (!g_main_loop_is_running (loop));
+
+ g_main_loop_ref (loop);
+
+ ctx = g_main_loop_get_context (loop);
+ g_assert (ctx == g_main_context_default ());
+
+ g_main_loop_unref (loop);
+
+ g_assert (g_main_depth () == 0);
}
int
@@ -32,7 +85,8 @@ main (int argc, char *argv[])
{
g_test_init (&argc, &argv, NULL);
- g_test_add_func ("/mainloop/unref", test_unref);
+ g_test_add_func ("/maincontext/basic", test_maincontext_basic);
+ g_test_add_func ("/mainloop/basic", test_mainloop_basic);
return g_test_run ();
}
diff --git a/glib/tests/strfuncs.c b/glib/tests/strfuncs.c
index d4bac4a..3c51e2e 100644
--- a/glib/tests/strfuncs.c
+++ b/glib/tests/strfuncs.c
@@ -19,6 +19,8 @@
* if advised of the possibility of such damage.
*/
+#define GLIB_DISABLE_DEPRECATION_WARNINGS
+
#include <ctype.h>
#include <errno.h>
#include <locale.h>
@@ -1269,6 +1271,18 @@ test_strsignal (void)
}
}
+static void
+test_strup (void)
+{
+ gchar *s;
+
+ s = g_strdup ("lower");
+ g_assert_cmpstr (g_strup (s), ==, "LOWER");
+ g_assert_cmpstr (g_strdown (s), ==, "lower");
+ g_assert (g_strcasecmp ("lower", "LOWER") == 0);
+ g_free (s);
+}
+
int
main (int argc,
char *argv[])
@@ -1301,6 +1315,7 @@ main (int argc,
g_test_add_func ("/strfuncs/strip-context", test_strip_context);
g_test_add_func ("/strfuncs/strerror", test_strerror);
g_test_add_func ("/strfuncs/strsignal", test_strsignal);
+ g_test_add_func ("/strfuncs/strup", test_strup);
return g_test_run();
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]