Chromium Code Reviews| 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); |
| + DCHECK_EQ(cases[i].result, result); |
|
Mark Mentovai
2011/11/09 21:08:38
You don’t want DCHECK_EQ, you want EXPECT_EQ. Same
Alexei Svitkine (slow)
2011/11/09 21:13:18
Doh, I knew that. Done.
|
| + DCHECK_EQ(cases[i].output, output); |
| + } |
| +} |
| + |
| TEST(StringUtilTest, ContainsOnlyChars) { |
| // Providing an empty list of characters should return false but for the empty |
| // string. |