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...
This commit is contained in:
parent
a567f12d76
commit
6eb7519dba
1 changed files with 31 additions and 0 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue