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

Unified Diff: base/string_util_unittest.cc

Issue 8502027: Fix AutocompleteMatch DCHECK() triggered by |RenderViewContextMenu::AppendSearchProvider()|. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 1 month 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/string_util.cc ('k') | chrome/browser/autocomplete/autocomplete_match.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/string_util_unittest.cc
===================================================================
--- base/string_util_unittest.cc (revision 108864)
+++ base/string_util_unittest.cc (working copy)
@@ -1066,6 +1066,39 @@
EXPECT_EQ(std::string(), input);
}
+TEST(StringUtilTest, ReplaceChars) {
+ struct TestData {
+ const char* input;
+ const char* replace_chars;
+ const char* replace_with;
+ const char* output;
+ bool result;
+ } cases[] = {
+ { "", "", "", "", false },
+ { "test", "", "", "test", false },
+ { "test", "", "!", "test", false },
+ { "test", "z", "!", "test", false },
+ { "test", "e", "!", "t!st", true },
+ { "test", "e", "!?", "t!?st", true },
+ { "test", "ez", "!", "t!st", true },
+ { "test", "zed", "!?", "t!?st", true },
+ { "test", "t", "!?", "!?es!?", true },
+ { "test", "et", "!>", "!>!>s!>", true },
+ { "test", "zest", "!", "!!!!", true },
+ { "test", "szt", "!", "!e!!", true },
+ };
+
+ for (size_t i = 0; i < ARRAYSIZE_UNSAFE(cases); ++i) {
+ std::string output;
+ bool result = ReplaceChars(cases[i].input,
+ cases[i].replace_chars,
+ cases[i].replace_with,
+ &output);
+ EXPECT_EQ(cases[i].result, result);
+ EXPECT_EQ(cases[i].output, output);
+ }
+}
+
TEST(StringUtilTest, ContainsOnlyChars) {
// Providing an empty list of characters should return false but for the empty
// string.
« no previous file with comments | « base/string_util.cc ('k') | chrome/browser/autocomplete/autocomplete_match.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698