[gxml/newattr: 13/13] DocumentTest.vala, ElementTest.vala: make changes to account for the switch from a GLib.HashTable at



commit 2ad95c717b2bc0fb33eeb4fef655ea86be30a8a6
Author: Richard Schwarting <aquarichy gmail com>
Date:   Tue Oct 22 02:52:51 2013 -0400

    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 e3da9ce..71cbda7 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<string, Attr> 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 588090d..8c53fac 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<string,Attr> 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<string,GXml.Attr> attrs;
+                               NamedAttrMap attrs;
                                string str;
 
                                Document doc = new Document.from_string ("<?xml version='1.0' 
encoding='UTF-8'?><entry><link rel='http://schemas.google.com/contacts/2008/rel#photo'/></entry>");


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]