From 2ad95c717b2bc0fb33eeb4fef655ea86be30a8a6 Mon Sep 17 00:00:00 2001 From: Richard Schwarting Date: Tue, 22 Oct 2013 02:52:51 -0400 Subject: [PATCH] DocumentTest.vala, ElementTest.vala: make changes to account for the switch from a GLib.HashTable attributes to a GXml.NamedNodeMap; we should consider supporting GLibHashTable methods for backwards compatibility though (lookup, size, etc) --- test/DocumentTest.vala | 6 +++--- test/ElementTest.vala | 21 +++++++++++---------- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/test/DocumentTest.vala b/test/DocumentTest.vala index e3da9ce5..71cbda70 100644 --- a/test/DocumentTest.vala +++ b/test/DocumentTest.vala @@ -395,9 +395,9 @@ class DocumentTest : GXmlTest { if (node.node_type != 3) GLib.stdout.printf ("<%s", node.node_name); - HashTable attrs = node.attributes; - foreach (string key in attrs.get_keys ()) { - Attr attr = attrs.lookup (key); + NamedAttrMap attrs = node.attributes; + for (int i = 0; i < attrs.length; i++) { + Attr attr = attrs.item (i); GLib.stdout.printf (" %s=\"%s\"", attr.name, attr.value); } diff --git a/test/ElementTest.vala b/test/ElementTest.vala index 588090d0..8c53fac9 100644 --- a/test/ElementTest.vala +++ b/test/ElementTest.vala @@ -101,7 +101,7 @@ class ElementTest : GXmlTest { assert (node.local_name == "Potion"); }); Test.add_func ("/gxml/element/attributes", () => { - HashTable attributes; + NamedAttrMap attributes; Document doc; Element elem; @@ -112,25 +112,26 @@ class ElementTest : GXmlTest { attributes = elem.attributes; assert (attributes != null); - assert (attributes.size () == 0); + assert (attributes.length == 0); elem.set_attribute ("alley", "Diagon"); elem.set_attribute ("train", "Hogwarts Express"); assert (attributes == elem.attributes); - assert (attributes.size () == 2); - assert (attributes.lookup ("alley").value == "Diagon"); - assert (attributes.lookup ("train").value == "Hogwarts Express"); + assert (attributes.length == 2); + assert (attributes.get_named_item ("alley").value == "Diagon"); + assert (attributes.get_named_item ("train").value == "Hogwarts Express"); - Attr attr = doc.create_attribute ("owl"); + Attr attr; + attr = doc.create_attribute ("owl"); attr.value = "Hedwig"; - attributes.insert ("owl", attr); + attributes.set_named_item (attr); - assert (attributes.size () == 3); + assert (attributes.length == 3); assert (elem.get_attribute ("owl") == "Hedwig"); - attributes.remove ("alley"); + attributes.remove_named_item ("alley"); assert (elem.get_attribute ("alley") == ""); }); /* by accessing .attributes, the element is marked as @@ -139,7 +140,7 @@ class ElementTest : GXmlTest { * HashTable, and the document will have to re-sync * before stringifying (or saving)*/ Test.add_func ("/gxml/element/syncing_of_dirty_elements", () => { - HashTable attrs; + NamedAttrMap attrs; string str; Document doc = new Document.from_string (""); -- GitLab