| 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_split.h" | 8 #include "base/string_split.h" |
| 9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
| 10 #include "base/stringprintf.h" |
| 10 #include "base/utf_string_conversions.h" | 11 #include "base/utf_string_conversions.h" |
| 11 #include "net/ftp/ftp_directory_listing_parser_vms.h" | 12 #include "net/ftp/ftp_directory_listing_parser_vms.h" |
| 12 | 13 |
| 13 namespace { | 14 namespace { |
| 14 | 15 |
| 15 typedef net::FtpDirectoryListingParserTest FtpDirectoryListingParserVmsTest; | 16 typedef net::FtpDirectoryListingParserTest FtpDirectoryListingParserVmsTest; |
| 16 | 17 |
| 17 TEST_F(FtpDirectoryListingParserVmsTest, Good) { | 18 TEST_F(FtpDirectoryListingParserVmsTest, Good) { |
| 18 const struct SingleLineTestData good_cases[] = { | 19 const struct SingleLineTestData good_cases[] = { |
| 19 { "README.TXT;4 2 18-APR-2000 10:40:39.90", | 20 { "README.TXT;4 2 18-APR-2000 10:40:39.90", |
| (...skipping 18 matching lines...) Expand all Loading... |
| 38 net::FtpDirectoryListingEntry::FILE, "announce.txt", 512, | 39 net::FtpDirectoryListingEntry::FILE, "announce.txt", 512, |
| 39 2005, 3, 12, 8, 44 }, | 40 2005, 3, 12, 8, 44 }, |
| 40 { "ANNOUNCE.TXT;2 1 12-MAR-2005 08:44:57 [X] (R,RW,RWD,RE)", | 41 { "ANNOUNCE.TXT;2 1 12-MAR-2005 08:44:57 [X] (R,RW,RWD,RE)", |
| 41 net::FtpDirectoryListingEntry::FILE, "announce.txt", 512, | 42 net::FtpDirectoryListingEntry::FILE, "announce.txt", 512, |
| 42 2005, 3, 12, 8, 44 }, | 43 2005, 3, 12, 8, 44 }, |
| 43 { "ANNOUNCE.TXT;2 1 12-MAR-2005 08:44:57 [X] (ED,RED,WD,WED)", | 44 { "ANNOUNCE.TXT;2 1 12-MAR-2005 08:44:57 [X] (ED,RED,WD,WED)", |
| 44 net::FtpDirectoryListingEntry::FILE, "announce.txt", 512, | 45 net::FtpDirectoryListingEntry::FILE, "announce.txt", 512, |
| 45 2005, 3, 12, 8, 44 }, | 46 2005, 3, 12, 8, 44 }, |
| 46 }; | 47 }; |
| 47 for (size_t i = 0; i < arraysize(good_cases); i++) { | 48 for (size_t i = 0; i < arraysize(good_cases); i++) { |
| 48 SCOPED_TRACE(StringPrintf("Test[%" PRIuS "]: %s", i, good_cases[i].input)); | 49 SCOPED_TRACE(base::StringPrintf("Test[%" PRIuS "]: %s", i, |
| 50 good_cases[i].input)); |
| 49 | 51 |
| 50 net::FtpDirectoryListingParserVms parser; | 52 net::FtpDirectoryListingParserVms parser; |
| 51 ASSERT_TRUE( | 53 ASSERT_TRUE( |
| 52 parser.ConsumeLine(ASCIIToUTF16("Directory ANONYMOUS_ROOT:[000000]"))); | 54 parser.ConsumeLine(ASCIIToUTF16("Directory ANONYMOUS_ROOT:[000000]"))); |
| 53 RunSingleLineTestCase(&parser, good_cases[i]); | 55 RunSingleLineTestCase(&parser, good_cases[i]); |
| 54 } | 56 } |
| 55 } | 57 } |
| 56 | 58 |
| 57 TEST_F(FtpDirectoryListingParserVmsTest, Bad) { | 59 TEST_F(FtpDirectoryListingParserVmsTest, Bad) { |
| 58 const char* bad_cases[] = { | 60 const char* bad_cases[] = { |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 "Directory ROOT|X.TXT;2 1 12-MAR-2005 08:44:57 (SYSTEM) (RWED,RWED,RE,RE)", | 96 "Directory ROOT|X.TXT;2 1 12-MAR-2005 08:44:57 (SYSTEM) (RWED,RWED,RE,RE)", |
| 95 "Directory ROOT|X.TXT;2 1 12-MAR-2005 08:44:57 [SYSTEM] [RWED,RWED,RE,RE]", | 97 "Directory ROOT|X.TXT;2 1 12-MAR-2005 08:44:57 [SYSTEM] [RWED,RWED,RE,RE]", |
| 96 "Directory ROOT|X.TXT;2 1 12-MAR-2005 08:44:57 [X] (RWED)", | 98 "Directory ROOT|X.TXT;2 1 12-MAR-2005 08:44:57 [X] (RWED)", |
| 97 "Directory ROOT|X.TXT;2 1 12-MAR-2005 08:44:57 [X] (RWED,RWED,RE,RE,RE)", | 99 "Directory ROOT|X.TXT;2 1 12-MAR-2005 08:44:57 [X] (RWED,RWED,RE,RE,RE)", |
| 98 "Directory ROOT|X.TXT;2 1 12-MAR-2005 08:44:57 [X] (RWED,RWEDRWED,RE,RE)", | 100 "Directory ROOT|X.TXT;2 1 12-MAR-2005 08:44:57 [X] (RWED,RWEDRWED,RE,RE)", |
| 99 "Directory ROOT|X.TXT;2 1 12-MAR-2005 08:44:57 [X] (RWED,DEWR,RE,RE)", | 101 "Directory ROOT|X.TXT;2 1 12-MAR-2005 08:44:57 [X] (RWED,DEWR,RE,RE)", |
| 100 "Directory ROOT|X.TXT;2 1 12-MAR-2005 08:44:57 [X] (RWED,RWED,Q,RE)", | 102 "Directory ROOT|X.TXT;2 1 12-MAR-2005 08:44:57 [X] (RWED,RWED,Q,RE)", |
| 101 "Directory ROOT|X.TXT;2 1 12-MAR-2005 08:44:57 [X] (RWED,RRWWEEDD,RE,RE)", | 103 "Directory ROOT|X.TXT;2 1 12-MAR-2005 08:44:57 [X] (RWED,RRWWEEDD,RE,RE)", |
| 102 }; | 104 }; |
| 103 for (size_t i = 0; i < arraysize(bad_cases); i++) { | 105 for (size_t i = 0; i < arraysize(bad_cases); i++) { |
| 104 SCOPED_TRACE(StringPrintf("Test[%" PRIuS "]: %s", i, bad_cases[i])); | 106 SCOPED_TRACE(base::StringPrintf("Test[%" PRIuS "]: %s", i, bad_cases[i])); |
| 105 | 107 |
| 106 std::vector<std::string> lines; | 108 std::vector<std::string> lines; |
| 107 SplitString(bad_cases[i], '|', &lines); | 109 SplitString(bad_cases[i], '|', &lines); |
| 108 net::FtpDirectoryListingParserVms parser; | 110 net::FtpDirectoryListingParserVms parser; |
| 109 bool failed = false; | 111 bool failed = false; |
| 110 for (std::vector<std::string>::const_iterator i = lines.begin(); | 112 for (std::vector<std::string>::const_iterator i = lines.begin(); |
| 111 i != lines.end(); ++i) { | 113 i != lines.end(); ++i) { |
| 112 if (!parser.ConsumeLine(UTF8ToUTF16(*i))) { | 114 if (!parser.ConsumeLine(UTF8ToUTF16(*i))) { |
| 113 failed = true; | 115 failed = true; |
| 114 break; | 116 break; |
| 115 } | 117 } |
| 116 } | 118 } |
| 117 EXPECT_TRUE(failed); | 119 EXPECT_TRUE(failed); |
| 118 } | 120 } |
| 119 } | 121 } |
| 120 | 122 |
| 121 } // namespace | 123 } // namespace |
| OLD | NEW |