Skip to content
Snippets Groups Projects
Commit bd232164 authored by Arseny Kapoulkine's avatar Arseny Kapoulkine
Browse files

tests: Improve XPath test coverage

Add more memory allocation failure tests.
parent a3664ea9
No related branches found
No related tags found
No related merge requests found
...@@ -302,7 +302,23 @@ TEST_XML(xpath_variables_select, "<node attr='1'/><node attr='2'/>") ...@@ -302,7 +302,23 @@ TEST_XML(xpath_variables_select, "<node attr='1'/><node attr='2'/>")
TEST(xpath_variables_empty_name) TEST(xpath_variables_empty_name)
{ {
xpath_variable_set set; xpath_variable_set set;
CHECK(!set.add(STR(""), xpath_type_node_set));
CHECK(!set.add(STR(""), xpath_type_number)); CHECK(!set.add(STR(""), xpath_type_number));
CHECK(!set.add(STR(""), xpath_type_string));
CHECK(!set.add(STR(""), xpath_type_boolean));
}
TEST(xpath_variables_long_name_out_of_memory_add)
{
std::basic_string<char_t> name(1000, 'a');
test_runner::_memory_fail_threshold = 1000;
xpath_variable_set set;
CHECK_ALLOC_FAIL(CHECK(!set.add(name.c_str(), xpath_type_node_set)));
CHECK_ALLOC_FAIL(CHECK(!set.add(name.c_str(), xpath_type_number)));
CHECK_ALLOC_FAIL(CHECK(!set.add(name.c_str(), xpath_type_string)));
CHECK_ALLOC_FAIL(CHECK(!set.add(name.c_str(), xpath_type_boolean)));
} }
TEST_XML(xpath_variables_inside_filter, "<node key='1' value='2'/><node key='2' value='1'/><node key='1' value='1'/>") TEST_XML(xpath_variables_inside_filter, "<node key='1' value='2'/><node key='2' value='1'/><node key='1' value='1'/>")
...@@ -591,4 +607,19 @@ TEST(xpath_variables_copy_big_out_of_memory) ...@@ -591,4 +607,19 @@ TEST(xpath_variables_copy_big_out_of_memory)
CHECK(!copy.get(name)); CHECK(!copy.get(name));
} }
} }
TEST(xpath_variables_copy_big_value_out_of_memory)
{
xpath_variable_set set;
std::basic_string<char_t> var(10000, 'a');
set.set(STR("x"), var.c_str());
test_runner::_memory_fail_threshold = 15000;
xpath_variable_set copy;
CHECK_ALLOC_FAIL(copy = set);
CHECK(!copy.get(STR("x")));
}
#endif #endif
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment