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

Side by Side Diff: base/file_path_unittest.cc

Issue 9320059: Define FilePath::NormalizePathSeparators on all platforms (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: build fix Created 8 years, 10 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « base/file_path.cc ('k') | chrome/browser/extensions/extension_protocols.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/basictypes.h" 5 #include "base/basictypes.h"
6 #include "base/file_path.h" 6 #include "base/file_path.h"
7 #include "base/file_util.h" 7 #include "base/file_util.h"
8 #include "base/utf_string_conversions.h" 8 #include "base/utf_string_conversions.h"
9 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
10 #include "testing/platform_test.h" 10 #include "testing/platform_test.h"
(...skipping 1056 matching lines...) Expand 10 before | Expand all | Expand 10 after
1067 // Test AsUTF8Unsafe() works. 1067 // Test AsUTF8Unsafe() works.
1068 FilePath from_native = FilePath(cases[i].native); 1068 FilePath from_native = FilePath(cases[i].native);
1069 EXPECT_EQ(cases[i].utf8, from_native.AsUTF8Unsafe()) 1069 EXPECT_EQ(cases[i].utf8, from_native.AsUTF8Unsafe())
1070 << "i: " << i << ", input: " << cases[i].native; 1070 << "i: " << i << ", input: " << cases[i].native;
1071 // Test the two file paths are identical. 1071 // Test the two file paths are identical.
1072 EXPECT_EQ(from_utf8.value(), from_native.value()); 1072 EXPECT_EQ(from_utf8.value(), from_native.value());
1073 } 1073 }
1074 } 1074 }
1075 1075
1076 #if defined(FILE_PATH_USES_WIN_SEPARATORS) 1076 #if defined(FILE_PATH_USES_WIN_SEPARATORS)
1077 TEST_F(FilePathTest, NormalizeWindowsPathSeparators) { 1077 TEST_F(FilePathTest, NormalizePathSeparators) {
1078 const struct UnaryTestData cases[] = { 1078 const struct UnaryTestData cases[] = {
1079 { FPL("foo/bar"), FPL("foo\\bar") }, 1079 { FPL("foo/bar"), FPL("foo\\bar") },
1080 { FPL("foo/bar\\betz"), FPL("foo\\bar\\betz") }, 1080 { FPL("foo/bar\\betz"), FPL("foo\\bar\\betz") },
1081 { FPL("foo\\bar"), FPL("foo\\bar") }, 1081 { FPL("foo\\bar"), FPL("foo\\bar") },
1082 { FPL("foo\\bar/betz"), FPL("foo\\bar\\betz") }, 1082 { FPL("foo\\bar/betz"), FPL("foo\\bar\\betz") },
1083 { FPL("foo"), FPL("foo") }, 1083 { FPL("foo"), FPL("foo") },
1084 // Trailing slashes don't automatically get stripped. That's what 1084 // Trailing slashes don't automatically get stripped. That's what
1085 // StripTrailingSeparators() is for. 1085 // StripTrailingSeparators() is for.
1086 { FPL("foo\\"), FPL("foo\\") }, 1086 { FPL("foo\\"), FPL("foo\\") },
1087 { FPL("foo/"), FPL("foo\\") }, 1087 { FPL("foo/"), FPL("foo\\") },
(...skipping 15 matching lines...) Expand all
1103 { FPL("foo//bar"), FPL("foo\\\\bar") }, 1103 { FPL("foo//bar"), FPL("foo\\\\bar") },
1104 { FPL("foo/\\bar"), FPL("foo\\\\bar") }, 1104 { FPL("foo/\\bar"), FPL("foo\\\\bar") },
1105 { FPL("foo\\/bar"), FPL("foo\\\\bar") }, 1105 { FPL("foo\\/bar"), FPL("foo\\\\bar") },
1106 { FPL("///foo\\\\bar"), FPL("\\\\\\foo\\\\bar") }, 1106 { FPL("///foo\\\\bar"), FPL("\\\\\\foo\\\\bar") },
1107 { FPL("foo//bar///"), FPL("foo\\\\bar\\\\\\") }, 1107 { FPL("foo//bar///"), FPL("foo\\\\bar\\\\\\") },
1108 { FPL("foo/\\bar/\\"), FPL("foo\\\\bar\\\\") }, 1108 { FPL("foo/\\bar/\\"), FPL("foo\\\\bar\\\\") },
1109 { FPL("/\\foo\\/bar"), FPL("\\\\foo\\\\bar") }, 1109 { FPL("/\\foo\\/bar"), FPL("\\\\foo\\\\bar") },
1110 }; 1110 };
1111 for (size_t i = 0; i < arraysize(cases); ++i) { 1111 for (size_t i = 0; i < arraysize(cases); ++i) {
1112 FilePath input(cases[i].input); 1112 FilePath input(cases[i].input);
1113 FilePath observed = input.NormalizeWindowsPathSeparators(); 1113 FilePath observed = input.NormalizePathSeparators();
1114 EXPECT_EQ(FilePath::StringType(cases[i].expected), observed.value()) << 1114 EXPECT_EQ(FilePath::StringType(cases[i].expected), observed.value()) <<
1115 "i: " << i << ", input: " << input.value(); 1115 "i: " << i << ", input: " << input.value();
1116 } 1116 }
1117 } 1117 }
1118 1118
1119 #endif 1119 #endif
OLDNEW
« no previous file with comments | « base/file_path.cc ('k') | chrome/browser/extensions/extension_protocols.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698