summaryrefslogtreecommitdiff
path: root/tests/test_xpath.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test_xpath.cpp')
-rw-r--r--tests/test_xpath.cpp23
1 files changed, 23 insertions, 0 deletions
diff --git a/tests/test_xpath.cpp b/tests/test_xpath.cpp
index 2143376..80115b8 100644
--- a/tests/test_xpath.cpp
+++ b/tests/test_xpath.cpp
@@ -606,4 +606,27 @@ TEST(xpath_sort_crossdoc_different_depth)
CHECK(ns.size() == 2);
CHECK((ns[0] == ns1[0] && ns[1] == ns2[0]) || (ns[0] == ns2[0] && ns[1] == ns1[0]));
}
+
+TEST(xpath_allocate_string_out_of_memory)
+{
+ std::basic_string<char_t> query;
+
+ for (int i = 0; i < 1024; ++i) query += STR("abcdefgh");
+
+ test_runner::_memory_fail_threshold = 8*1024;
+
+#ifdef PUGIXML_NO_EXCEPTIONS
+ CHECK(!xpath_query(query.c_str()));
+#else
+ try
+ {
+ xpath_query q(query.c_str());
+
+ CHECK_FORCE_FAIL("Expected out of memory exception");
+ }
+ catch (const std::bad_alloc&)
+ {
+ }
+#endif
+}
#endif