summaryrefslogtreecommitdiff
path: root/tests/test_xpath.cpp
diff options
context:
space:
mode:
authorArseny Kapoulkine <arseny.kapoulkine@gmail.com>2014-10-23 07:41:07 +0000
committerArseny Kapoulkine <arseny.kapoulkine@gmail.com>2014-10-23 07:41:07 +0000
commit903db8682a5f14b52adec996584c70ea072619ea (patch)
treeb65c4c8bb68d7d0d77a204ca850c2d85bf7a5a6e /tests/test_xpath.cpp
parentbbd75fda4618dcbef272c8e5432153992c392588 (diff)
tests: Add more tests for better coverage
More tests for out-of-memory and other edge conditions git-svn-id: https://pugixml.googlecode.com/svn/trunk@1075 99668b35-9821-0410-8761-19e4c4f06640
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