summaryrefslogtreecommitdiff
path: root/tests/test_dom_modify.cpp
diff options
context:
space:
mode:
authorarseny.kapoulkine <arseny.kapoulkine@99668b35-9821-0410-8761-19e4c4f06640>2010-09-26 19:01:36 +0000
committerarseny.kapoulkine <arseny.kapoulkine@99668b35-9821-0410-8761-19e4c4f06640>2010-09-26 19:01:36 +0000
commit630be2edb3110b9627718bd7b735348e4940fdd4 (patch)
treeb8bba89deaed121beac5df936463323fd27097fe /tests/test_dom_modify.cpp
parent605ab1b145968dd9ab2a07536493cbeac9311ccc (diff)
tests: Added node_doctype and parse_doctype tests
git-svn-id: http://pugixml.googlecode.com/svn/trunk@757 99668b35-9821-0410-8761-19e4c4f06640
Diffstat (limited to 'tests/test_dom_modify.cpp')
-rw-r--r--tests/test_dom_modify.cpp65
1 files changed, 62 insertions, 3 deletions
diff --git a/tests/test_dom_modify.cpp b/tests/test_dom_modify.cpp
index 46b0543..eefda58 100644
--- a/tests/test_dom_modify.cpp
+++ b/tests/test_dom_modify.cpp
@@ -514,13 +514,16 @@ TEST_XML(dom_node_copy_crossdoc, "<node/>")
CHECK_NODE(newdoc, STR("<node />"));
}
-TEST_XML_FLAGS(dom_node_copy_types, "<?xml version='1.0'?><root><?pi value?><!--comment--><node id='1'>pcdata<![CDATA[cdata]]></node></root>", parse_default | parse_pi | parse_comments | parse_declaration)
+TEST_XML_FLAGS(dom_node_copy_types, "<?xml version='1.0'?><!DOCTYPE id><root><?pi value?><!--comment--><node id='1'>pcdata<![CDATA[cdata]]></node></root>", parse_full)
{
doc.append_copy(doc.child(STR("root")));
- CHECK_NODE(doc, STR("<?xml version=\"1.0\"?><root><?pi value?><!--comment--><node id=\"1\">pcdata<![CDATA[cdata]]></node></root><root><?pi value?><!--comment--><node id=\"1\">pcdata<![CDATA[cdata]]></node></root>"));
+ CHECK_NODE(doc, STR("<?xml version=\"1.0\"?><!DOCTYPE id><root><?pi value?><!--comment--><node id=\"1\">pcdata<![CDATA[cdata]]></node></root><root><?pi value?><!--comment--><node id=\"1\">pcdata<![CDATA[cdata]]></node></root>"));
doc.insert_copy_before(doc.first_child(), doc.first_child());
- CHECK_NODE(doc, STR("<?xml version=\"1.0\"?><?xml version=\"1.0\"?><root><?pi value?><!--comment--><node id=\"1\">pcdata<![CDATA[cdata]]></node></root><root><?pi value?><!--comment--><node id=\"1\">pcdata<![CDATA[cdata]]></node></root>"));
+ CHECK_NODE(doc, STR("<?xml version=\"1.0\"?><?xml version=\"1.0\"?><!DOCTYPE id><root><?pi value?><!--comment--><node id=\"1\">pcdata<![CDATA[cdata]]></node></root><root><?pi value?><!--comment--><node id=\"1\">pcdata<![CDATA[cdata]]></node></root>"));
+
+ doc.insert_copy_after(doc.first_child().next_sibling().next_sibling(), doc.first_child());
+ CHECK_NODE(doc, STR("<?xml version=\"1.0\"?><!DOCTYPE id><?xml version=\"1.0\"?><!DOCTYPE id><root><?pi value?><!--comment--><node id=\"1\">pcdata<![CDATA[cdata]]></node></root><root><?pi value?><!--comment--><node id=\"1\">pcdata<![CDATA[cdata]]></node></root>"));
}
TEST_XML(dom_attr_assign_large_number, "<node attr1='' attr2='' />")
@@ -549,6 +552,16 @@ TEST(dom_node_declaration_name)
CHECK_NODE(doc, STR("<?xml?><?xml?><?xml?>"));
}
+TEST(dom_node_declaration_attributes)
+{
+ xml_document doc;
+ xml_node node = doc.append_child(node_declaration);
+ node.append_attribute(STR("version")) = STR("1.0");
+ node.append_attribute(STR("encoding")) = STR("utf-8");
+
+ CHECK_NODE(doc, STR("<?xml version=\"1.0\" encoding=\"utf-8\"?>"));
+}
+
TEST(dom_node_declaration_top_level)
{
xml_document doc;
@@ -677,3 +690,49 @@ TEST(dom_node_memory_limit)
CHECK(doc.remove_child(doc.first_child()));
}
}
+
+TEST(dom_node_doctype_top_level)
+{
+ xml_document doc;
+ doc.append_child().set_name(STR("node"));
+
+ xml_node node = doc.first_child();
+ node.append_child(node_pcdata).set_value(STR("text"));
+
+ CHECK(node.insert_child_before(node_doctype, node.first_child()) == xml_node());
+ CHECK(node.insert_child_after(node_doctype, node.first_child()) == xml_node());
+ CHECK(node.append_child(node_doctype) == xml_node());
+
+ CHECK_NODE(doc, STR("<node>text</node>"));
+
+ CHECK(doc.insert_child_before(node_doctype, node));
+ CHECK(doc.insert_child_after(node_doctype, node));
+ CHECK(doc.append_child(node_doctype));
+
+ CHECK_NODE(doc, STR("<!DOCTYPE><node>text</node><!DOCTYPE><!DOCTYPE>"));
+}
+
+TEST(dom_node_doctype_copy)
+{
+ xml_document doc;
+ doc.append_child(node_doctype);
+
+ doc.append_child().set_name(STR("node"));
+
+ doc.last_child().append_copy(doc.first_child());
+
+ CHECK_NODE(doc, STR("<!DOCTYPE><node />"));
+}
+
+TEST(dom_node_doctype_value)
+{
+ xml_document doc;
+ xml_node node = doc.append_child(node_doctype);
+
+ CHECK(node.type() == node_doctype);
+ CHECK_STRING(node.value(), STR(""));
+ CHECK_NODE(node, STR("<!DOCTYPE>"));
+
+ CHECK(node.set_value(STR("id [ foo ]")));
+ CHECK_NODE(node, STR("<!DOCTYPE id [ foo ]>"));
+}