summaryrefslogtreecommitdiff
path: root/tests/test_xpath_api.cpp
diff options
context:
space:
mode:
authorArseny Kapoulkine <arseny.kapoulkine@gmail.com>2014-10-19 07:33:51 +0000
committerArseny Kapoulkine <arseny.kapoulkine@gmail.com>2014-10-19 07:33:51 +0000
commitc3eb9c92a86b041b40e70afb32ea66d4369c892b (patch)
tree77c345f39fb54c531720c3868faff12c51492631 /tests/test_xpath_api.cpp
parentf6635588758ed1b650be22903c2e2e81273e05c5 (diff)
XPath: Rename xml_node::select_single_node to ::select_node
select_node is shorter and mistyping nodes as node or vice versa should not lead to any issues since return types are substantially different. select_single_node method still works and will be deprecated with an attribute and removed at some point. git-svn-id: https://pugixml.googlecode.com/svn/trunk@1065 99668b35-9821-0410-8761-19e4c4f06640
Diffstat (limited to 'tests/test_xpath_api.cpp')
-rw-r--r--tests/test_xpath_api.cpp32
1 files changed, 21 insertions, 11 deletions
diff --git a/tests/test_xpath_api.cpp b/tests/test_xpath_api.cpp
index 8ec5694..270f6aa 100644
--- a/tests/test_xpath_api.cpp
+++ b/tests/test_xpath_api.cpp
@@ -19,22 +19,22 @@ TEST_XML(xpath_api_select_nodes, "<node><head/><foo/><foo/><tail/></node>")
xpath_node_set_tester(ns2, "ns2") % 4 % 5;
}
-TEST_XML(xpath_api_select_single_node, "<node><head/><foo id='1'/><foo/><tail/></node>")
+TEST_XML(xpath_api_select_node, "<node><head/><foo id='1'/><foo/><tail/></node>")
{
- xpath_node n1 = doc.select_single_node(STR("node/foo"));
+ xpath_node n1 = doc.select_node(STR("node/foo"));
xpath_query q(STR("node/foo"));
- xpath_node n2 = doc.select_single_node(q);
+ xpath_node n2 = doc.select_node(q);
CHECK(n1.node().attribute(STR("id")).as_int() == 1);
CHECK(n2.node().attribute(STR("id")).as_int() == 1);
- xpath_node n3 = doc.select_single_node(STR("node/bar"));
+ xpath_node n3 = doc.select_node(STR("node/bar"));
CHECK(!n3);
- xpath_node n4 = doc.select_single_node(STR("node/head/following-sibling::foo"));
- xpath_node n5 = doc.select_single_node(STR("node/tail/preceding-sibling::foo"));
+ xpath_node n4 = doc.select_node(STR("node/head/following-sibling::foo"));
+ xpath_node n5 = doc.select_node(STR("node/tail/preceding-sibling::foo"));
CHECK(n4.node().attribute(STR("id")).as_int() == 1);
CHECK(n5.node().attribute(STR("id")).as_int() == 1);
@@ -42,20 +42,20 @@ TEST_XML(xpath_api_select_single_node, "<node><head/><foo id='1'/><foo/><tail/><
TEST_XML(xpath_api_node_bool_ops, "<node attr='value'/>")
{
- generic_bool_ops_test(doc.select_single_node(STR("node")));
- generic_bool_ops_test(doc.select_single_node(STR("node/@attr")));
+ generic_bool_ops_test(doc.select_node(STR("node")));
+ generic_bool_ops_test(doc.select_node(STR("node/@attr")));
}
TEST_XML(xpath_api_node_eq_ops, "<node attr='value'/>")
{
- generic_eq_ops_test(doc.select_single_node(STR("node")), doc.select_single_node(STR("node/@attr")));
+ generic_eq_ops_test(doc.select_node(STR("node")), doc.select_node(STR("node/@attr")));
}
TEST_XML(xpath_api_node_accessors, "<node attr='value'/>")
{
xpath_node null;
- xpath_node node = doc.select_single_node(STR("node"));
- xpath_node attr = doc.select_single_node(STR("node/@attr"));
+ xpath_node node = doc.select_node(STR("node"));
+ xpath_node attr = doc.select_node(STR("node/@attr"));
CHECK(!null.node());
CHECK(!null.attribute());
@@ -411,4 +411,14 @@ TEST_XML(xpath_api_node_set_assign_out_of_memory_preserve, "<node><a/><b/></node
}
#endif
+TEST_XML(xpath_api_deprecated_select_single_node, "<node><head/><foo id='1'/><foo/><tail/></node>")
+{
+ xpath_node n1 = doc.select_single_node(STR("node/foo"));
+
+ xpath_query q(STR("node/foo"));
+ xpath_node n2 = doc.select_single_node(q);
+
+ CHECK(n1.node().attribute(STR("id")).as_int() == 1);
+ CHECK(n2.node().attribute(STR("id")).as_int() == 1);
+}
#endif