tests: Add more XPath out of memory tests
This fixes missing coverage in translate_table_generate and xpath_node_set_raw::append.
This commit is contained in:
parent
5867aff943
commit
3870217381
@ -815,4 +815,28 @@ TEST(xpath_unknown_functions)
|
|||||||
CHECK_XPATH_FAIL(query);
|
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
|
#endif
|
||||||
|
|||||||
@ -624,4 +624,22 @@ TEST(xpath_variables_copy_big_value_out_of_memory)
|
|||||||
|
|
||||||
CHECK(!copy.get(STR("x")));
|
CHECK(!copy.get(STR("x")));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_XML(xpath_variables_evaluate_node_set_out_of_memory, "<node />")
|
||||||
|
{
|
||||||
|
for (size_t i = 0; i < 600; ++i)
|
||||||
|
doc.append_child(STR("node"));
|
||||||
|
|
||||||
|
xpath_node_set ns = doc.select_nodes(STR("node"));
|
||||||
|
CHECK(ns.size() == 601);
|
||||||
|
|
||||||
|
xpath_variable_set set;
|
||||||
|
set.set(STR("nodes"), ns);
|
||||||
|
|
||||||
|
xpath_query q("$nodes", &set);
|
||||||
|
|
||||||
|
test_runner::_memory_fail_threshold = 1;
|
||||||
|
|
||||||
|
CHECK_ALLOC_FAIL(q.evaluate_node_set(xml_node()).empty());
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user