summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorArseny Kapoulkine <arseny.kapoulkine@gmail.com>2015-04-14 19:19:13 -0700
committerArseny Kapoulkine <arseny.kapoulkine@gmail.com>2015-04-14 19:23:36 -0700
commit5158ee903be463c189a80715f92235ceb04871a7 (patch)
tree7819105030100ead1763c6936f3cd946ad24cb50 /tests
parent2badcbb6743ff803c9cd82db77a1d8a50802058f (diff)
Fix xpath_node_set assignment to provide strong exception guarantee
Since the type of the set was updated before assignment, assigning in out-of-memory condition could change the type to not match the content.
Diffstat (limited to 'tests')
-rw-r--r--tests/test_xpath_api.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/tests/test_xpath_api.cpp b/tests/test_xpath_api.cpp
index df078a0..4fc5be3 100644
--- a/tests/test_xpath_api.cpp
+++ b/tests/test_xpath_api.cpp
@@ -381,15 +381,20 @@ TEST_XML(xpath_api_node_set_assign_out_of_memory_preserve, "<node><a/><b/></node
{
xpath_node_set ns = doc.select_nodes(STR("node/*"));
CHECK(ns.size() == 2);
+ CHECK(ns.type() == xpath_node_set::type_sorted);
xpath_node_set nsall = doc.select_nodes(STR("//*"));
+ nsall.sort(true);
CHECK(nsall.size() == 3);
+ CHECK(nsall.type() == xpath_node_set::type_sorted_reverse);
test_runner::_memory_fail_threshold = 1;
CHECK_ALLOC_FAIL(ns = nsall);
- CHECK(ns.size() == 2 && ns[0] == doc.child(STR("node")).child(STR("a")) && ns[1] == doc.child(STR("node")).child(STR("b")));
+ CHECK(ns.size() == 2);
+ CHECK(ns.type() == xpath_node_set::type_sorted);
+ CHECK(ns[0] == doc.child(STR("node")).child(STR("a")) && ns[1] == doc.child(STR("node")).child(STR("b")));
}
TEST_XML(xpath_api_deprecated_select_single_node, "<node><head/><foo id='1'/><foo/><tail/></node>")