[gxml] * build out the Attr namespace tests. They currently FAIL because while GXml keeps a map between li



commit fd19ac8b7c107d80a8490121bea26ba1f036d980
Author: Richard Schwarting <aquarichy gmail com>
Date:   Tue Aug 9 03:57:18 2011 +0200

    * build out the Attr namespace tests.  They currently FAIL because while GXml keeps a map between libxml2 Xml.Nodes to GXML XNodes, we don't do that for attrs right now, since before namespace support, we could really get away with creating string-based attrs. Nuts\!

 test/AttrTest.vala |   57 +++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 56 insertions(+), 1 deletions(-)
---
diff --git a/test/AttrTest.vala b/test/AttrTest.vala
index 6fae3a2..f67e886 100644
--- a/test/AttrTest.vala
+++ b/test/AttrTest.vala
@@ -3,11 +3,66 @@ using GXml.Dom;
 
 class AttrTest : GXmlTest {
 	public static void add_tests () {
+		Test.add_func ("/gxml/element/namespace_uri", () => {
+				try {
+					Document doc = new Document.from_string ("<Wands xmlns:wands=\"http://mom.co.uk/wands\";><Wand price=\"43.56\" wands:core=\"dragon heart cord\" wands:shell=\"oak\"/></Wands>");
+					XNode root = doc.document_element;
+					Element node = (Element)root.child_nodes.item (0);
+
+					Attr core = node.get_attribute_node ("core");
+					Attr shell = node.get_attribute_node ("shell");
+					Attr price = node.get_attribute_node ("price");
+					
+					assert (core.namespace_uri == "http://mom.co.uk/wands";);
+					assert (shell.namespace_uri == "http://mom.co.uk/wands";);
+					assert (price.namespace_uri == null);
+				} catch (GXml.Dom.DomError e) {
+					GLib.warning ("%s", e.message);
+					assert (false);
+				}
+			});
+		Test.add_func ("/gxml/element/prefix", () => {
+				try {
+					Document doc = new Document.from_string ("<Wands xmlns:wands=\"http://mom.co.uk/wands\";><Wand price=\"43.56\" wands:core=\"dragon heart cord\" wands:shell=\"oak\"/></Wands>");
+					XNode root = doc.document_element;
+					Element node = (Element)root.child_nodes.item (0);
+
+					Attr core = node.get_attribute_node ("core");
+					Attr shell = node.get_attribute_node ("shell");
+					Attr price = node.get_attribute_node ("price");
+					
+					assert (core.prefix == "wands");
+					assert (shell.prefix == "wands");
+					assert (price.prefix == null);
+				} catch (GXml.Dom.DomError e) {
+					GLib.warning ("%s", e.message);
+					assert (false);
+				}
+			});
+		Test.add_func ("/gxml/element/local_name", () => {
+				try {
+					Document doc = new Document.from_string ("<Wands xmlns:wands=\"http://mom.co.uk/wands\";><Wand price=\"43.56\" wands:core=\"dragon heart cord\" wands:shell=\"oak\"/></Wands>");
+					XNode root = doc.document_element;
+					Element node = (Element)root.child_nodes.item (0);
+
+					Attr core = node.get_attribute_node ("core");
+					Attr shell = node.get_attribute_node ("shell");
+					Attr price = node.get_attribute_node ("price");
+					
+					assert (core.local_name == "core");
+					assert (shell.local_name == "shell");
+					assert (price.local_name == "price");
+				} catch (GXml.Dom.DomError e) {
+					GLib.warning ("%s", e.message);
+					assert (false);
+				}
+			});
+
 		Test.add_func ("/gxml/attribute/node_name", () => {
 				try {
 					Document doc = get_doc ();
 					Attr attr = get_attr ("broomSeries", "Nimbus", doc);
-
+					
 					assert (attr.node_name == "broomSeries");
 				} catch (GXml.Dom.DomError e) {
 					GLib.warning ("%s", e.message);



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