OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 "net/ftp/ftp_directory_listing_parser_unittest.h" | 5 #include "net/ftp/ftp_directory_listing_parser_unittest.h" |
6 | 6 |
7 #include "base/format_macros.h" | 7 #include "base/format_macros.h" |
8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
9 #include "net/ftp/ftp_directory_listing_parser_windows.h" | 9 #include "net/ftp/ftp_directory_listing_parser_windows.h" |
10 | 10 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 { "01-06-79 02:42AM 458 Corner4", | 43 { "01-06-79 02:42AM 458 Corner4", |
44 net::FtpDirectoryListingEntry::FILE, "Corner4", 458, | 44 net::FtpDirectoryListingEntry::FILE, "Corner4", 458, |
45 2079, 1, 6, 2, 42 }, | 45 2079, 1, 6, 2, 42 }, |
46 #endif // !defined (OS_LINUX) | 46 #endif // !defined (OS_LINUX) |
47 { "01-06-1979 02:42AM 458 Readme.txt", | 47 { "01-06-1979 02:42AM 458 Readme.txt", |
48 net::FtpDirectoryListingEntry::FILE, "Readme.txt", 458, | 48 net::FtpDirectoryListingEntry::FILE, "Readme.txt", 458, |
49 1979, 1, 6, 2, 42 }, | 49 1979, 1, 6, 2, 42 }, |
50 { "11-02-09 05:32PM <DIR> My Directory", | 50 { "11-02-09 05:32PM <DIR> My Directory", |
51 net::FtpDirectoryListingEntry::DIRECTORY, "My Directory", -1, | 51 net::FtpDirectoryListingEntry::DIRECTORY, "My Directory", -1, |
52 2009, 11, 2, 17, 32 }, | 52 2009, 11, 2, 17, 32 }, |
| 53 { "12-25-10 12:00AM <DIR> Christmas Midnight", |
| 54 net::FtpDirectoryListingEntry::DIRECTORY, "Christmas Midnight", -1, |
| 55 2010, 12, 25, 0, 0 }, |
| 56 { "12-25-10 12:00PM <DIR> Christmas Midday", |
| 57 net::FtpDirectoryListingEntry::DIRECTORY, "Christmas Midday", -1, |
| 58 2010, 12, 25, 12, 0 }, |
53 }; | 59 }; |
54 for (size_t i = 0; i < arraysize(good_cases); i++) { | 60 for (size_t i = 0; i < arraysize(good_cases); i++) { |
55 SCOPED_TRACE(StringPrintf("Test[%" PRIuS "]: %s", i, good_cases[i].input)); | 61 SCOPED_TRACE(StringPrintf("Test[%" PRIuS "]: %s", i, good_cases[i].input)); |
56 | 62 |
57 net::FtpDirectoryListingParserWindows parser; | 63 net::FtpDirectoryListingParserWindows parser; |
58 RunSingleLineTestCase(&parser, good_cases[i]); | 64 RunSingleLineTestCase(&parser, good_cases[i]); |
59 } | 65 } |
60 } | 66 } |
61 | 67 |
62 TEST_F(FtpDirectoryListingParserWindowsTest, Bad) { | 68 TEST_F(FtpDirectoryListingParserWindowsTest, Bad) { |
63 const char* bad_cases[] = { | 69 const char* bad_cases[] = { |
64 "", | 70 "", |
65 "garbage", | 71 "garbage", |
66 "11-02-09 05:32PM <GARBAGE> NT", | 72 "11-02-09 05:32PM <GARBAGE> NT", |
67 "11-02-09 05:32 <DIR> NT", | 73 "11-02-09 05:32 <DIR> NT", |
68 "11-FEB-09 05:32PM <DIR> NT", | 74 "11-FEB-09 05:32PM <DIR> NT", |
69 "11-02 05:32PM <DIR> NT", | 75 "11-02 05:32PM <DIR> NT", |
70 "11-02-09 05:32PM -1 NT", | 76 "11-02-09 05:32PM -1 NT", |
| 77 "99-25-10 12:00AM 0 months out of range", |
| 78 "12-99-10 12:00AM 0 days out of range", |
| 79 "12-25-10 99:00AM 0 hours out of range", |
| 80 "12-25-10 12:99AM 0 minutes out of range", |
| 81 "12-25-10 12:00ZM 0 what does ZM mean", |
71 }; | 82 }; |
72 for (size_t i = 0; i < arraysize(bad_cases); i++) { | 83 for (size_t i = 0; i < arraysize(bad_cases); i++) { |
73 net::FtpDirectoryListingParserWindows parser; | 84 net::FtpDirectoryListingParserWindows parser; |
74 EXPECT_FALSE(parser.ConsumeLine(UTF8ToUTF16(bad_cases[i]))) << bad_cases[i]; | 85 EXPECT_FALSE(parser.ConsumeLine(UTF8ToUTF16(bad_cases[i]))) << bad_cases[i]; |
75 } | 86 } |
76 } | 87 } |
77 | 88 |
78 } // namespace | 89 } // namespace |
OLD | NEW |