[glib] Improve test coverage of glist.c
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib] Improve test coverage of glist.c
- Date: Mon, 6 Jun 2011 04:33:04 +0000 (UTC)
commit 70c082127f12e1758087ae9dd61cfbbd5f397830
Author: Matthias Clasen <mclasen redhat com>
Date: Mon Jun 6 00:31:24 2011 -0400
Improve test coverage of glist.c
glib/tests/list.c | 43 +++++++++++++++++++++++++++++++++++++++++++
1 files changed, 43 insertions(+), 0 deletions(-)
---
diff --git a/glib/tests/list.c b/glib/tests/list.c
index 084f7ea..cf65f93 100644
--- a/glib/tests/list.c
+++ b/glib/tests/list.c
@@ -356,6 +356,47 @@ test_free_full (void)
g_slice_free (ListItem, three);
}
+static void
+test_list_copy (void)
+{
+ GList *l, *l2;
+ GList *u, *v;
+
+ l = NULL;
+ l = g_list_append (l, GINT_TO_POINTER (1));
+ l = g_list_append (l, GINT_TO_POINTER (2));
+ l = g_list_append (l, GINT_TO_POINTER (3));
+
+ l2 = g_list_copy (l);
+
+ for (u = l, v = l2; u && v; u = u->next, v = v->next)
+ {
+ g_assert (u->data == v->data);
+ }
+
+ g_list_free (l);
+ g_list_free (l2);
+}
+
+static void
+test_delete_link (void)
+{
+ GList *l, *l2;
+
+ l = NULL;
+ l = g_list_append (l, GINT_TO_POINTER (1));
+ l = g_list_append (l, GINT_TO_POINTER (2));
+ l = g_list_append (l, GINT_TO_POINTER (3));
+
+ l2 = l->next;
+
+ l = g_list_delete_link (l, l2);
+ g_assert (l->data == GINT_TO_POINTER (1));
+ g_assert (l->next->data == GINT_TO_POINTER (3));
+
+ g_list_free (l);
+}
+
int
main (int argc, char *argv[])
{
@@ -379,6 +420,8 @@ main (int argc, char *argv[])
g_test_add_func ("/list/first-last", test_list_first_last);
g_test_add_func ("/list/insert", test_list_insert);
g_test_add_func ("/list/free-full", test_free_full);
+ g_test_add_func ("/list/copy", test_list_copy);
+ g_test_add_func ("/list/delete-link", test_delete_link);
return g_test_run ();
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]