summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorArseny Kapoulkine <arseny.kapoulkine@gmail.com>2014-11-20 23:39:40 -0800
committerArseny Kapoulkine <arseny.kapoulkine@gmail.com>2014-11-20 23:39:40 -0800
commit125aa55061ccde4ae7351a9a6c7270a15c9e0204 (patch)
tree266a4d0fdd7687630a299da1a8493cacbdbe3ae9 /tests
parenta0dc468170a9f429446feafea48fc73ae348b648 (diff)
Fix node_declaration copying with empty name
node_copy_string relied on the fact that target node had an empty name and value. Normally this is a safe assumption (and a good one to make since it makes copying faster), however it was not checked and there was one case when it did not hold. Since we're reusing the logic for inserting nodes, newly inserted declaration nodes had the name set automatically to xml, which in our case violates the assumption and is counter-productive since we'll override the name right after setting it. For now the best solution is to do the same insertion manually - that results in some code duplication that we can refactor later (same logic is partially shared by _move variants anyway so on a level duplicating is not that bad).
Diffstat (limited to 'tests')
-rw-r--r--tests/test_dom_modify.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/tests/test_dom_modify.cpp b/tests/test_dom_modify.cpp
index 8665af9..7863718 100644
--- a/tests/test_dom_modify.cpp
+++ b/tests/test_dom_modify.cpp
@@ -1426,3 +1426,15 @@ TEST_XML(dom_node_set_deallocate, "<node attr='value'>text</node>")
CHECK_NODE(doc, STR("<:anonymous :anonymous=\"\"></:anonymous>"));
}
+
+TEST(dom_node_copy_declaration_empty_name)
+{
+ xml_document doc1;
+ xml_node decl1 = doc1.append_child(node_declaration);
+ decl1.set_name(STR(""));
+
+ xml_document doc2;
+ xml_node decl2 = doc2.append_copy(decl1);
+
+ CHECK_STRING(decl2.name(), STR(""));
+}