summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorArseny Kapoulkine <arseny.kapoulkine@gmail.com>2014-10-05 07:57:58 +0000
committerArseny Kapoulkine <arseny.kapoulkine@gmail.com>2014-10-05 07:57:58 +0000
commit5239fcbd0030ce7dcca1ee05dab0e8be3a98a288 (patch)
tree704c161c7954fe45cd0043ba21fed96fe36b9a49 /tests
parentb17501c3fb01530aae790228850ac6122227d8a8 (diff)
XPath: Implement optimized translate()
translate() with constant arguments now uses a 128-byte table and a table lookup instead of searching characters in the source string. The table is generated during query optimization. git-svn-id: https://pugixml.googlecode.com/svn/trunk@1052 99668b35-9821-0410-8761-19e4c4f06640
Diffstat (limited to 'tests')
-rw-r--r--tests/test_xpath_functions.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/tests/test_xpath_functions.cpp b/tests/test_xpath_functions.cpp
index 30ba218..f5d9e53 100644
--- a/tests/test_xpath_functions.cpp
+++ b/tests/test_xpath_functions.cpp
@@ -557,6 +557,16 @@ TEST(xpath_string_translate)
CHECK_XPATH_FAIL(STR("translate('a', 'b', 'c', 'd')"));
}
+TEST(xpath_string_translate_table)
+{
+ xml_node c;
+
+ CHECK_XPATH_STRING(c, STR("translate('abcd\xe9 ', 'abc', 'ABC')"), STR("ABCd\xe9 "));
+ CHECK_XPATH_STRING(c, STR("translate('abcd\xe9 ', 'abc\xe9', 'ABC!')"), STR("ABCd! "));
+ CHECK_XPATH_STRING(c, STR("translate('abcde', concat('abc', 'd'), 'ABCD')"), STR("ABCDe"));
+ CHECK_XPATH_STRING(c, STR("translate('abcde', 'abcd', concat('ABC', 'D'))"), STR("ABCDe"));
+}
+
TEST_XML(xpath_nodeset_last, "<node><c1/><c1/><c2/><c3/><c3/><c3/><c3/></node>")
{
xml_node n = doc.child(STR("node"));