| OLD | NEW |
| (Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "net/ftp/ftp_directory_listing_parser_unittest.h" |
| 6 |
| 7 #include "base/format_macros.h" |
| 8 #include "net/ftp/ftp_directory_listing_parser_windows.h" |
| 9 |
| 10 namespace { |
| 11 |
| 12 typedef net::FtpDirectoryListingParserTest FtpDirectoryListingParserWindowsTest; |
| 13 |
| 14 TEST_F(FtpDirectoryListingParserWindowsTest, Good) { |
| 15 base::Time::Exploded now_exploded; |
| 16 base::Time::Now().LocalExplode(&now_exploded); |
| 17 |
| 18 const struct SingleLineTestData good_cases[] = { |
| 19 { "11-02-09 05:32PM <DIR> NT", |
| 20 net::FtpDirectoryListingEntry::DIRECTORY, "NT", -1, |
| 21 2009, 11, 2, 17, 32 }, |
| 22 { "01-06-09 02:42PM 458 Readme.txt", |
| 23 net::FtpDirectoryListingEntry::FILE, "Readme.txt", 458, |
| 24 2009, 1, 6, 14, 42 }, |
| 25 { "01-06-09 02:42AM 1 Readme.txt", |
| 26 net::FtpDirectoryListingEntry::FILE, "Readme.txt", 1, |
| 27 2009, 1, 6, 2, 42 }, |
| 28 { "01-06-01 02:42AM 458 Readme.txt", |
| 29 net::FtpDirectoryListingEntry::FILE, "Readme.txt", 458, |
| 30 2001, 1, 6, 2, 42 }, |
| 31 { "01-06-00 02:42AM 458 Corner1.txt", |
| 32 net::FtpDirectoryListingEntry::FILE, "Corner1.txt", 458, |
| 33 2000, 1, 6, 2, 42 }, |
| 34 { "01-06-99 02:42AM 458 Corner2.txt", |
| 35 net::FtpDirectoryListingEntry::FILE, "Corner2.txt", 458, |
| 36 1999, 1, 6, 2, 42 }, |
| 37 { "01-06-80 02:42AM 458 Corner3.txt", |
| 38 net::FtpDirectoryListingEntry::FILE, "Corner3.txt", 458, |
| 39 1980, 1, 6, 2, 42 }, |
| 40 #if !defined(OS_LINUX) |
| 41 // TODO(phajdan.jr): Re-enable when 2038-year problem is fixed on Linux. |
| 42 { "01-06-79 02:42AM 458 Corner4", |
| 43 net::FtpDirectoryListingEntry::FILE, "Corner4", 458, |
| 44 2079, 1, 6, 2, 42 }, |
| 45 #endif // !defined (OS_LINUX) |
| 46 { "01-06-1979 02:42AM 458 Readme.txt", |
| 47 net::FtpDirectoryListingEntry::FILE, "Readme.txt", 458, |
| 48 1979, 1, 6, 2, 42 }, |
| 49 }; |
| 50 for (size_t i = 0; i < arraysize(good_cases); i++) { |
| 51 SCOPED_TRACE(StringPrintf("Test[%" PRIuS "]: %s", i, good_cases[i].input)); |
| 52 |
| 53 net::FtpDirectoryListingParserWindows parser; |
| 54 RunSingleLineTestCase(&parser, good_cases[i]); |
| 55 } |
| 56 } |
| 57 |
| 58 TEST_F(FtpDirectoryListingParserWindowsTest, Bad) { |
| 59 const char* bad_cases[] = { |
| 60 "", |
| 61 "garbage", |
| 62 "11-02-09 05:32PM <GARBAGE> NT", |
| 63 "11-02-09 05:32 <DIR> NT", |
| 64 "11-FEB-09 05:32PM <DIR> NT", |
| 65 "11-02 05:32PM <DIR> NT", |
| 66 "11-02-09 05:32PM -1 NT", |
| 67 }; |
| 68 for (size_t i = 0; i < arraysize(bad_cases); i++) { |
| 69 net::FtpDirectoryListingParserWindows parser; |
| 70 EXPECT_FALSE(parser.ConsumeLine(UTF8ToUTF16(bad_cases[i]))) << bad_cases[i]; |
| 71 } |
| 72 } |
| 73 |
| 74 } // namespace |
| OLD | NEW |