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