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

Side by Side Diff: base/files/file_path_unittest.cc

Issue 13196006: Move path functions from file_util to FilePath object. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: git try Created 7 years, 8 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
OLDNEW
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
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698