| 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_mlsd.h" | 10 #include "net/ftp/ftp_directory_listing_parser_mlsd.h" |
| 10 | 11 |
| 11 namespace { | 12 namespace { |
| 12 | 13 |
| 13 typedef net::FtpDirectoryListingParserTest FtpDirectoryListingParserMlsdTest; | 14 typedef net::FtpDirectoryListingParserTest FtpDirectoryListingParserMlsdTest; |
| 14 | 15 |
| 15 TEST_F(FtpDirectoryListingParserMlsdTest, Good) { | 16 TEST_F(FtpDirectoryListingParserMlsdTest, 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 |
| 19 const struct SingleLineTestData good_cases[] = { | 20 const struct SingleLineTestData good_cases[] = { |
| 20 { "type=file;size=380565;modify=20030606190749; README", | 21 { "type=file;size=380565;modify=20030606190749; README", |
| 21 net::FtpDirectoryListingEntry::FILE, "README", 380565, | 22 net::FtpDirectoryListingEntry::FILE, "README", 380565, |
| 22 2003, 6, 6, 19, 7 }, | 23 2003, 6, 6, 19, 7 }, |
| 23 { "type=dir;sizd=512;modify=20031021200128; pub", | 24 { "type=dir;sizd=512;modify=20031021200128; pub", |
| 24 net::FtpDirectoryListingEntry::DIRECTORY, "pub", -1, | 25 net::FtpDirectoryListingEntry::DIRECTORY, "pub", -1, |
| 25 2003, 10, 21, 20, 1 }, | 26 2003, 10, 21, 20, 1 }, |
| 26 { "type=dir;sizd=512;modify=20091009080706;UNIX.mode=0755; pub", | 27 { "type=dir;sizd=512;modify=20091009080706;UNIX.mode=0755; pub", |
| 27 net::FtpDirectoryListingEntry::DIRECTORY, "pub", -1, | 28 net::FtpDirectoryListingEntry::DIRECTORY, "pub", -1, |
| 28 2009, 10, 9, 8, 7 }, | 29 2009, 10, 9, 8, 7 }, |
| 29 { "type=dir;modify=20010414155237;UNIX.mode=0555;unique=6ag5b4e400; etc", | 30 { "type=dir;modify=20010414155237;UNIX.mode=0555;unique=6ag5b4e400; etc", |
| 30 net::FtpDirectoryListingEntry::DIRECTORY, "etc", -1, | 31 net::FtpDirectoryListingEntry::DIRECTORY, "etc", -1, |
| 31 2001, 4, 14, 15, 52 }, | 32 2001, 4, 14, 15, 52 }, |
| 32 }; | 33 }; |
| 33 for (size_t i = 0; i < arraysize(good_cases); i++) { | 34 for (size_t i = 0; i < arraysize(good_cases); i++) { |
| 34 SCOPED_TRACE(StringPrintf("Test[%" PRIuS "]: %s", i, good_cases[i].input)); | 35 SCOPED_TRACE(base::StringPrintf("Test[%" PRIuS "]: %s", i, |
| 36 good_cases[i].input)); |
| 35 | 37 |
| 36 net::FtpDirectoryListingParserMlsd parser; | 38 net::FtpDirectoryListingParserMlsd parser; |
| 37 RunSingleLineTestCase(&parser, good_cases[i]); | 39 RunSingleLineTestCase(&parser, good_cases[i]); |
| 38 } | 40 } |
| 39 } | 41 } |
| 40 | 42 |
| 41 TEST_F(FtpDirectoryListingParserMlsdTest, Bad) { | 43 TEST_F(FtpDirectoryListingParserMlsdTest, Bad) { |
| 42 const char* bad_cases[] = { | 44 const char* bad_cases[] = { |
| 43 "", | 45 "", |
| 44 " ", | 46 " ", |
| (...skipping 14 matching lines...) Expand all Loading... |
| 59 "type=file;size=garbage;modify=20030606190749; README", | 61 "type=file;size=garbage;modify=20030606190749; README", |
| 60 "type=file;size=380565;modify=garbage; README", | 62 "type=file;size=380565;modify=garbage; README", |
| 61 }; | 63 }; |
| 62 for (size_t i = 0; i < arraysize(bad_cases); i++) { | 64 for (size_t i = 0; i < arraysize(bad_cases); i++) { |
| 63 net::FtpDirectoryListingParserMlsd parser; | 65 net::FtpDirectoryListingParserMlsd parser; |
| 64 EXPECT_FALSE(parser.ConsumeLine(UTF8ToUTF16(bad_cases[i]))) << bad_cases[i]; | 66 EXPECT_FALSE(parser.ConsumeLine(UTF8ToUTF16(bad_cases[i]))) << bad_cases[i]; |
| 65 } | 67 } |
| 66 } | 68 } |
| 67 | 69 |
| 68 } // namespace | 70 } // namespace |
| OLD | NEW |