From 8aa8e11ba6473ae35844930ac4319c647a8d9679 Mon Sep 17 00:00:00 2001 From: Arseny Kapoulkine Date: Sun, 29 Jan 2017 21:53:40 -0800 Subject: tests: Add query out of memory test --- tests/test_xpath_api.cpp | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'tests/test_xpath_api.cpp') diff --git a/tests/test_xpath_api.cpp b/tests/test_xpath_api.cpp index c1a4968..6b32b68 100644 --- a/tests/test_xpath_api.cpp +++ b/tests/test_xpath_api.cpp @@ -418,6 +418,13 @@ TEST(xpath_api_empty) CHECK(!q.evaluate_boolean(c)); } +TEST(xpath_api_query_out_of_memory) +{ + test_runner::_memory_fail_threshold = 1; + + CHECK_ALLOC_FAIL(xpath_query q(STR("node"))); +} + #ifdef PUGIXML_HAS_MOVE TEST_XML(xpath_api_nodeset_move_ctor, "") { -- cgit v1.2.3 From 02cee98492233f4ae91f025fc38f9df8b4bc0efe Mon Sep 17 00:00:00 2001 From: Arseny Kapoulkine Date: Mon, 30 Jan 2017 21:36:05 -0800 Subject: tests: Add more tests for branch coverage gcov -b surfaced many lines with partial coverage, where branch is only ever taken or not taken, or one of the expressions in a complex conditional is always either true or false. This change adds a series of tests (mostly focusing on XPath) to reduce the number of partially covered lines. --- tests/test_xpath_api.cpp | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) (limited to 'tests/test_xpath_api.cpp') diff --git a/tests/test_xpath_api.cpp b/tests/test_xpath_api.cpp index 6b32b68..1e7f924 100644 --- a/tests/test_xpath_api.cpp +++ b/tests/test_xpath_api.cpp @@ -107,6 +107,7 @@ TEST_XML(xpath_api_nodeset_accessors, "") TEST_XML(xpath_api_nodeset_copy, "") { + xpath_node_set empty; xpath_node_set set = doc.select_nodes(STR("node/foo")); xpath_node_set copy1 = set; @@ -132,7 +133,7 @@ TEST_XML(xpath_api_nodeset_copy, "") xpath_node_set copy5; copy5 = set; - copy5 = xpath_node_set(); + copy5 = empty; CHECK(copy5.size() == 0); } @@ -418,13 +419,6 @@ TEST(xpath_api_empty) CHECK(!q.evaluate_boolean(c)); } -TEST(xpath_api_query_out_of_memory) -{ - test_runner::_memory_fail_threshold = 1; - - CHECK_ALLOC_FAIL(xpath_query q(STR("node"))); -} - #ifdef PUGIXML_HAS_MOVE TEST_XML(xpath_api_nodeset_move_ctor, "") { -- cgit v1.2.3 From a1bc15c8d525ff2cac165cc0e5d08b272d79fc33 Mon Sep 17 00:00:00 2001 From: Arseny Kapoulkine Date: Mon, 30 Jan 2017 23:24:20 -0800 Subject: tests: Add more coverage tests Expand out of memory coverage during XPath parsing and evaluation and add some other small tests. --- tests/test_xpath_api.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'tests/test_xpath_api.cpp') diff --git a/tests/test_xpath_api.cpp b/tests/test_xpath_api.cpp index 1e7f924..3f05e13 100644 --- a/tests/test_xpath_api.cpp +++ b/tests/test_xpath_api.cpp @@ -573,6 +573,18 @@ TEST(xpath_api_nodeset_move_assign_empty) CHECK(move.type() == xpath_node_set::type_sorted); } +TEST_XML(xpath_api_nodeset_move_assign_self, "") +{ + xpath_node_set set = doc.select_nodes(STR("node/bar")); + + CHECK(set.size() == 1); + CHECK(set.type() == xpath_node_set::type_sorted); + + test_runner::_memory_fail_threshold = 1; + + set = std::move(*&set); +} + TEST(xpath_api_query_move) { xml_node c; -- cgit v1.2.3