summaryrefslogtreecommitdiffstats
path: root/base/file_path_unittest.cc
diff options
context:
space:
mode:
authoravi@chromium.org <avi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-29 20:31:29 +0000
committeravi@chromium.org <avi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-29 20:31:29 +0000
commitf1ce6e6c4d6bb08bd1534170b4647aabf8ff25ef (patch)
tree9166583bf968e8b0e780482823b2592fcade223f /base/file_path_unittest.cc
parent401392455919b47e7a85a20a058754e4b05da488 (diff)
downloadchromium_src-f1ce6e6c4d6bb08bd1534170b4647aabf8ff25ef.zip
chromium_src-f1ce6e6c4d6bb08bd1534170b4647aabf8ff25ef.tar.gz
chromium_src-f1ce6e6c4d6bb08bd1534170b4647aabf8ff25ef.tar.bz2
Allow extension extensions to be case-insensitive.
BUG=none TEST=try to load an extension with a capital letter or two in the extension's extension. It should load. Review URL: http://codereview.chromium.org/147017 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@19520 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/file_path_unittest.cc')
-rw-r--r--base/file_path_unittest.cc83
1 files changed, 57 insertions, 26 deletions
diff --git a/base/file_path_unittest.cc b/base/file_path_unittest.cc
index 0df6838..55efeac 100644
--- a/base/file_path_unittest.cc
+++ b/base/file_path_unittest.cc
@@ -435,35 +435,35 @@ TEST_F(FilePathTest, PathComponentsTest) {
TEST_F(FilePathTest, IsParentTest) {
const struct BinaryBooleanTestData cases[] = {
- { { FPL("/"), FPL("/foo/bar/baz") }, true},
- { { FPL("/foo/bar"), FPL("/foo/bar/baz") }, true},
- { { FPL("/foo/bar/"), FPL("/foo/bar/baz") }, true},
- { { FPL("//foo/bar/"), FPL("//foo/bar/baz") }, true},
- { { FPL("/foo/bar"), FPL("/foo2/bar/baz") }, false},
- { { FPL("/foo/bar.txt"), FPL("/foo/bar/baz") }, false},
- { { FPL("/foo/bar"), FPL("/foo/bar2/baz") }, false},
- { { FPL("/foo/bar"), FPL("/foo/bar") }, false},
- { { FPL("/foo/bar/baz"), FPL("/foo/bar") }, false},
- { { FPL("foo/bar"), FPL("foo/bar/baz") }, true},
- { { FPL("foo/bar"), FPL("foo2/bar/baz") }, false},
- { { FPL("foo/bar"), FPL("foo/bar2/baz") }, false},
- { { FPL(""), FPL("foo") }, false},
+ { { FPL("/"), FPL("/foo/bar/baz") }, true},
+ { { FPL("/foo/bar"), FPL("/foo/bar/baz") }, true},
+ { { FPL("/foo/bar/"), FPL("/foo/bar/baz") }, true},
+ { { FPL("//foo/bar/"), FPL("//foo/bar/baz") }, true},
+ { { FPL("/foo/bar"), FPL("/foo2/bar/baz") }, false},
+ { { FPL("/foo/bar.txt"), FPL("/foo/bar/baz") }, false},
+ { { FPL("/foo/bar"), FPL("/foo/bar2/baz") }, false},
+ { { FPL("/foo/bar"), FPL("/foo/bar") }, false},
+ { { FPL("/foo/bar/baz"), FPL("/foo/bar") }, false},
+ { { FPL("foo/bar"), FPL("foo/bar/baz") }, true},
+ { { FPL("foo/bar"), FPL("foo2/bar/baz") }, false},
+ { { FPL("foo/bar"), FPL("foo/bar2/baz") }, false},
+ { { FPL(""), FPL("foo") }, false},
#if defined(FILE_PATH_USES_DRIVE_LETTERS)
- { { FPL("c:/foo/bar"), FPL("c:/foo/bar/baz") }, true},
- { { 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("c:/foo2/bar/baz") }, false},
- { { FPL("c:/foo/bar"), FPL("c:/foo/bar2/baz") }, false},
+ { { FPL("c:/foo/bar"), FPL("c:/foo/bar/baz") }, true},
+ { { 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("c:/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)
- { { FPL("\\foo\\bar"), FPL("\\foo\\bar\\baz") }, true},
- { { FPL("\\foo/bar"), FPL("\\foo\\bar\\baz") }, true},
- { { FPL("\\foo/bar"), FPL("\\foo/bar/baz") }, true},
- { { FPL("\\"), FPL("\\foo\\bar\\baz") }, true},
- { { FPL(""), FPL("\\foo\\bar\\baz") }, false},
- { { FPL("\\foo\\bar"), FPL("\\foo2\\bar\\baz") }, false},
- { { FPL("\\foo\\bar"), FPL("\\foo\\bar2\\baz") }, false},
+ { { FPL("\\foo\\bar"), FPL("\\foo\\bar\\baz") }, true},
+ { { FPL("\\foo/bar"), FPL("\\foo\\bar\\baz") }, true},
+ { { FPL("\\foo/bar"), FPL("\\foo/bar/baz") }, true},
+ { { FPL("\\"), FPL("\\foo\\bar\\baz") }, true},
+ { { 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
};
@@ -634,3 +634,34 @@ TEST_F(FilePathTest, ReplaceExtension) {
", path: " << path.value() << ", replace: " << cases[i].inputs[1];
}
}
+
+TEST_F(FilePathTest, MatchesExtension) {
+ const struct BinaryBooleanTestData cases[] = {
+ { { FPL("foo"), FPL("") }, true},
+ { { FPL("foo"), FPL(".") }, false},
+ { { FPL("foo."), FPL("") }, false},
+ { { FPL("foo."), FPL(".") }, true},
+ { { FPL("foo.txt"), FPL(".dll") }, false},
+ { { FPL("foo.txt"), FPL(".txt") }, true},
+ { { FPL("foo.txt.dll"), FPL(".txt") }, false},
+ { { FPL("foo.txt.dll"), FPL(".dll") }, true},
+#if defined(FILE_PATH_USES_DRIVE_LETTERS)
+ { { FPL("c:/foo.txt.dll"), FPL(".txt") }, false},
+ { { FPL("c:/foo.txt"), FPL(".txt") }, true},
+#endif // FILE_PATH_USES_DRIVE_LETTERS
+#if defined(FILE_PATH_USES_WIN_SEPARATORS)
+ { { FPL("c:\\bar\\foo.txt.dll"), FPL(".txt") }, false},
+ { { FPL("c:\\bar\\foo.txt"), FPL(".txt") }, true},
+#endif // FILE_PATH_USES_DRIVE_LETTERS
+ { { FPL("/bar/foo.txt.dll"), FPL(".txt") }, false},
+ { { FPL("/bar/foo.txt"), FPL(".txt") }, true},
+ };
+
+ for (size_t i = 0; i < arraysize(cases); ++i) {
+ FilePath path(cases[i].inputs[0]);
+ FilePath::StringType ext(cases[i].inputs[1]);
+
+ EXPECT_EQ(cases[i].expected, path.MatchesExtension(ext)) <<
+ "i: " << i << ", path: " << path.value() << ", ext: " << ext;
+ }
+}