From 0504fa4e90e0024ff612fdfdf740ef7826191ebe Mon Sep 17 00:00:00 2001 From: Arseny Kapoulkine Date: Thu, 26 Oct 2017 08:36:05 -0700 Subject: tests: Add more tests for document move These tests currently fail for compact mode because of ->reserve() failing. --- tests/test_document.cpp | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) 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, "") CHECK_NODE(other, STR("")); } + +#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(""))); + + 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("")); + + delete[] docs; +} +#endif #endif -- cgit v1.2.3