summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorArseny Kapoulkine <arseny.kapoulkine@gmail.com>2017-09-25 19:18:50 -0700
committerArseny Kapoulkine <arseny.kapoulkine@gmail.com>2017-09-25 21:37:56 -0700
commit6eb7519dbae860a789e972c63cd6e83685d961a0 (patch)
treef1915f70b3c932f6098b73d0657b1271e95a8bd5 /tests
parenta567f12d76b97c6336b4e3ef34767440182eade6 (diff)
tests: Add basic move tests
These just verify that move ctor/assignment operator work as expected in simple cases - there are a number of ways in which the internal structure can be incorrect...
Diffstat (limited to 'tests')
-rw-r--r--tests/test_document.cpp31
1 files changed, 31 insertions, 0 deletions
diff --git a/tests/test_document.cpp b/tests/test_document.cpp
index ecbe6dc..43d3906 100644
--- a/tests/test_document.cpp
+++ b/tests/test_document.cpp
@@ -1621,3 +1621,34 @@ TEST(document_convert_out_of_memory)
delete[] files[j].data;
}
}
+
+#ifdef PUGIXML_HAS_MOVE
+TEST_XML(document_move_ctor, "<node1/><node2/>")
+{
+ xml_document other = std::move(doc);
+
+ CHECK(doc.first_child().empty());
+
+ CHECK_STRING(other.first_child().name(), STR("node1"));
+ CHECK(other.first_child().parent() == other);
+
+ CHECK_STRING(other.last_child().name(), STR("node2"));
+ CHECK(other.last_child().parent() == other);
+}
+
+TEST_XML(document_move_assign, "<node1/><node2/>")
+{
+ xml_document other;
+ CHECK(other.load_string(STR("<node3/>")));
+
+ other = std::move(doc);
+
+ CHECK(doc.first_child().empty());
+
+ CHECK_STRING(other.first_child().name(), STR("node1"));
+ CHECK(other.first_child().parent() == other);
+
+ CHECK_STRING(other.last_child().name(), STR("node2"));
+ CHECK(other.last_child().parent() == other);
+}
+#endif