summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorWill Thompson <will.thompson@collabora.co.uk>2012-11-26 15:45:22 +0000
committerWill Thompson <will.thompson@collabora.co.uk>2012-12-06 17:00:05 +0000
commite49a114960f78c490f9614cc1138e4f862162cde (patch)
treec4e09a065e15176e1b4095a1acdb6991b7e43fca /tests
parent6982dc11dcf44dff4f26f59a33c572c13ba3ba09 (diff)
Add wocky_node_iter_remove()
I find myself wanting this in Gabble's vcard code.
Diffstat (limited to 'tests')
-rw-r--r--tests/wocky-xmpp-node-test.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/tests/wocky-xmpp-node-test.c b/tests/wocky-xmpp-node-test.c
index 3498ff5..4f19fac 100644
--- a/tests/wocky-xmpp-node-test.c
+++ b/tests/wocky-xmpp-node-test.c
@@ -375,6 +375,35 @@ test_node_iteration (void)
}
static void
+test_node_iter_remove (void)
+{
+ WockyNode *top, *child;
+ WockyNodeTree *tree = wocky_node_tree_new ("foo", "wocky:test",
+ '*', &top,
+ '(', "remove-me", ')',
+ '(', "remove-me", ')',
+ '(', "preserve-me", ')',
+ '(', "remove-me", ')',
+ '(', "preserve-me", ')',
+ '(', "remove-me", ')',
+ '(', "remove-me", ')',
+ NULL);
+ WockyNodeIter iter;
+
+ wocky_node_iter_init (&iter, top, "remove-me", NULL);
+ while (wocky_node_iter_next (&iter, NULL))
+ wocky_node_iter_remove (&iter);
+
+ g_assert_cmpuint (g_slist_length (top->children), ==, 2);
+
+ wocky_node_iter_init (&iter, top, NULL, NULL);
+ while (wocky_node_iter_next (&iter, &child))
+ g_assert_cmpstr (child->name, ==, "preserve-me");
+
+ g_object_unref (tree);
+}
+
+static void
test_get_first_child (void)
{
WockyNodeTree *tree = wocky_node_tree_new ("my-elixir", "my:poison",
@@ -421,6 +450,7 @@ main (int argc, char **argv)
g_test_add_func ("/xmpp-node/append-content-n", test_append_content_n);
g_test_add_func ("/xmpp-node/set-attribute-ns", test_set_attribute_ns);
g_test_add_func ("/xmpp-node/node-iterator", test_node_iteration);
+ g_test_add_func ("/xmpp-node/node-iterator-remove", test_node_iter_remove);
g_test_add_func ("/xmpp-node/get-first-child", test_get_first_child);
result = g_test_run ();