OLD | NEW |
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 Loading... |
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 Loading... |
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 |
OLD | NEW |