tests: Add a dedicated test for XPath variable conversion
This makes sure all conversions work as expected (note that no type can be converted to node set so we don't check that).
This commit is contained in:
parent
41b6ff21c4
commit
85a39b955d
1 changed files with 26 additions and 0 deletions
|
@ -642,4 +642,30 @@ TEST_XML(xpath_variables_evaluate_node_set_out_of_memory, "<node />")
|
|||
|
||||
CHECK_ALLOC_FAIL(q.evaluate_node_set(xml_node()).empty());
|
||||
}
|
||||
|
||||
TEST_XML(xpath_variables_type_conversion, "<node>15</node>")
|
||||
{
|
||||
xpath_variable_set set;
|
||||
|
||||
set.set(STR("a"), true);
|
||||
set.set(STR("b"), 42.0);
|
||||
set.set(STR("c"), STR("test"));
|
||||
set.set(STR("d"), doc.select_nodes(STR("node")));
|
||||
|
||||
CHECK_XPATH_BOOLEAN_VAR(xml_node(), STR("boolean($a) = true()"), &set, true);
|
||||
CHECK_XPATH_BOOLEAN_VAR(xml_node(), STR("number($a) = 1"), &set, true);
|
||||
CHECK_XPATH_BOOLEAN_VAR(xml_node(), STR("string($a) = 'true'"), &set, true);
|
||||
|
||||
CHECK_XPATH_BOOLEAN_VAR(xml_node(), STR("boolean($b) = true()"), &set, true);
|
||||
CHECK_XPATH_BOOLEAN_VAR(xml_node(), STR("number($b) = 42"), &set, true);
|
||||
CHECK_XPATH_BOOLEAN_VAR(xml_node(), STR("string($b) = '42'"), &set, true);
|
||||
|
||||
CHECK_XPATH_BOOLEAN_VAR(xml_node(), STR("boolean($c) = true()"), &set, true);
|
||||
CHECK_XPATH_BOOLEAN_VAR(xml_node(), STR("number($c) = 0"), &set, false);
|
||||
CHECK_XPATH_BOOLEAN_VAR(xml_node(), STR("string($c) = 'test'"), &set, true);
|
||||
|
||||
CHECK_XPATH_BOOLEAN_VAR(xml_node(), STR("boolean($d) = true()"), &set, true);
|
||||
CHECK_XPATH_BOOLEAN_VAR(xml_node(), STR("number($d) = 15"), &set, true);
|
||||
CHECK_XPATH_BOOLEAN_VAR(xml_node(), STR("string($d) = '15'"), &set, true);
|
||||
}
|
||||
#endif
|
||||
|
|
Loading…
Add table
Reference in a new issue