diff options
author | Arseny Kapoulkine <arseny.kapoulkine@gmail.com> | 2017-01-30 23:24:20 -0800 |
---|---|---|
committer | Arseny Kapoulkine <arseny.kapoulkine@gmail.com> | 2017-01-30 23:52:32 -0800 |
commit | a1bc15c8d525ff2cac165cc0e5d08b272d79fc33 (patch) | |
tree | a17977f8fc4b5f57ccfddcbc1e3aa2032074346c /tests/test_xpath.cpp | |
parent | f500435cb49c3b532cec562bb63470af0c9e6a31 (diff) |
tests: Add more coverage tests
Expand out of memory coverage during XPath parsing and evaluation and
add some other small tests.
Diffstat (limited to 'tests/test_xpath.cpp')
-rw-r--r-- | tests/test_xpath.cpp | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/tests/test_xpath.cpp b/tests/test_xpath.cpp index 8359f4f..f8a4b15 100644 --- a/tests/test_xpath.cpp +++ b/tests/test_xpath.cpp @@ -439,6 +439,42 @@ TEST_XML(xpath_out_of_memory_evaluate_predicate, "<node><a/><a/><a/><a/><a/><a/> CHECK_ALLOC_FAIL(CHECK(q.evaluate_node_set(doc).empty())); } +TEST_XML(xpath_out_of_memory_evaluate_normalize_space_0, "<node> a b c d e f g h i j k l m n o p q r s t u v w x y z a b c d e f g h i j k l m n o p q r s t u v w x y z a b c d e f g h i j k l m n o p q r s t u v w x y z a b c d e f g h i j k l m n o p q r s t u v w x y z a b c d e f g h i j k l m n o p q r s t u v w x y z a b c d e f g h i j k l m n o p q r s t u v w x y z a b c d e f g h i j k l m n o p q r s t u v w x y z a b c d e f g h i j k l m n o p q r s t u v w x y z a b c d e f g h i j k l m n o p q r s t u v w x y z a b c d e f g h i j k l m n o p q r s t u v w x y z </node>") +{ + test_runner::_memory_fail_threshold = 32768 + 4096 * 2; + + pugi::xpath_query q(STR("concat(normalize-space(), normalize-space(), normalize-space(), normalize-space(), normalize-space(), normalize-space(), normalize-space(), normalize-space())")); + + CHECK_ALLOC_FAIL(CHECK(q.evaluate_string(doc.first_child()).empty())); +} + +TEST_XML(xpath_out_of_memory_evaluate_normalize_space_1, "<node> a b c d e f g h i j k l m n o p q r s t u v w x y z a b c d e f g h i j k l m n o p q r s t u v w x y z a b c d e f g h i j k l m n o p q r s t u v w x y z a b c d e f g h i j k l m n o p q r s t u v w x y z a b c d e f g h i j k l m n o p q r s t u v w x y z a b c d e f g h i j k l m n o p q r s t u v w x y z a b c d e f g h i j k l m n o p q r s t u v w x y z a b c d e f g h i j k l m n o p q r s t u v w x y z a b c d e f g h i j k l m n o p q r s t u v w x y z a b c d e f g h i j k l m n o p q r s t u v w x y z </node>") +{ + test_runner::_memory_fail_threshold = 32768 + 4096 * 2; + + pugi::xpath_query q(STR("concat(normalize-space(node), normalize-space(node), normalize-space(node), normalize-space(node), normalize-space(node), normalize-space(node), normalize-space(node), normalize-space(node))")); + + CHECK_ALLOC_FAIL(CHECK(q.evaluate_string(doc).empty())); +} + +TEST_XML(xpath_out_of_memory_evaluate_translate, "<node> a b c d e f g h i j k l m n o p q r s t u v w x y z a b c d e f g h i j k l m n o p q r s t u v w x y z a b c d e f g h i j k l m n o p q r s t u v w x y z a b c d e f g h i j k l m n o p q r s t u v w x y z a b c d e f g h i j k l m n o p q r s t u v w x y z a b c d e f g h i j k l m n o p q r s t u v w x y z a b c d e f g h i j k l m n o p q r s t u v w x y z a b c d e f g h i j k l m n o p q r s t u v w x y z a b c d e f g h i j k l m n o p q r s t u v w x y z a b c d e f g h i j k l m n o p q r s t u v w x y z </node>") +{ + test_runner::_memory_fail_threshold = 32768 + 4096 * 2; + + pugi::xpath_query q(STR("concat(translate(node, 'a', '\xe9'), translate(node, 'a', '\xe9'), translate(node, 'a', '\xe9'), translate(node, 'a', '\xe9'), translate(node, 'a', '\xe9'), translate(node, 'a', '\xe9'), translate(node, 'a', '\xe9'), translate(node, 'a', '\xe9'))")); + + CHECK_ALLOC_FAIL(CHECK(q.evaluate_string(doc).empty())); +} + +TEST_XML(xpath_out_of_memory_evaluate_translate_table, "<node> a b c d e f g h i j k l m n o p q r s t u v w x y z a b c d e f g h i j k l m n o p q r s t u v w x y z a b c d e f g h i j k l m n o p q r s t u v w x y z a b c d e f g h i j k l m n o p q r s t u v w x y z a b c d e f g h i j k l m n o p q r s t u v w x y z a b c d e f g h i j k l m n o p q r s t u v w x y z a b c d e f g h i j k l m n o p q r s t u v w x y z a b c d e f g h i j k l m n o p q r s t u v w x y z a b c d e f g h i j k l m n o p q r s t u v w x y z a b c d e f g h i j k l m n o p q r s t u v w x y z </node>") +{ + test_runner::_memory_fail_threshold = 32768 + 4096 * 2; + + pugi::xpath_query q(STR("concat(translate(node, 'a', 'A'), translate(node, 'a', 'A'), translate(node, 'a', 'A'), translate(node, 'a', 'A'), translate(node, 'a', 'A'), translate(node, 'a', 'A'), translate(node, 'a', 'A'), translate(node, 'a', 'A'))")); + + CHECK_ALLOC_FAIL(CHECK(q.evaluate_string(doc).empty())); +} + TEST(xpath_memory_concat_massive) { pugi::xml_document doc; |