summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorArseny Kapoulkine <arseny.kapoulkine@gmail.com>2017-09-25 22:47:10 -0700
committerArseny Kapoulkine <arseny.kapoulkine@gmail.com>2017-09-25 22:47:10 -0700
commit402b967fa95bebbc4786ae755391f0c745717df6 (patch)
tree9f288f4c1f28fa04683f17995ac137e094399c8a /tests
parentfaba4786c077f32ca57d48895c058b6894836cfc (diff)
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.
Diffstat (limited to 'tests')
-rw-r--r--tests/test_document.cpp27
1 files changed, 25 insertions, 2 deletions
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("<node1 attr1=\"value1\"><node2/></node1>"));
@@ -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