Chromium Code Reviews| Index: base/file_path_unittest.cc |
| =================================================================== |
| --- base/file_path_unittest.cc (revision 28751) |
| +++ base/file_path_unittest.cc (working copy) |
| @@ -312,6 +312,70 @@ |
| } |
| } |
| +TEST_F(FilePathTest, StripTrailingSeparators) { |
| + const struct UnaryTestData cases[] = { |
| + { FPL(""), FPL("") }, |
| + { FPL("/"), FPL("/") }, |
| + { FPL("//"), FPL("//") }, |
|
Erik does not do reviews
2009/10/13 16:57:01
is this use case for windows network paths using /
|
| + { FPL("///"), FPL("/") }, |
| + { FPL("////"), FPL("/") }, |
| + { FPL("a/"), FPL("a") }, |
| + { FPL("a//"), FPL("a") }, |
| + { FPL("a///"), FPL("a") }, |
| + { FPL("a////"), FPL("a") }, |
| + { FPL("/a"), FPL("/a") }, |
| + { FPL("/a/"), FPL("/a") }, |
| + { FPL("/a//"), FPL("/a") }, |
| + { FPL("/a///"), FPL("/a") }, |
| + { FPL("/a////"), FPL("/a") }, |
| +#if defined(FILE_PATH_USES_DRIVE_LETTERS) |
| + { FPL("c:"), FPL("c:") }, |
| + { FPL("c:/"), FPL("c:/") }, |
| + { FPL("c://"), FPL("c://") }, |
|
Erik does not do reviews
2009/10/13 16:57:01
just curious, what is this use case for?
|
| + { FPL("c:///"), FPL("c:/") }, |
| + { FPL("c:////"), FPL("c:/") }, |
| + { FPL("c:/a"), FPL("c:/a") }, |
| + { FPL("c:/a/"), FPL("c:/a") }, |
| + { FPL("c:/a//"), FPL("c:/a") }, |
| + { FPL("c:/a///"), FPL("c:/a") }, |
| + { FPL("c:/a////"), FPL("c:/a") }, |
| +#endif // FILE_PATH_USES_DRIVE_LETTERS |
| +#if defined(FILE_PATH_USES_WIN_SEPARATORS) |
| + { FPL("\\"), FPL("\\") }, |
| + { FPL("\\\\"), FPL("\\\\") }, |
| + { FPL("\\\\\\"), FPL("\\") }, |
| + { FPL("\\\\\\\\"), FPL("\\") }, |
| + { FPL("a\\"), FPL("a") }, |
| + { FPL("a\\\\"), FPL("a") }, |
| + { FPL("a\\\\\\"), FPL("a") }, |
| + { FPL("a\\\\\\\\"), FPL("a") }, |
| + { FPL("\\a"), FPL("\\a") }, |
| + { FPL("\\a\\"), FPL("\\a") }, |
| + { FPL("\\a\\\\"), FPL("\\a") }, |
| + { FPL("\\a\\\\\\"), FPL("\\a") }, |
| + { FPL("\\a\\\\\\\\"), FPL("\\a") }, |
| +#if defined(FILE_PATH_USES_DRIVE_LETTERS) |
| + { FPL("c:\\"), FPL("c:\\") }, |
| + { FPL("c:\\\\"), FPL("c:\\\\") }, |
| + { FPL("c:\\\\\\"), FPL("c:\\") }, |
| + { FPL("c:\\\\\\\\"), FPL("c:\\") }, |
| + { FPL("c:\\a"), FPL("c:\\a") }, |
| + { FPL("c:\\a\\"), FPL("c:\\a") }, |
| + { FPL("c:\\a\\\\"), FPL("c:\\a") }, |
| + { FPL("c:\\a\\\\\\"), FPL("c:\\a") }, |
| + { FPL("c:\\a\\\\\\\\"), FPL("c:\\a") }, |
| +#endif // FILE_PATH_USES_DRIVE_LETTERS |
| +#endif // FILE_PATH_USES_WIN_SEPARATORS |
| + }; |
| + |
| + for (size_t i = 0; i < arraysize(cases); ++i) { |
| + FilePath input(cases[i].input); |
| + FilePath observed = input.StripTrailingSeparators(); |
| + EXPECT_EQ(FilePath::StringType(cases[i].expected), observed.value()) << |
| + "i: " << i << ", input: " << input.value(); |
| + } |
| +} |
| + |
| TEST_F(FilePathTest, IsAbsolute) { |
| const struct UnaryBooleanTestData cases[] = { |
| { FPL(""), false }, |