summaryrefslogtreecommitdiff
path: root/tests/test_xpath_functions.cpp
diff options
context:
space:
mode:
authorArseny Kapoulkine <arseny.kapoulkine@gmail.com>2017-06-22 22:11:43 -0700
committerArseny Kapoulkine <arseny.kapoulkine@gmail.com>2017-06-22 22:11:43 -0700
commit3870217381529093b9e8752056ca6784b8d03bc6 (patch)
treefa0d485f37f6c039bab549fab47bc904dfce4070 /tests/test_xpath_functions.cpp
parent5867aff943f80f19649c7e6495765af0cb5719b2 (diff)
tests: Add more XPath out of memory tests
This fixes missing coverage in translate_table_generate and xpath_node_set_raw::append.
Diffstat (limited to 'tests/test_xpath_functions.cpp')
-rw-r--r--tests/test_xpath_functions.cpp24
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/test_xpath_functions.cpp b/tests/test_xpath_functions.cpp
index 43e334e..dee999c 100644
--- a/tests/test_xpath_functions.cpp
+++ b/tests/test_xpath_functions.cpp
@@ -815,4 +815,28 @@ TEST(xpath_unknown_functions)
CHECK_XPATH_FAIL(query);
}
}
+
+TEST(xpath_string_translate_table_out_of_memory)
+{
+ xml_node c;
+
+ // our goal is to generate translate table OOM without generating query OOM
+ std::basic_string<char_t> query = STR("concat(");
+
+ size_t count = 20;
+
+ for (size_t i = 0; i < count; ++i)
+ {
+ if (i != 0) query += STR(",");
+ query += STR("translate('a','a','A')");
+ }
+
+ query += STR(")");
+
+ std::basic_string<char_t> result(count, 'A');
+
+ test_runner::_memory_fail_threshold = 5000;
+
+ CHECK_ALLOC_FAIL(CHECK_XPATH_STRING(c, query.c_str(), result.c_str()));
+}
#endif