summaryrefslogtreecommitdiffstats
path: root/base/string_util_unittest.cc
diff options
context:
space:
mode:
authorrafaelw@chromium.org <rafaelw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-04 23:10:39 +0000
committerrafaelw@chromium.org <rafaelw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-04 23:10:39 +0000
commit46878fb99cebcc06936428a4cf04586734856fe0 (patch)
tree60d0107ef6b2b1d4074037fe4e865c8a201d9af0 /base/string_util_unittest.cc
parent8b6c1e3833d5030da152ef816ba0f6673082c25a (diff)
downloadchromium_src-46878fb99cebcc06936428a4cf04586734856fe0.zip
chromium_src-46878fb99cebcc06936428a4cf04586734856fe0.tar.gz
chromium_src-46878fb99cebcc06936428a4cf04586734856fe0.tar.bz2
add CollapseWhitespaceASCII
R=erikkay Review URL: http://codereview.chromium.org/119199 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@17689 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/string_util_unittest.cc')
-rw-r--r--base/string_util_unittest.cc30
1 files changed, 30 insertions, 0 deletions
diff --git a/base/string_util_unittest.cc b/base/string_util_unittest.cc
index a2f4f1d..1087aea 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"));