[gxml] * add a test for escaped characters
- From: Richard Hans Schwarting <rschwart src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gxml] * add a test for escaped characters
- Date: Fri, 30 Sep 2011 00:26:56 +0000 (UTC)
commit eb0ad461381c30c4ef856d3430ade2b2465978a3
Author: Richard Schwarting <aquarichy gmail com>
Date: Thu Sep 29 20:04:00 2011 -0400
* add a test for escaped characters
gxml/Element.vala | 4 +---
test/ElementTest.vala | 6 ++++++
2 files changed, 7 insertions(+), 3 deletions(-)
---
diff --git a/gxml/Element.vala b/gxml/Element.vala
index 71f0d00..13ff31b 100644
--- a/gxml/Element.vala
+++ b/gxml/Element.vala
@@ -484,10 +484,8 @@ namespace GXml.Dom {
// TODO: add test
public string content {
owned get {
- //return this.child_nodes.to_string (true);
+ // <> in with stringifying child nodes would get escaped, here the content is preserved
return base.node->get_content ();
- // TODO: what's the difference between this and stringifying
- // the child nodes?
}
set {
// TODO: check impact on existing child nodes; they will be
diff --git a/test/ElementTest.vala b/test/ElementTest.vala
index 49555ef..13538e3 100644
--- a/test/ElementTest.vala
+++ b/test/ElementTest.vala
@@ -442,6 +442,12 @@ class ElementTest : GXmlTest {
Element elem = get_elem_new_doc ("country");
elem.append_child (elem.owner_document.create_text_node ("New Zealand"));
assert (elem.to_string () == "<country>New Zealand</country>");
+
+ // during stringification, we don't want to confuse XML <> with text <>
+ Element elem2 = get_elem_new_doc ("messy");
+ elem2.append_child (elem.owner_document.create_text_node ("<<>>"));
+ assert (elem2.to_string () == "<messy>&lt;<>&gt;</messy>");
+
// TODO: want to test with format on and off
} catch (GXml.Dom.DomError e) {
GLib.warning ("%s", e.message);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]