| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/strings/string_util.h" | 8 #include "base/strings/string_util.h" |
| 9 #include "base/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
| 10 #include "base/strings/string_split.h" | 10 #include "base/strings/string_split.h" |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 ASCIIToUTF16("Total of 1 file, 2 blocks.")); | 68 ASCIIToUTF16("Total of 1 file, 2 blocks.")); |
| 69 | 69 |
| 70 std::vector<FtpDirectoryListingEntry> entries; | 70 std::vector<FtpDirectoryListingEntry> entries; |
| 71 EXPECT_TRUE(ParseFtpDirectoryListingVms(lines, | 71 EXPECT_TRUE(ParseFtpDirectoryListingVms(lines, |
| 72 &entries)); | 72 &entries)); |
| 73 VerifySingleLineTestCase(good_cases[i], entries); | 73 VerifySingleLineTestCase(good_cases[i], entries); |
| 74 } | 74 } |
| 75 } | 75 } |
| 76 | 76 |
| 77 TEST_F(FtpDirectoryListingParserVmsTest, Bad) { | 77 TEST_F(FtpDirectoryListingParserVmsTest, Bad) { |
| 78 const char* bad_cases[] = { | 78 const char* const bad_cases[] = { |
| 79 "garbage", | 79 "garbage", |
| 80 | 80 |
| 81 // Missing file version number. | 81 // Missing file version number. |
| 82 "README.TXT 2 18-APR-2000 10:40:39", | 82 "README.TXT 2 18-APR-2000 10:40:39", |
| 83 | 83 |
| 84 // Missing extension. | 84 // Missing extension. |
| 85 "README;1 2 18-APR-2000 10:40:39", | 85 "README;1 2 18-APR-2000 10:40:39", |
| 86 | 86 |
| 87 // Malformed file size. | 87 // Malformed file size. |
| 88 "README.TXT;1 garbage 18-APR-2000 10:40:39", | 88 "README.TXT;1 garbage 18-APR-2000 10:40:39", |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 lines.insert(lines.end(), | 121 lines.insert(lines.end(), |
| 122 ASCIIToUTF16("Total of 1 file, 2 blocks.")); | 122 ASCIIToUTF16("Total of 1 file, 2 blocks.")); |
| 123 | 123 |
| 124 std::vector<FtpDirectoryListingEntry> entries; | 124 std::vector<FtpDirectoryListingEntry> entries; |
| 125 EXPECT_FALSE(ParseFtpDirectoryListingVms(lines, | 125 EXPECT_FALSE(ParseFtpDirectoryListingVms(lines, |
| 126 &entries)); | 126 &entries)); |
| 127 } | 127 } |
| 128 } | 128 } |
| 129 | 129 |
| 130 TEST_F(FtpDirectoryListingParserVmsTest, BadDataAfterFooter) { | 130 TEST_F(FtpDirectoryListingParserVmsTest, BadDataAfterFooter) { |
| 131 const char* bad_cases[] = { | 131 const char* const bad_cases[] = { |
| 132 "garbage", | 132 "garbage", |
| 133 "Total of 1 file, 2 blocks.", | 133 "Total of 1 file, 2 blocks.", |
| 134 "Directory ANYNYMOUS_ROOT:[000000]", | 134 "Directory ANYNYMOUS_ROOT:[000000]", |
| 135 }; | 135 }; |
| 136 for (size_t i = 0; i < arraysize(bad_cases); i++) { | 136 for (size_t i = 0; i < arraysize(bad_cases); i++) { |
| 137 SCOPED_TRACE(base::StringPrintf("Test[%" PRIuS "]: %s", i, bad_cases[i])); | 137 SCOPED_TRACE(base::StringPrintf("Test[%" PRIuS "]: %s", i, bad_cases[i])); |
| 138 | 138 |
| 139 std::vector<base::string16> lines( | 139 std::vector<base::string16> lines( |
| 140 GetSingleLineTestCase("README.TXT;4 2 18-APR-2000 10:40:39.90")); | 140 GetSingleLineTestCase("README.TXT;4 2 18-APR-2000 10:40:39.90")); |
| 141 | 141 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 161 std::vector<FtpDirectoryListingEntry> entries; | 161 std::vector<FtpDirectoryListingEntry> entries; |
| 162 EXPECT_FALSE(ParseFtpDirectoryListingVms(lines, | 162 EXPECT_FALSE(ParseFtpDirectoryListingVms(lines, |
| 163 &entries)); | 163 &entries)); |
| 164 } | 164 } |
| 165 } | 165 } |
| 166 } | 166 } |
| 167 | 167 |
| 168 } // namespace | 168 } // namespace |
| 169 | 169 |
| 170 } // namespace net | 170 } // namespace net |
| OLD | NEW |