| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "base/stringprintf.h" |
| 9 #include "net/ftp/ftp_directory_listing_parser_windows.h" | 10 #include "net/ftp/ftp_directory_listing_parser_windows.h" |
| 10 | 11 |
| 11 namespace { | 12 namespace { |
| 12 | 13 |
| 13 typedef net::FtpDirectoryListingParserTest FtpDirectoryListingParserWindowsTest; | 14 typedef net::FtpDirectoryListingParserTest FtpDirectoryListingParserWindowsTest; |
| 14 | 15 |
| 15 TEST_F(FtpDirectoryListingParserWindowsTest, Good) { | 16 TEST_F(FtpDirectoryListingParserWindowsTest, Good) { |
| 16 base::Time::Exploded now_exploded; | 17 base::Time::Exploded now_exploded; |
| 17 base::Time::Now().LocalExplode(&now_exploded); | 18 base::Time::Now().LocalExplode(&now_exploded); |
| 18 | 19 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 net::FtpDirectoryListingEntry::DIRECTORY, "My Directory", -1, | 52 net::FtpDirectoryListingEntry::DIRECTORY, "My Directory", -1, |
| 52 2009, 11, 2, 17, 32 }, | 53 2009, 11, 2, 17, 32 }, |
| 53 { "12-25-10 12:00AM <DIR> Christmas Midnight", | 54 { "12-25-10 12:00AM <DIR> Christmas Midnight", |
| 54 net::FtpDirectoryListingEntry::DIRECTORY, "Christmas Midnight", -1, | 55 net::FtpDirectoryListingEntry::DIRECTORY, "Christmas Midnight", -1, |
| 55 2010, 12, 25, 0, 0 }, | 56 2010, 12, 25, 0, 0 }, |
| 56 { "12-25-10 12:00PM <DIR> Christmas Midday", | 57 { "12-25-10 12:00PM <DIR> Christmas Midday", |
| 57 net::FtpDirectoryListingEntry::DIRECTORY, "Christmas Midday", -1, | 58 net::FtpDirectoryListingEntry::DIRECTORY, "Christmas Midday", -1, |
| 58 2010, 12, 25, 12, 0 }, | 59 2010, 12, 25, 12, 0 }, |
| 59 }; | 60 }; |
| 60 for (size_t i = 0; i < arraysize(good_cases); i++) { | 61 for (size_t i = 0; i < arraysize(good_cases); i++) { |
| 61 SCOPED_TRACE(StringPrintf("Test[%" PRIuS "]: %s", i, good_cases[i].input)); | 62 SCOPED_TRACE(base::StringPrintf("Test[%" PRIuS "]: %s", i, |
| 63 good_cases[i].input)); |
| 62 | 64 |
| 63 net::FtpDirectoryListingParserWindows parser; | 65 net::FtpDirectoryListingParserWindows parser; |
| 64 RunSingleLineTestCase(&parser, good_cases[i]); | 66 RunSingleLineTestCase(&parser, good_cases[i]); |
| 65 } | 67 } |
| 66 } | 68 } |
| 67 | 69 |
| 68 TEST_F(FtpDirectoryListingParserWindowsTest, Bad) { | 70 TEST_F(FtpDirectoryListingParserWindowsTest, Bad) { |
| 69 const char* bad_cases[] = { | 71 const char* bad_cases[] = { |
| 70 "", | 72 "", |
| 71 "garbage", | 73 "garbage", |
| 72 "11-02-09 05:32PM <GARBAGE> NT", | 74 "11-02-09 05:32PM <GARBAGE> NT", |
| 73 "11-02-09 05:32 <DIR> NT", | 75 "11-02-09 05:32 <DIR> NT", |
| 74 "11-FEB-09 05:32PM <DIR> NT", | 76 "11-FEB-09 05:32PM <DIR> NT", |
| 75 "11-02 05:32PM <DIR> NT", | 77 "11-02 05:32PM <DIR> NT", |
| 76 "11-02-09 05:32PM -1 NT", | 78 "11-02-09 05:32PM -1 NT", |
| 77 "99-25-10 12:00AM 0 months out of range", | 79 "99-25-10 12:00AM 0 months out of range", |
| 78 "12-99-10 12:00AM 0 days out of range", | 80 "12-99-10 12:00AM 0 days out of range", |
| 79 "12-25-10 99:00AM 0 hours out of range", | 81 "12-25-10 99:00AM 0 hours out of range", |
| 80 "12-25-10 12:99AM 0 minutes out of range", | 82 "12-25-10 12:99AM 0 minutes out of range", |
| 81 "12-25-10 12:00ZM 0 what does ZM mean", | 83 "12-25-10 12:00ZM 0 what does ZM mean", |
| 82 }; | 84 }; |
| 83 for (size_t i = 0; i < arraysize(bad_cases); i++) { | 85 for (size_t i = 0; i < arraysize(bad_cases); i++) { |
| 84 net::FtpDirectoryListingParserWindows parser; | 86 net::FtpDirectoryListingParserWindows parser; |
| 85 EXPECT_FALSE(parser.ConsumeLine(UTF8ToUTF16(bad_cases[i]))) << bad_cases[i]; | 87 EXPECT_FALSE(parser.ConsumeLine(UTF8ToUTF16(bad_cases[i]))) << bad_cases[i]; |
| 86 } | 88 } |
| 87 } | 89 } |
| 88 | 90 |
| 89 } // namespace | 91 } // namespace |
| OLD | NEW |