summaryrefslogtreecommitdiff
path: root/tests/test_xpath_api.cpp
diff options
context:
space:
mode:
authorarseny.kapoulkine <arseny.kapoulkine@99668b35-9821-0410-8761-19e4c4f06640>2010-09-14 05:29:16 +0000
committerarseny.kapoulkine <arseny.kapoulkine@99668b35-9821-0410-8761-19e4c4f06640>2010-09-14 05:29:16 +0000
commit521384bd21b6321368b4094677d482698fe5c5a5 (patch)
tree4f0df4dbae8537cdb333eee944f268e03277c9a1 /tests/test_xpath_api.cpp
parent7b1560f4b292090a71cbbc8d3f9cc5a69a19ad09 (diff)
tests: Added XPath out of memory tests
git-svn-id: http://pugixml.googlecode.com/svn/trunk@728 99668b35-9821-0410-8761-19e4c4f06640
Diffstat (limited to 'tests/test_xpath_api.cpp')
-rw-r--r--tests/test_xpath_api.cpp58
1 files changed, 58 insertions, 0 deletions
diff --git a/tests/test_xpath_api.cpp b/tests/test_xpath_api.cpp
index df9b9a6..281e357 100644
--- a/tests/test_xpath_api.cpp
+++ b/tests/test_xpath_api.cpp
@@ -314,6 +314,64 @@ TEST(xpath_api_exception_what)
CHECK(e.what()[0] != 0);
}
}
+
+TEST(xpath_api_node_set_ctor_out_of_memory)
+{
+ test_runner::_memory_fail_threshold = 1;
+
+ xpath_node data[2];
+
+ try
+ {
+ xpath_node_set ns(data, data + 2);
+
+ CHECK_FORCE_FAIL("Expected out of memory exception");
+ }
+ catch (const std::bad_alloc&)
+ {
+ }
+}
+
+TEST(xpath_api_node_set_copy_ctor_out_of_memory)
+{
+ xpath_node data[2];
+ xpath_node_set ns(data, data + 2);
+
+ test_runner::_memory_fail_threshold = 1;
+
+ try
+ {
+ xpath_node_set copy = ns;
+
+ CHECK_FORCE_FAIL("Expected out of memory exception");
+ }
+ catch (const std::bad_alloc&)
+ {
+ }
+}
+
+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);
+
+ xpath_node_set nsall = doc.select_nodes(STR("//*"));
+ CHECK(nsall.size() == 3);
+
+ test_runner::_memory_fail_threshold = 1;
+
+ try
+ {
+ ns = nsall;
+
+ CHECK_FORCE_FAIL("Expected out of memory exception");
+ }
+ catch (const std::bad_alloc&)
+ {
+ }
+
+ CHECK(ns.size() == 2 && ns[0] == doc.child(STR("node")).child(STR("a")) && ns[1] == doc.child(STR("node")).child(STR("b")));
+}
#endif
#endif