summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArseny Kapoulkine <arseny.kapoulkine@gmail.com>2017-10-26 08:36:05 -0700
committerArseny Kapoulkine <arseny.kapoulkine@gmail.com>2017-10-26 08:36:05 -0700
commit0504fa4e90e0024ff612fdfdf740ef7826191ebe (patch)
treeda4011985a9345c943c07ed9a8961e9f6b828393
parent3af93a39d7dddadc13fba978da113aa847509ee5 (diff)
tests: Add more tests for document move
These tests currently fail for compact mode because of ->reserve() failing.
-rw-r--r--tests/test_document.cpp33
1 files changed, 33 insertions, 0 deletions
diff --git a/tests/test_document.cpp b/tests/test_document.cpp
index e6b9081..8b2573b 100644
--- a/tests/test_document.cpp
+++ b/tests/test_document.cpp
@@ -1750,4 +1750,37 @@ TEST_XML(document_move_append_child_zero_alloc, "<node1/><node2/>")
CHECK_NODE(other, STR("<node1/><node2/><node3/>"));
}
+
+#ifndef PUGIXML_COMPACT
+TEST(document_move_empty_zero_alloc)
+{
+ xml_document* docs = new xml_document[32];
+
+ test_runner::_memory_fail_threshold = 1;
+
+ for (int i = 1; i < 32; ++i)
+ docs[i] = std::move(docs[i-1]);
+
+ delete[] docs;
+}
+
+TEST(document_move_repeated_zero_alloc)
+{
+ xml_document* docs = new xml_document[32];
+
+ CHECK(docs[0].load_string(STR("<node><child/></node>")));
+
+ test_runner::_memory_fail_threshold = 1;
+
+ for (int i = 1; i < 32; ++i)
+ docs[i] = std::move(docs[i-1]);
+
+ for (int i = 0; i < 31; ++i)
+ CHECK(!docs[i].first_child());
+
+ CHECK_NODE(docs[31], STR("<node><child/></node>"));
+
+ delete[] docs;
+}
+#endif
#endif