| Index: base/file_path_unittest.cc
|
| ===================================================================
|
| --- base/file_path_unittest.cc (revision 19502)
|
| +++ base/file_path_unittest.cc (working copy)
|
| @@ -634,3 +634,34 @@
|
| ", 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;
|
| + }
|
| +}
|
|
|