From 5239fcbd0030ce7dcca1ee05dab0e8be3a98a288 Mon Sep 17 00:00:00 2001 From: Arseny Kapoulkine Date: Sun, 5 Oct 2014 07:57:58 +0000 Subject: 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 --- tests/test_xpath_functions.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'tests') 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, "") { xml_node n = doc.child(STR("node")); -- cgit v1.2.3