Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2139)

Unified Diff: base/i18n/string_search_unittest.cc

Issue 18031015: base/i18n: Class for efficiently searching the same query over many texts. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address review comments (#5) Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/i18n/string_search.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/i18n/string_search_unittest.cc
diff --git a/base/i18n/string_search_unittest.cc b/base/i18n/string_search_unittest.cc
index b24600e1d4a1a2f54061428b5bc50de65930d95b..d2bd53a6d130a0441fc9f2e7de587c80b646926b 100644
--- a/base/i18n/string_search_unittest.cc
+++ b/base/i18n/string_search_unittest.cc
@@ -199,5 +199,28 @@ TEST(StringSearchTest, UnicodeLocaleDependent) {
SetICUDefaultLocale(default_locale);
}
+TEST(StringSearchTest, FixedPatternMultipleSearch) {
+ std::string default_locale(uloc_getDefault());
+ bool locale_is_posix = (default_locale == "en_US_POSIX");
+ if (locale_is_posix)
+ SetICUDefaultLocale("en_US");
+
+ size_t index = 0;
+ size_t length = 0;
+
+ // Search "hello" over multiple texts.
+ FixedPatternStringSearchIgnoringCaseAndAccents query(ASCIIToUTF16("hello"));
+ EXPECT_TRUE(query.Search(ASCIIToUTF16("12hello34"), &index, &length));
+ EXPECT_EQ(2U, index);
+ EXPECT_EQ(5U, length);
+ EXPECT_FALSE(query.Search(ASCIIToUTF16("bye"), &index, &length));
+ EXPECT_TRUE(query.Search(ASCIIToUTF16("hELLo"), &index, &length));
+ EXPECT_EQ(0U, index);
+ EXPECT_EQ(5U, length);
+
+ if (locale_is_posix)
+ SetICUDefaultLocale(default_locale.data());
+}
+
} // namespace i18n
} // namespace base
« no previous file with comments | « base/i18n/string_search.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698