summaryrefslogtreecommitdiffstats
path: root/base/file_path_unittest.cc
diff options
context:
space:
mode:
authormark@chromium.org <mark@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-13 17:31:39 +0000
committermark@chromium.org <mark@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-13 17:31:39 +0000
commit8133c680452262815566bd8ba6c9b80ca8428780 (patch)
treefc3490aa4354451c6c3e6488005b514438c73138 /base/file_path_unittest.cc
parentb58713f4e243a1eba23a2a6f31db08ea178ff043 (diff)
downloadchromium_src-8133c680452262815566bd8ba6c9b80ca8428780.zip
chromium_src-8133c680452262815566bd8ba6c9b80ca8428780.tar.gz
chromium_src-8133c680452262815566bd8ba6c9b80ca8428780.tar.bz2
Add FilePathTest.StripTrailingSeparators to base_unittests to test
FilePath::StripTrailingSeparators. BUG=24692 TEST=this Review URL: http://codereview.chromium.org/272039 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@28832 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/file_path_unittest.cc')
-rw-r--r--base/file_path_unittest.cc65
1 files changed, 64 insertions, 1 deletions
diff --git a/base/file_path_unittest.cc b/base/file_path_unittest.cc
index 0bf9ed7..b80d9fc 100644
--- a/base/file_path_unittest.cc
+++ b/base/file_path_unittest.cc
@@ -312,6 +312,70 @@ TEST_F(FilePathTest, Append) {
}
}
+TEST_F(FilePathTest, StripTrailingSeparators) {
+ const struct UnaryTestData cases[] = {
+ { FPL(""), FPL("") },
+ { FPL("/"), FPL("/") },
+ { FPL("//"), FPL("//") },
+ { FPL("///"), FPL("/") },
+ { FPL("////"), FPL("/") },
+ { FPL("a/"), FPL("a") },
+ { FPL("a//"), FPL("a") },
+ { FPL("a///"), FPL("a") },
+ { FPL("a////"), FPL("a") },
+ { FPL("/a"), FPL("/a") },
+ { FPL("/a/"), FPL("/a") },
+ { FPL("/a//"), FPL("/a") },
+ { FPL("/a///"), FPL("/a") },
+ { FPL("/a////"), FPL("/a") },
+#if defined(FILE_PATH_USES_DRIVE_LETTERS)
+ { FPL("c:"), FPL("c:") },
+ { FPL("c:/"), FPL("c:/") },
+ { FPL("c://"), FPL("c://") },
+ { FPL("c:///"), FPL("c:/") },
+ { FPL("c:////"), FPL("c:/") },
+ { FPL("c:/a"), FPL("c:/a") },
+ { FPL("c:/a/"), FPL("c:/a") },
+ { FPL("c:/a//"), FPL("c:/a") },
+ { FPL("c:/a///"), FPL("c:/a") },
+ { FPL("c:/a////"), FPL("c:/a") },
+#endif // FILE_PATH_USES_DRIVE_LETTERS
+#if defined(FILE_PATH_USES_WIN_SEPARATORS)
+ { FPL("\\"), FPL("\\") },
+ { FPL("\\\\"), FPL("\\\\") },
+ { FPL("\\\\\\"), FPL("\\") },
+ { FPL("\\\\\\\\"), FPL("\\") },
+ { FPL("a\\"), FPL("a") },
+ { FPL("a\\\\"), FPL("a") },
+ { FPL("a\\\\\\"), FPL("a") },
+ { FPL("a\\\\\\\\"), FPL("a") },
+ { FPL("\\a"), FPL("\\a") },
+ { FPL("\\a\\"), FPL("\\a") },
+ { FPL("\\a\\\\"), FPL("\\a") },
+ { FPL("\\a\\\\\\"), FPL("\\a") },
+ { FPL("\\a\\\\\\\\"), FPL("\\a") },
+#if defined(FILE_PATH_USES_DRIVE_LETTERS)
+ { FPL("c:\\"), FPL("c:\\") },
+ { FPL("c:\\\\"), FPL("c:\\\\") },
+ { FPL("c:\\\\\\"), FPL("c:\\") },
+ { FPL("c:\\\\\\\\"), FPL("c:\\") },
+ { FPL("c:\\a"), FPL("c:\\a") },
+ { FPL("c:\\a\\"), FPL("c:\\a") },
+ { FPL("c:\\a\\\\"), FPL("c:\\a") },
+ { FPL("c:\\a\\\\\\"), FPL("c:\\a") },
+ { FPL("c:\\a\\\\\\\\"), FPL("c:\\a") },
+#endif // FILE_PATH_USES_DRIVE_LETTERS
+#endif // FILE_PATH_USES_WIN_SEPARATORS
+ };
+
+ for (size_t i = 0; i < arraysize(cases); ++i) {
+ FilePath input(cases[i].input);
+ FilePath observed = input.StripTrailingSeparators();
+ EXPECT_EQ(FilePath::StringType(cases[i].expected), observed.value()) <<
+ "i: " << i << ", input: " << input.value();
+ }
+}
+
TEST_F(FilePathTest, IsAbsolute) {
const struct UnaryBooleanTestData cases[] = {
{ FPL(""), false },
@@ -844,4 +908,3 @@ TEST_F(FilePathTest, ReferencesParent) {
"i: " << i << ", input: " << input.value();
}
}
-