summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/test_xpath_parse.cpp11
-rw-r--r--tests/test_xpath_variables.cpp30
2 files changed, 40 insertions, 1 deletions
diff --git a/tests/test_xpath_parse.cpp b/tests/test_xpath_parse.cpp
index f996b24..aa148be 100644
--- a/tests/test_xpath_parse.cpp
+++ b/tests/test_xpath_parse.cpp
@@ -291,4 +291,15 @@ TEST(xpath_parse_out_of_memory_string_to_number)
CHECK_XPATH_FAIL(STR("0.11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111"));
}
+TEST(xpath_parse_qname_error)
+{
+ CHECK_XPATH_FAIL(STR("foo: bar"));
+ CHECK_XPATH_FAIL(STR("foo :bar"));
+ CHECK_XPATH_FAIL(STR("foo: *"));
+ CHECK_XPATH_FAIL(STR("foo :*"));
+ CHECK_XPATH_FAIL(STR(":*"));
+ CHECK_XPATH_FAIL(STR(":bar"));
+ CHECK_XPATH_FAIL(STR(":"));
+}
+
#endif
diff --git a/tests/test_xpath_variables.cpp b/tests/test_xpath_variables.cpp
index 1ea8b11..f759dc1 100644
--- a/tests/test_xpath_variables.cpp
+++ b/tests/test_xpath_variables.cpp
@@ -2,6 +2,8 @@
#include "common.hpp"
+#include <string>
+
TEST(xpath_variables_type_none)
{
xpath_variable_set set;
@@ -323,17 +325,22 @@ TEST(xpath_variables_qname)
CHECK_XPATH_BOOLEAN(xml_node(), xpath_query(STR("$foo:bar"), &set), true);
}
-TEST(xpath_variables_qname_error)
+TEST(xpath_variables_name_error)
{
xpath_variable_set set;
set.set(STR("foo:"), true);
set.set(STR(":bar"), true);
set.set(STR("foo:*"), true);
+ set.set(STR("foo"), true);
+ set.set(STR("3"), true);
CHECK_XPATH_FAIL_VAR(STR("$foo:"), &set);
CHECK_XPATH_FAIL_VAR(STR("$:bar"), &set);
CHECK_XPATH_FAIL_VAR(STR("$foo:*"), &set);
CHECK_XPATH_FAIL_VAR(STR("$foo:bar:baz"), &set);
+ CHECK_XPATH_FAIL_VAR(STR("$ foo"), &set);
+
+ CHECK_XPATH_FAIL_VAR(STR("$3"), &set);
}
TEST(xpath_variables_empty_string)
@@ -361,6 +368,27 @@ TEST(xpath_variables_name_case)
CHECK_XPATH_NUMBER(xml_node(), xpath_query(STR("$i div $I"), &set), 2.5);
}
+TEST(xpath_variables_name_unicode)
+{
+#ifdef PUGIXML_WCHAR_MODE
+ #ifdef U_LITERALS
+ const char_t* name = L"\u0400\u203D";
+ #else
+ const char_t* name = L"\x0400\x203D";
+ #endif
+#else
+ const char_t* name = "\xd0\x80\xe2\x80\xbd";
+#endif
+
+ xpath_variable_set set;
+ set.set(name, STR("value"));
+
+ std::basic_string<char_t> var = STR("$");
+ var += name;
+
+ CHECK_XPATH_STRING(xml_node(), xpath_query(var.c_str(), &set), STR("value"));
+}
+
TEST_XML(xpath_variables_count_sum, "<node><c1>12</c1><c2>23</c2><c3>34</c3></node>")
{
xpath_variable_set set;