OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_util.h" | 6 #include "base/file_util.h" |
7 #include "base/files/file_path.h" | 7 #include "base/files/file_path.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 1178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1189 { FPL("foo/\\bar/\\"), FPL("foo\\\\bar\\\\") }, | 1189 { FPL("foo/\\bar/\\"), FPL("foo\\\\bar\\\\") }, |
1190 { FPL("/\\foo\\/bar"), FPL("\\\\foo\\\\bar") }, | 1190 { FPL("/\\foo\\/bar"), FPL("\\\\foo\\\\bar") }, |
1191 }; | 1191 }; |
1192 for (size_t i = 0; i < arraysize(cases); ++i) { | 1192 for (size_t i = 0; i < arraysize(cases); ++i) { |
1193 FilePath input(cases[i].input); | 1193 FilePath input(cases[i].input); |
1194 FilePath observed = input.NormalizePathSeparators(); | 1194 FilePath observed = input.NormalizePathSeparators(); |
1195 EXPECT_EQ(FilePath::StringType(cases[i].expected), observed.value()) << | 1195 EXPECT_EQ(FilePath::StringType(cases[i].expected), observed.value()) << |
1196 "i: " << i << ", input: " << input.value(); | 1196 "i: " << i << ", input: " << input.value(); |
1197 } | 1197 } |
1198 } | 1198 } |
1199 | |
1200 #endif | 1199 #endif |
1201 | 1200 |
| 1201 TEST_F(FilePathTest, EndsWithSeparator) { |
| 1202 const UnaryBooleanTestData cases[] = { |
| 1203 { FPL(""), false }, |
| 1204 { FPL("/"), true }, |
| 1205 { FPL("foo/"), true }, |
| 1206 { FPL("bar"), false }, |
| 1207 { FPL("/foo/bar"), false }, |
| 1208 }; |
| 1209 for (size_t i = 0; i < arraysize(cases); ++i) { |
| 1210 FilePath input = FilePath(cases[i].input).NormalizePathSeparators(); |
| 1211 EXPECT_EQ(cases[i].expected, input.EndsWithSeparator()); |
| 1212 } |
| 1213 } |
| 1214 |
| 1215 TEST_F(FilePathTest, AsEndingWithSeparator) { |
| 1216 const UnaryTestData cases[] = { |
| 1217 { FPL(""), FPL("") }, |
| 1218 { FPL("/"), FPL("/") }, |
| 1219 { FPL("foo"), FPL("foo/") }, |
| 1220 { FPL("foo/"), FPL("foo/") } |
| 1221 }; |
| 1222 for (size_t i = 0; i < arraysize(cases); ++i) { |
| 1223 FilePath input = FilePath(cases[i].input).NormalizePathSeparators(); |
| 1224 FilePath expected = FilePath(cases[i].expected).NormalizePathSeparators(); |
| 1225 EXPECT_EQ(expected.value(), input.AsEndingWithSeparator().value()); |
| 1226 } |
| 1227 } |
| 1228 |
1202 } // namespace base | 1229 } // namespace base |
OLD | NEW |