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

Unified Diff: base/file_path_unittest.cc

Issue 272039: Add FilePathTest.StripTrailingSeparator to base_unittests to test FilePath::StripTrailingSeparator (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 11 years, 2 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/file_path_unittest.cc
===================================================================
--- base/file_path_unittest.cc (revision 28751)
+++ base/file_path_unittest.cc (working copy)
@@ -312,6 +312,70 @@
}
}
+TEST_F(FilePathTest, StripTrailingSeparators) {
+ const struct UnaryTestData cases[] = {
+ { FPL(""), FPL("") },
+ { FPL("/"), FPL("/") },
+ { FPL("//"), FPL("//") },
Erik does not do reviews 2009/10/13 16:57:01 is this use case for windows network paths using /
+ { 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://") },
Erik does not do reviews 2009/10/13 16:57:01 just curious, what is this use case for?
+ { 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 },
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698