From 7774cdd96e01b2d89be16f7e240c1ffb2436b4c9 Mon Sep 17 00:00:00 2001 From: Arseny Kapoulkine Date: Tue, 21 Oct 2014 03:33:37 +0000 Subject: XPath: Make sure step_push is called with valid nodes Some steps relied on step_push rejecting null inputs; this is no longer the case. Additionally stepping now more rigorously filters null inputs. git-svn-id: https://pugixml.googlecode.com/svn/trunk@1069 99668b35-9821-0410-8761-19e4c4f06640 --- tests/test_xpath_paths.cpp | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'tests') diff --git a/tests/test_xpath_paths.cpp b/tests/test_xpath_paths.cpp index d791cdf..f1d52ad 100644 --- a/tests/test_xpath_paths.cpp +++ b/tests/test_xpath_paths.cpp @@ -616,4 +616,27 @@ TEST_XML(xpath_paths_optimize_step_once, "

") +{ + xpath_node nodes[] = + { + xpath_node(doc.first_child()), + xpath_node(xml_node()), + xpath_node(doc.first_child().first_attribute(), doc.first_child()), + xpath_node(xml_attribute(), doc.first_child()), + xpath_node(xml_attribute(), xml_node()), + }; + + xpath_node_set ns(nodes, nodes + sizeof(nodes) / sizeof(nodes[0])); + + xpath_variable_set vars; + vars.set(STR("x"), ns); + + xpath_node_set rs = xpath_query("$x/.", &vars).evaluate_node_set(xml_node()); + + CHECK(rs.size() == 2); + CHECK(rs[0] == nodes[0]); + CHECK(rs[1] == nodes[2]); +} #endif -- cgit v1.2.3