[gxml] Fixed TwDocument.write_document() fo text nodes
- From: Daniel Espinosa Ortiz <despinosa src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gxml] Fixed TwDocument.write_document() fo text nodes
- Date: Sun, 28 Feb 2016 15:43:19 +0000 (UTC)
commit c1e566786bf0f94ddaf764d1de6cb00bbfb2958f
Author: Daniel Espinosa <esodan gmail com>
Date: Sun Feb 28 09:40:22 2016 -0600
Fixed TwDocument.write_document() fo text nodes
gxml/TwDocument.vala | 2 +-
test/GDocumentTest.vala | 24 +++++++++++++++++++++++-
test/gdocument-read.xml | 8 ++++++++
3 files changed, 32 insertions(+), 2 deletions(-)
---
diff --git a/gxml/TwDocument.vala b/gxml/TwDocument.vala
index 5d40bbf..6f0f663 100644
--- a/gxml/TwDocument.vala
+++ b/gxml/TwDocument.vala
@@ -335,7 +335,7 @@ public class GXml.TwDocument : GXml.TwNode, GXml.Document
}
if (n is GXml.Text) {
//GLib.message ("Writting Element's contents");
- size += tw.write_string (node.value);
+ size += tw.write_string (n.value);
if (size > 1500)
tw.flush ();
}
diff --git a/test/GDocumentTest.vala b/test/GDocumentTest.vala
index b5ad0b3..69c54d9 100644
--- a/test/GDocumentTest.vala
+++ b/test/GDocumentTest.vala
@@ -264,7 +264,7 @@ class GDocumentTest : GXmlTest {
//Test.message ("DOC libxml2:"+doc.libxml_to_string ());
} catch { assert_not_reached (); }
});
- Test.add_func ("/gxml/gdocument/to_string", () => {
+ Test.add_func ("/gxml/gdocument/to_string/basic", () => {
try {
GDocument doc = new GDocument.from_string ("<?xml version=\"1.0\"?>
<Sentences><Sentence lang=\"en\">I like the colour blue.</Sentence><Sentence lang=\"de\">Ich liebe die
Tür.</Sentence><Authors><Author><Name>Fred</Name><Email>fweasley hogwarts co
uk</Email></Author><Author><Name>George</Name><Email>gweasley hogwarts co
uk</Email></Author></Authors></Sentences>");
@@ -275,6 +275,28 @@ class GDocumentTest : GXmlTest {
assert (cs1[1] == "<Sentences><Sentence lang=\"en\">I like the colour
blue.</Sentence><Sentence lang=\"de\">Ich liebe die
Tür.</Sentence><Authors><Author><Name>Fred</Name><Email>fweasley hogwarts co
uk</Email></Author><Author><Name>George</Name><Email>gweasley hogwarts co
uk</Email></Author></Authors></Sentences>");
} catch { assert_not_reached (); }
});
+ Test.add_func ("/gxml/gdocument/to_string/extended", () => {
+ try {
+ var d = new GDocument.from_path
(GXmlTestConfig.TEST_DIR+"/gdocument-read.xml");
+ Test.message (d.to_string ());
+ assert (d.root != null);
+ assert (d.root.name == "DataTypeTemplates");
+ Test.message (d.root.children.size.to_string ());
+ assert (d.root.children[0] is GXml.Text);
+ assert (d.root.children[1] is GXml.Element);
+ assert (d.root.children[2] is GXml.Text);
+ assert (d.root.children[2].value == "\n");
+ assert (d.root.children.size == 3);
+ assert (d.root.children[1].name == "DAType");
+ assert (d.root.children[1].children.size == 3);
+ assert (d.root.children[1].children[1].name == "BDA");
+ assert (d.root.children[1].children[1].children.size == 3);
+ assert (d.root.children[1].children[1].children[1].name == "Val");
+ assert (d.root.children[1].children[1].children[1].children.size == 1);
+ assert (d.root.children[1].children[1].children[1].children[0] is GXml.Text);
+ assert (d.root.children[1].children[1].children[1].children[0].value ==
"status_only");
+ } catch { assert_not_reached (); }
+ });
Test.add_func ("/gxml/gdocument/libxml_to_string", () => {
try {
GDocument doc = new GDocument.from_string ("<?xml version=\"1.0\"?>
diff --git a/test/gdocument-read.xml b/test/gdocument-read.xml
new file mode 100644
index 0000000..2bb36e1
--- /dev/null
+++ b/test/gdocument-read.xml
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="utf-8"?>
+<DataTypeTemplates>
+ <DAType id="LLN01ModctlModel" iedType="">
+ <BDA name="ctlModels" bType="Enum" valKind="Set" type="ctlModelsEnum" count="0">
+ <Val>status_only</Val>
+ </BDA>
+ </DAType>
+</DataTypeTemplates>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]