tests: Add more tests for document move

These tests currently fail for compact mode because of ->reserve()
failing.
This commit is contained in:
Arseny Kapoulkine 2017-10-26 08:36:05 -07:00
parent 3af93a39d7
commit 0504fa4e90

View File

@ -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