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

Unified Diff: base/file_path_unittest.cc

Issue 150109: make FilePath:IsParent use case-insensitive compare for drive letters on windows (Closed)
Patch Set: one more Created 11 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 55efeace224742c02f31e3b65f47ec285051182e..ca30baa551eecf695fe7fd5e58829089f614856b 100644
--- a/base/file_path_unittest.cc
+++ b/base/file_path_unittest.cc
@@ -450,10 +450,18 @@ TEST_F(FilePathTest, IsParentTest) {
{ { FPL(""), FPL("foo") }, false},
#if defined(FILE_PATH_USES_DRIVE_LETTERS)
{ { FPL("c:/foo/bar"), FPL("c:/foo/bar/baz") }, true},
+ { { FPL("E:/foo/bar"), FPL("e:/foo/bar/baz") }, true},
+ { { FPL("f:/foo/bar"), FPL("F:/foo/bar/baz") }, true},
+ { { FPL("E:/Foo/bar"), FPL("e:/foo/bar/baz") }, false},
+ { { FPL("f:/foo/bar"), FPL("F:/foo/Bar/baz") }, false},
{ { FPL("c:/"), FPL("c:/foo/bar/baz") }, true},
{ { FPL("c:"), FPL("c:/foo/bar/baz") }, true},
{ { FPL("c:/foo/bar"), FPL("d:/foo/bar/baz") }, false},
+ { { FPL("c:/foo/bar"), FPL("D:/foo/bar/baz") }, false},
+ { { FPL("C:/foo/bar"), FPL("d:/foo/bar/baz") }, false},
{ { FPL("c:/foo/bar"), FPL("c:/foo2/bar/baz") }, false},
+ { { FPL("e:/foo/bar"), FPL("E:/foo2/bar/baz") }, false},
+ { { FPL("F:/foo/bar"), FPL("f:/foo2/bar/baz") }, false},
{ { FPL("c:/foo/bar"), FPL("c:/foo/bar2/baz") }, false},
#endif // FILE_PATH_USES_DRIVE_LETTERS
#if defined(FILE_PATH_USES_WIN_SEPARATORS)
@@ -464,7 +472,7 @@ TEST_F(FilePathTest, IsParentTest) {
{ { FPL(""), FPL("\\foo\\bar\\baz") }, false},
{ { FPL("\\foo\\bar"), FPL("\\foo2\\bar\\baz") }, false},
{ { FPL("\\foo\\bar"), FPL("\\foo\\bar2\\baz") }, false},
-#endif // FILE_PATH_USES_DRIVE_LETTERS
+#endif // FILE_PATH_USES_WIN_SEPARATORS
};
for (size_t i = 0; i < arraysize(cases); ++i) {
@@ -477,6 +485,67 @@ TEST_F(FilePathTest, IsParentTest) {
}
}
+TEST_F(FilePathTest, EqualityTest) {
+ const struct BinaryBooleanTestData cases[] = {
+ { { FPL("/foo/bar/baz"), FPL("/foo/bar/baz") }, true},
+ { { FPL("/foo/bar"), FPL("/foo/bar/baz") }, false},
+ { { FPL("/foo/bar/baz"), FPL("/foo/bar") }, false},
+ { { FPL("//foo/bar/"), FPL("//foo/bar/") }, true},
+ { { FPL("/foo/bar"), FPL("/foo2/bar") }, false},
+ { { FPL("/foo/bar.txt"), FPL("/foo/bar") }, false},
+ { { FPL("foo/bar"), FPL("foo/bar") }, true},
+ { { FPL("foo/bar"), FPL("foo/bar/baz") }, false},
+ { { FPL(""), FPL("foo") }, false},
+#if defined(FILE_PATH_USES_DRIVE_LETTERS)
+ { { FPL("c:/foo/bar"), FPL("c:/foo/bar") }, true},
+ { { FPL("E:/foo/bar"), FPL("e:/foo/bar") }, true},
+ { { FPL("f:/foo/bar"), FPL("F:/foo/bar") }, true},
+ { { FPL("E:/Foo/bar"), FPL("e:/foo/bar") }, false},
+ { { FPL("f:/foo/bar"), FPL("F:/foo/Bar") }, false},
+ { { FPL("c:/"), FPL("c:/") }, true},
+ { { FPL("c:"), FPL("c:") }, true},
+ { { FPL("c:/foo/bar"), FPL("d:/foo/bar") }, false},
+ { { FPL("c:/foo/bar"), FPL("D:/foo/bar") }, false},
+ { { FPL("C:/foo/bar"), FPL("d:/foo/bar") }, false},
+ { { FPL("c:/foo/bar"), FPL("c:/foo2/bar") }, false},
+#endif // FILE_PATH_USES_DRIVE_LETTERS
+#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("\\"), FPL("\\") }, true},
+ { { FPL("\\"), FPL("/") }, false},
+ { { FPL(""), FPL("\\") }, false},
+ { { FPL("\\foo\\bar"), FPL("\\foo2\\bar") }, false},
+ { { FPL("\\foo\\bar"), FPL("\\foo\\bar2") }, false},
+#if defined(FILE_PATH_USES_DRIVE_LETTERS)
+ { { FPL("c:\\foo\\bar"), FPL("c:\\foo\\bar") }, true},
+ { { FPL("E:\\foo\\bar"), FPL("e:\\foo\\bar") }, true},
+ { { FPL("f:\\foo\\bar"), FPL("F:\\foo/bar") }, false},
+#endif // FILE_PATH_USES_DRIVE_LETTERS
+#endif // FILE_PATH_USES_WIN_SEPARATORS
+ };
+
+ for (size_t i = 0; i < arraysize(cases); ++i) {
+ FilePath a(cases[i].inputs[0]);
+ FilePath b(cases[i].inputs[1]);
+
+ EXPECT_EQ(a == b, cases[i].expected) <<
+ "equality i: " << i << ", a: " << a.value() << ", b: " <<
+ b.value();
+ }
+
+
+ for (size_t i = 0; i < arraysize(cases); ++i) {
+ FilePath a(cases[i].inputs[0]);
+ FilePath b(cases[i].inputs[1]);
+
+ EXPECT_EQ(a != b, !cases[i].expected) <<
+ "inequality i: " << i << ", a: " << a.value() << ", b: " <<
+ b.value();
+ }
+}
+
TEST_F(FilePathTest, Extension) {
FilePath base_dir(FILE_PATH_LITERAL("base_dir"));
« 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