| 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 "net/ftp/ftp_directory_listing_parser_ls.h" | 8 #include "net/ftp/ftp_directory_listing_parser_ls.h" |
| 9 | 9 |
| 10 namespace { | 10 namespace { |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 2007, 2, 20, 0, 0 }, | 33 2007, 2, 20, 0, 0 }, |
| 34 { "drwxr-xr-x 4 (?) (?) 4096 Apr 8 2007 jigdo", | 34 { "drwxr-xr-x 4 (?) (?) 4096 Apr 8 2007 jigdo", |
| 35 net::FtpDirectoryListingEntry::DIRECTORY, "jigdo", -1, | 35 net::FtpDirectoryListingEntry::DIRECTORY, "jigdo", -1, |
| 36 2007, 4, 8, 0, 0 }, | 36 2007, 4, 8, 0, 0 }, |
| 37 { "drwx-wx-wt 2 root wheel 512 Jul 1 02:15 incoming", | 37 { "drwx-wx-wt 2 root wheel 512 Jul 1 02:15 incoming", |
| 38 net::FtpDirectoryListingEntry::DIRECTORY, "incoming", -1, | 38 net::FtpDirectoryListingEntry::DIRECTORY, "incoming", -1, |
| 39 now_exploded.year, 7, 1, 2, 15 }, | 39 now_exploded.year, 7, 1, 2, 15 }, |
| 40 { "-rw-r--r-- 1 2 3 3447432 May 18 2009 Foo - Manual.pdf", | 40 { "-rw-r--r-- 1 2 3 3447432 May 18 2009 Foo - Manual.pdf", |
| 41 net::FtpDirectoryListingEntry::FILE, "Foo - Manual.pdf", 3447432, | 41 net::FtpDirectoryListingEntry::FILE, "Foo - Manual.pdf", 3447432, |
| 42 2009, 5, 18, 0, 0 }, | 42 2009, 5, 18, 0, 0 }, |
| 43 |
| 44 // Tests for the wu-ftpd variant: |
| 45 { "drwxr-xr-x 2 sys 512 Mar 27 2009 pub", |
| 46 net::FtpDirectoryListingEntry::DIRECTORY, "pub", -1, |
| 47 2009, 3, 27, 0, 0 }, |
| 48 { "lrwxrwxrwx 0 0 26 Sep 18 2008 pub -> vol/1/.CLUSTER/var_ftp/pub", |
| 49 net::FtpDirectoryListingEntry::SYMLINK, "pub", -1, |
| 50 2008, 9, 18, 0, 0 }, |
| 51 { "drwxr-xr-x (?) (?) 4096 Apr 8 2007 jigdo", |
| 52 net::FtpDirectoryListingEntry::DIRECTORY, "jigdo", -1, |
| 53 2007, 4, 8, 0, 0 }, |
| 54 { "-rw-r--r-- 2 3 3447432 May 18 2009 Foo - Manual.pdf", |
| 55 net::FtpDirectoryListingEntry::FILE, "Foo - Manual.pdf", 3447432, |
| 56 2009, 5, 18, 0, 0 }, |
| 43 }; | 57 }; |
| 44 for (size_t i = 0; i < arraysize(good_cases); i++) { | 58 for (size_t i = 0; i < arraysize(good_cases); i++) { |
| 45 SCOPED_TRACE(StringPrintf("Test[%" PRIuS "]: %s", i, good_cases[i].input)); | 59 SCOPED_TRACE(StringPrintf("Test[%" PRIuS "]: %s", i, good_cases[i].input)); |
| 46 | 60 |
| 47 net::FtpDirectoryListingParserLs parser; | 61 net::FtpDirectoryListingParserLs parser; |
| 48 RunSingleLineTestCase(&parser, good_cases[i]); | 62 RunSingleLineTestCase(&parser, good_cases[i]); |
| 49 } | 63 } |
| 50 } | 64 } |
| 51 | 65 |
| 52 TEST_F(FtpDirectoryListingParserLsTest, Bad) { | 66 TEST_F(FtpDirectoryListingParserLsTest, Bad) { |
| 53 const char* bad_cases[] = { | 67 const char* bad_cases[] = { |
| 54 "garbage", | 68 "garbage", |
| 69 "-rw-r--r-- ftp ftp", |
| 70 "-rw-r--rgb ftp ftp 528 Nov 01 2007 README", |
| 71 "-rw-rgbr-- ftp ftp 528 Nov 01 2007 README", |
| 72 "qrwwr--r-- ftp ftp 528 Nov 01 2007 README", |
| 73 "-rw-r--r-- ftp ftp -528 Nov 01 2007 README", |
| 74 "-rw-r--r-- ftp ftp 528 Foo 01 2007 README", |
| 55 "-rw-r--r-- 1 ftp ftp", | 75 "-rw-r--r-- 1 ftp ftp", |
| 56 "-rw-r--rgb 1 ftp ftp 528 Nov 01 2007 README", | 76 "-rw-r--rgb 1 ftp ftp 528 Nov 01 2007 README", |
| 57 "-rw-rgbr-- 1 ftp ftp 528 Nov 01 2007 README", | 77 "-rw-rgbr-- 1 ftp ftp 528 Nov 01 2007 README", |
| 58 "qrwwr--r-- 1 ftp ftp 528 Nov 01 2007 README", | 78 "qrwwr--r-- 1 ftp ftp 528 Nov 01 2007 README", |
| 59 "-rw-r--r-- -1 ftp ftp 528 Nov 01 2007 README", | |
| 60 "-rw-r--r-- 1 ftp ftp -528 Nov 01 2007 README", | 79 "-rw-r--r-- 1 ftp ftp -528 Nov 01 2007 README", |
| 61 "-rw-r--r-- 1 ftp ftp 528 Foo 01 2007 README", | 80 "-rw-r--r-- 1 ftp ftp 528 Foo 01 2007 README", |
| 62 }; | 81 }; |
| 63 for (size_t i = 0; i < arraysize(bad_cases); i++) { | 82 for (size_t i = 0; i < arraysize(bad_cases); i++) { |
| 64 net::FtpDirectoryListingParserLs parser; | 83 net::FtpDirectoryListingParserLs parser; |
| 65 EXPECT_FALSE(parser.ConsumeLine(UTF8ToUTF16(bad_cases[i]))) << bad_cases[i]; | 84 EXPECT_FALSE(parser.ConsumeLine(UTF8ToUTF16(bad_cases[i]))) << bad_cases[i]; |
| 66 } | 85 } |
| 67 } | 86 } |
| 68 | 87 |
| 69 } // namespace | 88 } // namespace |
| OLD | NEW |