summaryrefslogtreecommitdiff
path: root/tests/test_xpath_parse.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test_xpath_parse.cpp')
-rw-r--r--tests/test_xpath_parse.cpp25
1 files changed, 24 insertions, 1 deletions
diff --git a/tests/test_xpath_parse.cpp b/tests/test_xpath_parse.cpp
index c39481b..9b28478 100644
--- a/tests/test_xpath_parse.cpp
+++ b/tests/test_xpath_parse.cpp
@@ -274,7 +274,7 @@ TEST_XML(xpath_parse_absolute, "<div><s/></div>")
TEST(xpath_parse_out_of_memory_first_page)
{
- test_runner::_memory_fail_threshold = 1;
+ test_runner::_memory_fail_threshold = 128;
CHECK_ALLOC_FAIL(CHECK_XPATH_FAIL(STR("1")));
}
@@ -335,6 +335,29 @@ TEST(xpath_parse_error_propagation)
}
}
+TEST(xpath_parse_oom_propagation)
+{
+ const char_t* query_base = STR("(//foo[count(. | @*)] | /foo | /foo/bar//more/ancestor-or-self::foobar | /text() | a[1 + 2 * 3 div (1+0) mod 2]//b[1]/c | a[$x])[true()]");
+
+ xpath_variable_set vars;
+ vars.set(STR("x"), 1.0);
+
+ test_runner::_memory_fail_threshold = 4096 + 128;
+
+ {
+ xpath_query q(query_base, &vars);
+ CHECK(q);
+ }
+
+ for (size_t i = 3200; i < 4200; ++i)
+ {
+ std::basic_string<char_t> literal(i, 'a');
+ std::basic_string<char_t> query = STR("processing-instruction('") + literal + STR("') | ") + query_base;
+
+ CHECK_ALLOC_FAIL(CHECK_XPATH_FAIL(query.c_str()));
+ }
+}
+
TEST_XML(xpath_parse_location_path, "<node><child/></node>")
{
CHECK_XPATH_NODESET(doc, STR("/node")) % 2;