summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorArseny Kapoulkine <arseny.kapoulkine@gmail.com>2017-01-30 08:57:42 -0800
committerArseny Kapoulkine <arseny.kapoulkine@gmail.com>2017-01-30 11:51:07 -0800
commitcac1d8ad9f602e74841acb05596396ee00994ebb (patch)
tree6beb36d4e05fc25c85688bbfff4c25d98e1fdf53 /tests
parent1b3e8614e7638fb7e87ec7e85bfbe8447432c53c (diff)
tests: Add an error propagation test for XPath
This test is supposed to test error coverage in different expressions that are nested in other expressions to reduce the number of never-taken branches in tests (and make sure we aren't missing any).
Diffstat (limited to 'tests')
-rw-r--r--tests/test_xpath_parse.cpp22
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/test_xpath_parse.cpp b/tests/test_xpath_parse.cpp
index b6de42e..1f51118 100644
--- a/tests/test_xpath_parse.cpp
+++ b/tests/test_xpath_parse.cpp
@@ -313,4 +313,26 @@ TEST(xpath_parse_result_default)
CHECK(result.offset == 0);
}
+TEST(xpath_parse_error_propagation)
+{
+ char_t query[] = STR("(//foo[count(. | @*)] | /foo | /foo/bar//more/ancestor-or-self::foobar | /text() | a[1 + 2 * 3 div (1+0) mod 2]//b[1]/c | a[$x])[true()]");
+
+ xpath_variable_set vars;
+ vars.set(STR("x"), 1.0);
+
+ xpath_query q(query, &vars);
+ CHECK(q);
+
+ for (size_t i = 0; i + 1 < sizeof(query) / sizeof(query[0]); ++i)
+ {
+ char_t ch = query[i];
+
+ query[i] = '%';
+
+ CHECK_XPATH_FAIL(query);
+
+ query[i] = ch;
+ }
+}
+
#endif