summaryrefslogtreecommitdiff
path: root/tests/test_xpath_paths.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test_xpath_paths.cpp')
-rw-r--r--tests/test_xpath_paths.cpp75
1 files changed, 75 insertions, 0 deletions
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, "<node attr='value'/>")
CHECK(rs[0] == nodes[0]);
CHECK(rs[1] == nodes[2]);
}
+
+TEST_XML(xpath_paths_step_leaf_coverage, "<n><n1/><n2 a='v'><child/></n2><n3/></n>")
+{
+ 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, "<n><n1/><n2 a='v'><child/></n2><n3/></n>")
+{
+ 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, "<n><n1/><n2 a='v'><child/></n2><n3/></n>")
+{
+ 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, "<n><n1/><n2 a='v'><child/></n2><n3/></n>")
+{
+ 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