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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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* const 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", |
89 "README.TXT;1 -2 18-APR-2000 10:40:39", | 89 "README.TXT;1 -2 18-APR-2000 10:40:39", |
90 | 90 |
91 // Malformed date. | 91 // Malformed date. |
92 "README.TXT;1 2 APR-2000 10:40:39", | 92 "README.TXT;1 2 APR-2000 10:40:39", |
93 "README.TXT;1 2 -18-APR-2000 10:40:39", | 93 "README.TXT;1 2 -18-APR-2000 10:40:39", "README.TXT;1 2 18-APR 10:40:39", |
94 "README.TXT;1 2 18-APR 10:40:39", | 94 "README.TXT;1 2 18-APR-2000 10", "README.TXT;1 2 18-APR-2000 10:40.25", |
95 "README.TXT;1 2 18-APR-2000 10", | 95 "README.TXT;1 2 18-APR-2000 10:40.25.25", |
96 "README.TXT;1 2 18-APR-2000 10:40.25", | |
97 "README.TXT;1 2 18-APR-2000 10:40.25.25", | |
98 | 96 |
99 // Malformed security information. | 97 // Malformed security information. |
100 "X.TXT;2 1 12-MAR-2005 08:44:57 (RWED,RWED,RE,RE)", | 98 "X.TXT;2 1 12-MAR-2005 08:44:57 (RWED,RWED,RE,RE)", |
101 "X.TXT;2 1 12-MAR-2005 08:44:57 [SYSTEM]", | 99 "X.TXT;2 1 12-MAR-2005 08:44:57 [SYSTEM]", |
102 "X.TXT;2 1 12-MAR-2005 08:44:57 (SYSTEM) (RWED,RWED,RE,RE)", | 100 "X.TXT;2 1 12-MAR-2005 08:44:57 (SYSTEM) (RWED,RWED,RE,RE)", |
103 "X.TXT;2 1 12-MAR-2005 08:44:57 [SYSTEM] [RWED,RWED,RE,RE]", | 101 "X.TXT;2 1 12-MAR-2005 08:44:57 [SYSTEM] [RWED,RWED,RE,RE]", |
104 "X.TXT;2 1 12-MAR-2005 08:44:57 [X] (RWED)", | 102 "X.TXT;2 1 12-MAR-2005 08:44:57 [X] (RWED)", |
105 "X.TXT;2 1 12-MAR-2005 08:44:57 [X] (RWED,RWED,RE,RE,RE)", | 103 "X.TXT;2 1 12-MAR-2005 08:44:57 [X] (RWED,RWED,RE,RE,RE)", |
106 "X.TXT;2 1 12-MAR-2005 08:44:57 [X] (RWED,RWEDRWED,RE,RE)", | 104 "X.TXT;2 1 12-MAR-2005 08:44:57 [X] (RWED,RWEDRWED,RE,RE)", |
107 "X.TXT;2 1 12-MAR-2005 08:44:57 [X] (RWED,DEWR,RE,RE)", | 105 "X.TXT;2 1 12-MAR-2005 08:44:57 [X] (RWED,DEWR,RE,RE)", |
108 "X.TXT;2 1 12-MAR-2005 08:44:57 [X] (RWED,RWED,Q,RE)", | 106 "X.TXT;2 1 12-MAR-2005 08:44:57 [X] (RWED,RWED,Q,RE)", |
109 "X.TXT;2 1 12-MAR-2005 08:44:57 [X] (RWED,RRWWEEDD,RE,RE)", | 107 "X.TXT;2 1 12-MAR-2005 08:44:57 [X] (RWED,RRWWEEDD,RE,RE)", |
108 | |
109 // Block size is too large. | |
110 "README.TXT;1 9223372036854775807 18-APR-2000 10:40:39.90", | |
111 "README.TXT;1 9223372036854775807/9223372036854775807 18-APR-2000 " | |
mmenke
2017/01/04 18:46:41
Shouldn't the first number be smaller here, if you
mmenke
2017/01/04 18:46:41
I'd also suggest something like 922337203685477580
eroman
2017/01/04 18:55:49
My current test is INT64_MAX/INT64_MAX.
What addi
eroman
2017/01/04 18:55:49
The first number is the blocks_used, the second is
mmenke
2017/01/04 19:00:26
Oops, I misread the code...What I really want is a
mmenke
2017/01/04 19:00:26
Multiplying by 512 (block size) causes an overflow
mmenke
2017/01/04 19:01:33
Rather than parsing the string as an int64, rather
eroman
2017/01/04 19:04:31
I have updated the test description to clarify, an
| |
112 "10:40:39.90", | |
110 }; | 113 }; |
111 for (size_t i = 0; i < arraysize(bad_cases); i++) { | 114 for (size_t i = 0; i < arraysize(bad_cases); i++) { |
112 SCOPED_TRACE(base::StringPrintf("Test[%" PRIuS "]: %s", i, bad_cases[i])); | 115 SCOPED_TRACE(base::StringPrintf("Test[%" PRIuS "]: %s", i, bad_cases[i])); |
113 | 116 |
114 std::vector<base::string16> lines(GetSingleLineTestCase(bad_cases[i])); | 117 std::vector<base::string16> lines(GetSingleLineTestCase(bad_cases[i])); |
115 | 118 |
116 // The parser requires a directory header before accepting regular input. | 119 // The parser requires a directory header before accepting regular input. |
117 lines.insert(lines.begin(), | 120 lines.insert(lines.begin(), |
118 ASCIIToUTF16("Directory ANONYMOUS_ROOT:[000000]")); | 121 ASCIIToUTF16("Directory ANONYMOUS_ROOT:[000000]")); |
119 | 122 |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
186 | 189 |
187 lines.push_back(ASCIIToUTF16(" ")); | 190 lines.push_back(ASCIIToUTF16(" ")); |
188 | 191 |
189 std::vector<FtpDirectoryListingEntry> entries; | 192 std::vector<FtpDirectoryListingEntry> entries; |
190 EXPECT_FALSE(ParseFtpDirectoryListingVms(lines, &entries)); | 193 EXPECT_FALSE(ParseFtpDirectoryListingVms(lines, &entries)); |
191 } | 194 } |
192 | 195 |
193 } // namespace | 196 } // namespace |
194 | 197 |
195 } // namespace net | 198 } // namespace net |
OLD | NEW |