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

Unified Diff: base/string_util_unittest.cc

Issue 119199: add CollapseWhitespaceASCII (Closed)
Patch Set: Created 11 years, 7 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/string_util.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/string_util_unittest.cc
diff --git a/base/string_util_unittest.cc b/base/string_util_unittest.cc
index a2f4f1defa89e4cfc67bb38a9b25f68dc5ec98af..1087aeab7a1ebcdd14e169c2e1ae3b72cfde3fe5 100644
--- a/base/string_util_unittest.cc
+++ b/base/string_util_unittest.cc
@@ -157,6 +157,36 @@ TEST(StringUtilTest, CollapseWhitespace) {
}
}
+static const struct collapse_case_ascii {
+ const char* input;
+ const bool trim;
+ const char* output;
+} collapse_cases_ascii[] = {
+ {" Google Video ", false, "Google Video"},
+ {"Google Video", false, "Google Video"},
+ {"", false, ""},
+ {" ", false, ""},
+ {"\t\rTest String\n", false, "Test String"},
+ {" Test \n \t String ", false, "Test String"},
+ {" Test String", false, "Test String"},
+ {"Test String ", false, "Test String"},
+ {"Test String", false, "Test String"},
+ {"", true, ""},
+ {"\n", true, ""},
+ {" \r ", true, ""},
+ {"\nFoo", true, "Foo"},
+ {"\r Foo ", true, "Foo"},
+ {" Foo bar ", true, "Foo bar"},
+ {" \tFoo bar \n", true, "Foo bar"},
+ {" a \r b\n c \r\n d \t\re \t f \n ", true, "abcde f"},
+};
+
+TEST(StringUtilTest, CollapseWhitespaceASCII) {
+ for (size_t i = 0; i < arraysize(collapse_cases_ascii); ++i) {
+ const collapse_case_ascii& value = collapse_cases_ascii[i];
+ EXPECT_EQ(value.output, CollapseWhitespaceASCII(value.input, value.trim));
+ }
+}
TEST(StringUtilTest, IsStringUTF8) {
EXPECT_TRUE(IsStringUTF8("abc"));
« no previous file with comments | « base/string_util.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698