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

Unified Diff: base/file_path_unittest.cc

Issue 2831029: Add a method for normalizing path separators on Windows. (Closed) Base URL: http://src.chromium.org/git/chromium.git
Patch Set: a few more Created 10 years, 6 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/file_path.cc ('k') | 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
diff --git a/base/file_path_unittest.cc b/base/file_path_unittest.cc
index 92659f16e1a6862853ce65076a48f262022f9b03..828a6426e1bc4720abd0065a44df15cec5f0db69 100644
--- a/base/file_path_unittest.cc
+++ b/base/file_path_unittest.cc
@@ -661,7 +661,7 @@ TEST_F(FilePathTest, EqualityTest) {
#if defined(FILE_PATH_USES_WIN_SEPARATORS)
{ { FPL("\\foo\\bar"), FPL("\\foo\\bar") }, true},
{ { FPL("\\foo/bar"), FPL("\\foo/bar") }, true},
- { { FPL("\\foo/bar"), FPL("\\foo\bar") }, false},
+ { { FPL("\\foo/bar"), FPL("\\foo\\bar") }, false},
{ { FPL("\\"), FPL("\\") }, true},
{ { FPL("\\"), FPL("/") }, false},
{ { FPL(""), FPL("\\") }, false},
@@ -1004,3 +1004,47 @@ TEST_F(FilePathTest, ReferencesParent) {
"i: " << i << ", input: " << input.value();
}
}
+
+#if defined(FILE_PATH_USES_WIN_SEPARATORS)
+TEST_F(FilePathTest, NormalizeWindowsPathSeparators) {
+ const struct UnaryTestData cases[] = {
+ { FPL("foo/bar"), FPL("foo\\bar") },
+ { FPL("foo/bar\\betz"), FPL("foo\\bar\\betz") },
+ { FPL("foo\\bar"), FPL("foo\\bar") },
+ { FPL("foo\\bar/betz"), FPL("foo\\bar\\betz") },
+ { FPL("foo"), FPL("foo") },
+ // Trailing slashes don't automatically get stripped. That's what
+ // StripTrailingSeparators() is for.
+ { FPL("foo\\"), FPL("foo\\") },
+ { FPL("foo/"), FPL("foo\\") },
+ { FPL("foo/bar\\"), FPL("foo\\bar\\") },
+ { FPL("foo\\bar/"), FPL("foo\\bar\\") },
+ { FPL("foo/bar/"), FPL("foo\\bar\\") },
+ { FPL("foo\\bar\\"), FPL("foo\\bar\\") },
+ { FPL("\\foo/bar"), FPL("\\foo\\bar") },
+ { FPL("/foo\\bar"), FPL("\\foo\\bar") },
+ { FPL("c:/foo/bar/"), FPL("c:\\foo\\bar\\") },
+ { FPL("/foo/bar/"), FPL("\\foo\\bar\\") },
+ { FPL("\\foo\\bar\\"), FPL("\\foo\\bar\\") },
+ { FPL("c:\\foo/bar"), FPL("c:\\foo\\bar") },
+ { FPL("//foo\\bar\\"), FPL("\\\\foo\\bar\\") },
+ { FPL("\\\\foo\\bar\\"), FPL("\\\\foo\\bar\\") },
+ { FPL("//foo\\bar\\"), FPL("\\\\foo\\bar\\") },
+ // This method does not normalize the number of path separators.
+ { FPL("foo\\\\bar"), FPL("foo\\\\bar") },
+ { FPL("foo//bar"), FPL("foo\\\\bar") },
+ { FPL("foo/\\bar"), FPL("foo\\\\bar") },
+ { FPL("foo\\/bar"), FPL("foo\\\\bar") },
+ { FPL("///foo\\\\bar"), FPL("\\\\\\foo\\\\bar") },
+ { FPL("foo//bar///"), FPL("foo\\\\bar\\\\\\") },
+ { FPL("foo/\\bar/\\"), FPL("foo\\\\bar\\\\") },
+ { FPL("/\\foo\\/bar"), FPL("\\\\foo\\\\bar") },
+ };
+ for (size_t i = 0; i < arraysize(cases); ++i) {
+ FilePath input(cases[i].input);
+ FilePath observed = input.NormalizeWindowsPathSeparators();
+ EXPECT_EQ(FilePath::StringType(cases[i].expected), observed.value()) <<
+ "i: " << i << ", input: " << input.value();
+ }
+}
+#endif
« no previous file with comments | « base/file_path.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698