From 402b967fa95bebbc4786ae755391f0c745717df6 Mon Sep 17 00:00:00 2001 From: Arseny Kapoulkine Date: Mon, 25 Sep 2017 22:47:10 -0700 Subject: tests: Add more move tests Make sure we have coverage for empty documents and for large documents that trigger compact_shared_parent != root for some pages. --- tests/test_document.cpp | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/test_document.cpp b/tests/test_document.cpp index c2f55a7..fa0dc8d 100644 --- a/tests/test_document.cpp +++ b/tests/test_document.cpp @@ -1691,10 +1691,10 @@ TEST(document_move_append_child) xml_document other = std::move(*doc); delete doc; - for (int i = 0; i < 1000; ++i) + for (int i = 0; i < 3000; ++i) other.child(STR("node1")).append_child(STR("node")); - for (int i = 0; i < 1000; ++i) + for (int i = 0; i < 3000; ++i) other.child(STR("node1")).remove_child(other.child(STR("node1")).last_child()); CHECK_NODE(other, STR("")); @@ -1703,4 +1703,27 @@ TEST(document_move_append_child) CHECK(!other.first_child()); } + +TEST(document_move_empty) +{ + xml_document* doc = new xml_document(); + xml_document other = std::move(*doc); + delete doc; +} + +TEST(document_move_large) +{ + xml_document* doc = new xml_document(); + + for (int i = 0; i < 3000; ++i) + doc->append_child(STR("node")); + + xml_document other = std::move(*doc); + delete doc; + + for (int i = 0; i < 3000; ++i) + CHECK(other.remove_child(other.first_child())); + + CHECK(!other.first_child()); +} #endif -- cgit v1.2.3