| OLD | NEW |
| 1 // Copyright (c) 2010 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 "base/stringprintf.h" |
| 10 #include "net/ftp/ftp_directory_listing_parser_mlsd.h" | 10 #include "net/ftp/ftp_directory_listing_parser_mlsd.h" |
| 11 | 11 |
| 12 namespace { | 12 namespace { |
| 13 | 13 |
| 14 typedef net::FtpDirectoryListingParserTest FtpDirectoryListingParserMlsdTest; | 14 typedef net::FtpDirectoryListingParserTest FtpDirectoryListingParserMlsdTest; |
| 15 | 15 |
| 16 TEST_F(FtpDirectoryListingParserMlsdTest, Good) { | 16 TEST_F(FtpDirectoryListingParserMlsdTest, Good) { |
| 17 base::Time::Exploded now_exploded; | |
| 18 base::Time::Now().LocalExplode(&now_exploded); | |
| 19 | |
| 20 const struct SingleLineTestData good_cases[] = { | 17 const struct SingleLineTestData good_cases[] = { |
| 21 { "type=file;size=380565;modify=20030606190749; README", | 18 { "type=file;size=380565;modify=20030606190749; README", |
| 22 net::FtpDirectoryListingEntry::FILE, "README", 380565, | 19 net::FtpDirectoryListingEntry::FILE, "README", 380565, |
| 23 2003, 6, 6, 19, 7 }, | 20 2003, 6, 6, 19, 7 }, |
| 24 { "type=dir;sizd=512;modify=20031021200128; pub", | 21 { "type=dir;sizd=512;modify=20031021200128; pub", |
| 25 net::FtpDirectoryListingEntry::DIRECTORY, "pub", -1, | 22 net::FtpDirectoryListingEntry::DIRECTORY, "pub", -1, |
| 26 2003, 10, 21, 20, 1 }, | 23 2003, 10, 21, 20, 1 }, |
| 27 { "type=dir;sizd=512;modify=20091009080706;UNIX.mode=0755; pub", | 24 { "type=dir;sizd=512;modify=20091009080706;UNIX.mode=0755; pub", |
| 28 net::FtpDirectoryListingEntry::DIRECTORY, "pub", -1, | 25 net::FtpDirectoryListingEntry::DIRECTORY, "pub", -1, |
| 29 2009, 10, 9, 8, 7 }, | 26 2009, 10, 9, 8, 7 }, |
| (...skipping 11 matching lines...) Expand all Loading... |
| 41 } | 38 } |
| 42 | 39 |
| 43 TEST_F(FtpDirectoryListingParserMlsdTest, Bad) { | 40 TEST_F(FtpDirectoryListingParserMlsdTest, Bad) { |
| 44 const char* bad_cases[] = { | 41 const char* bad_cases[] = { |
| 45 "", | 42 "", |
| 46 " ", | 43 " ", |
| 47 " ", | 44 " ", |
| 48 ";", | 45 ";", |
| 49 "; ", | 46 "; ", |
| 50 " ;", | 47 " ;", |
| 48 " foo", |
| 51 "garbage", | 49 "garbage", |
| 52 "total 5", | 50 "total 5", |
| 53 "type=file;size=380565;modify=20030606190749;README", | 51 "type=file;size=380565;modify=20030606190749;README", |
| 54 "type=file;size=380565;modify=20030606190749;", | 52 "type=file;size=380565;modify=20030606190749;", |
| 55 "type=file;size=380565;modify=20030606190749", | 53 "type=file;size=380565;modify=20030606190749", |
| 56 "size=380565;modify=20030606190749; README", | 54 "size=380565;modify=20030606190749; README", |
| 57 "type=file;modify=20030606190749; README", | 55 "type=file;modify=20030606190749; README", |
| 58 "type=file;size=380565; README", | 56 "type=file;size=380565; README", |
| 59 "type=file; size=380565; modify=20030606190749; README", | 57 "type=file; size=380565; modify=20030606190749; README", |
| 60 " type=file;size=380565;modify=20030606190749; README", | 58 " type=file;size=380565;modify=20030606190749; README", |
| 61 "type=file;size=garbage;modify=20030606190749; README", | 59 "type=file;size=garbage;modify=20030606190749; README", |
| 62 "type=file;size=380565;modify=garbage; README", | 60 "type=file;size=380565;modify=garbage; README", |
| 63 }; | 61 }; |
| 64 for (size_t i = 0; i < arraysize(bad_cases); i++) { | 62 for (size_t i = 0; i < arraysize(bad_cases); i++) { |
| 65 net::FtpDirectoryListingParserMlsd parser; | 63 net::FtpDirectoryListingParserMlsd parser; |
| 66 EXPECT_FALSE(parser.ConsumeLine(UTF8ToUTF16(bad_cases[i]))) << bad_cases[i]; | 64 EXPECT_FALSE(parser.ConsumeLine(UTF8ToUTF16(bad_cases[i]))) << bad_cases[i]; |
| 67 } | 65 } |
| 68 } | 66 } |
| 69 | 67 |
| 70 } // namespace | 68 } // namespace |
| OLD | NEW |