From 0027b6ac7907dce79cc2f13230c7ecb46ce14ff6 Mon Sep 17 00:00:00 2001 From: Arseny Kapoulkine Date: Fri, 16 Jun 2017 22:42:40 -0700 Subject: tests: Improve XPath coverage Add memory allocation failure test for concact with a very large list and make sure we have every single axis covered with and without a predicate, with and without a previous step. --- tests/test_xpath_paths.cpp | 75 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) (limited to 'tests/test_xpath_paths.cpp') diff --git a/tests/test_xpath_paths.cpp b/tests/test_xpath_paths.cpp index 7915df1..dd97019 100644 --- a/tests/test_xpath_paths.cpp +++ b/tests/test_xpath_paths.cpp @@ -703,4 +703,79 @@ TEST_XML(xpath_paths_null_nodeset_entries, "") CHECK(rs[0] == nodes[0]); CHECK(rs[1] == nodes[2]); } + +TEST_XML(xpath_paths_step_leaf_coverage, "") +{ + xml_node n = doc.child(STR("n")).child(STR("n2")); + + CHECK_XPATH_NODESET(n, STR("ancestor::node()")) % 2 % 1; + CHECK_XPATH_NODESET(n, STR("ancestor-or-self::node()")) % 4 % 2 % 1; + CHECK_XPATH_NODESET(n, STR("attribute::node()")) % 5; + CHECK_XPATH_NODESET(n, STR("child::node()")) % 6; + CHECK_XPATH_NODESET(n, STR("descendant::node()")) % 6; + CHECK_XPATH_NODESET(n, STR("descendant-or-self::node()")) % 4 % 6; + CHECK_XPATH_NODESET(n, STR("following::node()")) % 7; + CHECK_XPATH_NODESET(n, STR("following-sibling::node()")) % 7; + CHECK_XPATH_NODESET(n, STR("namespace::node()")); + CHECK_XPATH_NODESET(n, STR("parent::node()")) % 2; + CHECK_XPATH_NODESET(n, STR("preceding::node()")) % 3; + CHECK_XPATH_NODESET(n, STR("preceding-sibling::node()")) % 3; + CHECK_XPATH_NODESET(n, STR("self::node()")) % 4; +} +TEST_XML(xpath_paths_step_leaf_predicate_coverage, "") +{ + xml_node n = doc.child(STR("n")).child(STR("n2")); + + CHECK_XPATH_NODESET(n, STR("ancestor::node()[1]")) % 2; + CHECK_XPATH_NODESET(n, STR("ancestor-or-self::node()[1]")) % 4; + CHECK_XPATH_NODESET(n, STR("attribute::node()[1]")) % 5; + CHECK_XPATH_NODESET(n, STR("child::node()[1]")) % 6; + CHECK_XPATH_NODESET(n, STR("descendant::node()[1]")) % 6; + CHECK_XPATH_NODESET(n, STR("descendant-or-self::node()[1]")) % 4; + CHECK_XPATH_NODESET(n, STR("following::node()[1]")) % 7; + CHECK_XPATH_NODESET(n, STR("following-sibling::node()[1]")) % 7; + CHECK_XPATH_NODESET(n, STR("namespace::node()[1]")); + CHECK_XPATH_NODESET(n, STR("parent::node()[1]")) % 2; + CHECK_XPATH_NODESET(n, STR("preceding::node()[1]")) % 3; + CHECK_XPATH_NODESET(n, STR("preceding-sibling::node()[1]")) % 3; + CHECK_XPATH_NODESET(n, STR("self::node()[1]")) % 4; +} + +TEST_XML(xpath_paths_step_step_coverage, "") +{ + xml_node n = doc.child(STR("n")).child(STR("n2")); + + CHECK_XPATH_NODESET(n, STR("./ancestor::node()")) % 2 % 1; + CHECK_XPATH_NODESET(n, STR("./ancestor-or-self::node()")) % 4 % 2 % 1; + CHECK_XPATH_NODESET(n, STR("./attribute::node()")) % 5; + CHECK_XPATH_NODESET(n, STR("./child::node()")) % 6; + CHECK_XPATH_NODESET(n, STR("./descendant::node()")) % 6; + CHECK_XPATH_NODESET(n, STR("./descendant-or-self::node()")) % 4 % 6; + CHECK_XPATH_NODESET(n, STR("./following::node()")) % 7; + CHECK_XPATH_NODESET(n, STR("./following-sibling::node()")) % 7; + CHECK_XPATH_NODESET(n, STR("./namespace::node()")); + CHECK_XPATH_NODESET(n, STR("./parent::node()")) % 2; + CHECK_XPATH_NODESET(n, STR("./preceding::node()")) % 3; + CHECK_XPATH_NODESET(n, STR("./preceding-sibling::node()")) % 3; + CHECK_XPATH_NODESET(n, STR("./self::node()")) % 4; +} + +TEST_XML(xpath_paths_step_step_predicate_coverage, "") +{ + xml_node n = doc.child(STR("n")).child(STR("n2")); + + CHECK_XPATH_NODESET(n, STR("./ancestor::node()[1]")) % 2; + CHECK_XPATH_NODESET(n, STR("./ancestor-or-self::node()[1]")) % 4; + CHECK_XPATH_NODESET(n, STR("./attribute::node()[1]")) % 5; + CHECK_XPATH_NODESET(n, STR("./child::node()[1]")) % 6; + CHECK_XPATH_NODESET(n, STR("./descendant::node()[1]")) % 6; + CHECK_XPATH_NODESET(n, STR("./descendant-or-self::node()[1]")) % 4; + CHECK_XPATH_NODESET(n, STR("./following::node()[1]")) % 7; + CHECK_XPATH_NODESET(n, STR("./following-sibling::node()[1]")) % 7; + CHECK_XPATH_NODESET(n, STR("./namespace::node()[1]")); + CHECK_XPATH_NODESET(n, STR("./parent::node()[1]")) % 2; + CHECK_XPATH_NODESET(n, STR("./preceding::node()[1]")) % 3; + CHECK_XPATH_NODESET(n, STR("./preceding-sibling::node()[1]")) % 3; + CHECK_XPATH_NODESET(n, STR("./self::node()[1]")) % 4; +} #endif -- cgit v1.2.3