Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(100)

Side by Side Diff: net/ftp/ftp_util_unittest.cc

Issue 662553002: Convert ARRAYSIZE_UNSAFE -> arraysize in net/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « net/ftp/ftp_directory_listing_parser.cc ('k') | net/http/http_auth_handler_basic_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_util.h" 5 #include "net/ftp/ftp_util.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/format_macros.h" 8 #include "base/format_macros.h"
9 #include "base/strings/string_util.h" 9 #include "base/strings/string_util.h"
10 #include "base/strings/stringprintf.h" 10 #include "base/strings/stringprintf.h"
(...skipping 16 matching lines...) Expand all
27 { "/a", "a" }, 27 { "/a", "a" },
28 { "/a/b", "a:[000000]b" }, 28 { "/a/b", "a:[000000]b" },
29 { "/a/b/c", "a:[b]c" }, 29 { "/a/b/c", "a:[b]c" },
30 { "/a/b/c/d", "a:[b.c]d" }, 30 { "/a/b/c/d", "a:[b.c]d" },
31 { "/a/b/c/d/e", "a:[b.c.d]e" }, 31 { "/a/b/c/d/e", "a:[b.c.d]e" },
32 { "a", "a" }, 32 { "a", "a" },
33 { "a/b", "[.a]b" }, 33 { "a/b", "[.a]b" },
34 { "a/b/c", "[.a.b]c" }, 34 { "a/b/c", "[.a.b]c" },
35 { "a/b/c/d", "[.a.b.c]d" }, 35 { "a/b/c/d", "[.a.b.c]d" },
36 }; 36 };
37 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kTestCases); i++) { 37 for (size_t i = 0; i < arraysize(kTestCases); i++) {
38 EXPECT_EQ(kTestCases[i].expected_output, 38 EXPECT_EQ(kTestCases[i].expected_output,
39 net::FtpUtil::UnixFilePathToVMS(kTestCases[i].input)) 39 net::FtpUtil::UnixFilePathToVMS(kTestCases[i].input))
40 << kTestCases[i].input; 40 << kTestCases[i].input;
41 } 41 }
42 } 42 }
43 43
44 TEST(FtpUtilTest, UnixDirectoryPathToVMS) { 44 TEST(FtpUtilTest, UnixDirectoryPathToVMS) {
45 const struct { 45 const struct {
46 const char* input; 46 const char* input;
47 const char* expected_output; 47 const char* expected_output;
(...skipping 12 matching lines...) Expand all
60 { "/a/b/c/d/e/", "a:[b.c.d.e]" }, 60 { "/a/b/c/d/e/", "a:[b.c.d.e]" },
61 { "a", "[.a]" }, 61 { "a", "[.a]" },
62 { "a/", "[.a]" }, 62 { "a/", "[.a]" },
63 { "a/b", "[.a.b]" }, 63 { "a/b", "[.a.b]" },
64 { "a/b/", "[.a.b]" }, 64 { "a/b/", "[.a.b]" },
65 { "a/b/c", "[.a.b.c]" }, 65 { "a/b/c", "[.a.b.c]" },
66 { "a/b/c/", "[.a.b.c]" }, 66 { "a/b/c/", "[.a.b.c]" },
67 { "a/b/c/d", "[.a.b.c.d]" }, 67 { "a/b/c/d", "[.a.b.c.d]" },
68 { "a/b/c/d/", "[.a.b.c.d]" }, 68 { "a/b/c/d/", "[.a.b.c.d]" },
69 }; 69 };
70 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kTestCases); i++) { 70 for (size_t i = 0; i < arraysize(kTestCases); i++) {
71 EXPECT_EQ(kTestCases[i].expected_output, 71 EXPECT_EQ(kTestCases[i].expected_output,
72 net::FtpUtil::UnixDirectoryPathToVMS(kTestCases[i].input)) 72 net::FtpUtil::UnixDirectoryPathToVMS(kTestCases[i].input))
73 << kTestCases[i].input; 73 << kTestCases[i].input;
74 } 74 }
75 } 75 }
76 76
77 TEST(FtpUtilTest, VMSPathToUnix) { 77 TEST(FtpUtilTest, VMSPathToUnix) {
78 const struct { 78 const struct {
79 const char* input; 79 const char* input;
80 const char* expected_output; 80 const char* expected_output;
(...skipping 19 matching lines...) Expand all
100 { "[.a.b.c.d]", "a/b/c/d" }, 100 { "[.a.b.c.d]", "a/b/c/d" },
101 { "[.", "" }, 101 { "[.", "" },
102 102
103 // UNIX emulation: 103 // UNIX emulation:
104 { "/", "/" }, 104 { "/", "/" },
105 { "/a", "/a" }, 105 { "/a", "/a" },
106 { "/a/b", "/a/b" }, 106 { "/a/b", "/a/b" },
107 { "/a/b/c", "/a/b/c" }, 107 { "/a/b/c", "/a/b/c" },
108 { "/a/b/c/d", "/a/b/c/d" }, 108 { "/a/b/c/d", "/a/b/c/d" },
109 }; 109 };
110 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kTestCases); i++) { 110 for (size_t i = 0; i < arraysize(kTestCases); i++) {
111 EXPECT_EQ(kTestCases[i].expected_output, 111 EXPECT_EQ(kTestCases[i].expected_output,
112 net::FtpUtil::VMSPathToUnix(kTestCases[i].input)) 112 net::FtpUtil::VMSPathToUnix(kTestCases[i].input))
113 << kTestCases[i].input; 113 << kTestCases[i].input;
114 } 114 }
115 } 115 }
116 116
117 TEST(FtpUtilTest, LsDateListingToTime) { 117 TEST(FtpUtilTest, LsDateListingToTime) {
118 base::Time mock_current_time; 118 base::Time mock_current_time;
119 ASSERT_TRUE(base::Time::FromString("Tue, 15 Nov 1994 12:45:26 GMT", 119 ASSERT_TRUE(base::Time::FromString("Tue, 15 Nov 1994 12:45:26 GMT",
120 &mock_current_time)); 120 &mock_current_time));
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 { "\xd0\xb4\xd0\xb5\xd0\xba", "1", "2011", 2011, 12, 1, 0, 0 }, 156 { "\xd0\xb4\xd0\xb5\xd0\xba", "1", "2011", 2011, 12, 1, 0, 0 },
157 157
158 // Test current year detection. 158 // Test current year detection.
159 { "Nov", "01", "12:00", 1994, 11, 1, 12, 0 }, 159 { "Nov", "01", "12:00", 1994, 11, 1, 12, 0 },
160 { "Nov", "15", "12:00", 1994, 11, 15, 12, 0 }, 160 { "Nov", "15", "12:00", 1994, 11, 15, 12, 0 },
161 { "Nov", "16", "12:00", 1993, 11, 16, 12, 0 }, 161 { "Nov", "16", "12:00", 1993, 11, 16, 12, 0 },
162 { "Jan", "01", "08:30", 1994, 1, 1, 8, 30 }, 162 { "Jan", "01", "08:30", 1994, 1, 1, 8, 30 },
163 { "Sep", "02", "09:00", 1994, 9, 2, 9, 0 }, 163 { "Sep", "02", "09:00", 1994, 9, 2, 9, 0 },
164 { "Dec", "06", "21:00", 1993, 12, 6, 21, 0 }, 164 { "Dec", "06", "21:00", 1993, 12, 6, 21, 0 },
165 }; 165 };
166 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kTestCases); i++) { 166 for (size_t i = 0; i < arraysize(kTestCases); i++) {
167 SCOPED_TRACE(base::StringPrintf("Test[%" PRIuS "]: %s %s %s", i, 167 SCOPED_TRACE(base::StringPrintf("Test[%" PRIuS "]: %s %s %s", i,
168 kTestCases[i].month, kTestCases[i].day, 168 kTestCases[i].month, kTestCases[i].day,
169 kTestCases[i].rest)); 169 kTestCases[i].rest));
170 170
171 base::Time time; 171 base::Time time;
172 ASSERT_TRUE(net::FtpUtil::LsDateListingToTime( 172 ASSERT_TRUE(net::FtpUtil::LsDateListingToTime(
173 UTF8ToUTF16(kTestCases[i].month), UTF8ToUTF16(kTestCases[i].day), 173 UTF8ToUTF16(kTestCases[i].month), UTF8ToUTF16(kTestCases[i].day),
174 UTF8ToUTF16(kTestCases[i].rest), mock_current_time, &time)); 174 UTF8ToUTF16(kTestCases[i].rest), mock_current_time, &time));
175 175
176 base::Time::Exploded time_exploded; 176 base::Time::Exploded time_exploded;
(...skipping 20 matching lines...) Expand all
197 int expected_day_of_month; 197 int expected_day_of_month;
198 int expected_hour; 198 int expected_hour;
199 int expected_minute; 199 int expected_minute;
200 } kTestCases[] = { 200 } kTestCases[] = {
201 { "11-01-07", "12:42", 2007, 11, 1, 12, 42 }, 201 { "11-01-07", "12:42", 2007, 11, 1, 12, 42 },
202 { "11-01-07", "12:42AM", 2007, 11, 1, 0, 42 }, 202 { "11-01-07", "12:42AM", 2007, 11, 1, 0, 42 },
203 { "11-01-07", "12:42PM", 2007, 11, 1, 12, 42 }, 203 { "11-01-07", "12:42PM", 2007, 11, 1, 12, 42 },
204 204
205 { "11-01-2007", "12:42", 2007, 11, 1, 12, 42 }, 205 { "11-01-2007", "12:42", 2007, 11, 1, 12, 42 },
206 }; 206 };
207 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kTestCases); i++) { 207 for (size_t i = 0; i < arraysize(kTestCases); i++) {
208 SCOPED_TRACE(base::StringPrintf("Test[%" PRIuS "]: %s %s", i, 208 SCOPED_TRACE(base::StringPrintf("Test[%" PRIuS "]: %s %s", i,
209 kTestCases[i].date, kTestCases[i].time)); 209 kTestCases[i].date, kTestCases[i].time));
210 210
211 base::Time time; 211 base::Time time;
212 ASSERT_TRUE(net::FtpUtil::WindowsDateListingToTime( 212 ASSERT_TRUE(net::FtpUtil::WindowsDateListingToTime(
213 UTF8ToUTF16(kTestCases[i].date), 213 UTF8ToUTF16(kTestCases[i].date),
214 UTF8ToUTF16(kTestCases[i].time), 214 UTF8ToUTF16(kTestCases[i].time),
215 &time)); 215 &time));
216 216
217 base::Time::Exploded time_exploded; 217 base::Time::Exploded time_exploded;
(...skipping 18 matching lines...) Expand all
236 { "", 1, "" }, 236 { "", 1, "" },
237 { "foo abc", 0, "foo abc" }, 237 { "foo abc", 0, "foo abc" },
238 { "foo abc", 1, "abc" }, 238 { "foo abc", 1, "abc" },
239 { " foo abc", 0, "foo abc" }, 239 { " foo abc", 0, "foo abc" },
240 { " foo abc", 1, "abc" }, 240 { " foo abc", 1, "abc" },
241 { " foo abc", 2, "" }, 241 { " foo abc", 2, "" },
242 { " foo abc ", 0, "foo abc" }, 242 { " foo abc ", 0, "foo abc" },
243 { " foo abc ", 1, "abc" }, 243 { " foo abc ", 1, "abc" },
244 { " foo abc ", 2, "" }, 244 { " foo abc ", 2, "" },
245 }; 245 };
246 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kTestCases); i++) { 246 for (size_t i = 0; i < arraysize(kTestCases); i++) {
247 SCOPED_TRACE(base::StringPrintf("Test[%" PRIuS "]: %s %d", i, 247 SCOPED_TRACE(base::StringPrintf("Test[%" PRIuS "]: %s %d", i,
248 kTestCases[i].text, kTestCases[i].column)); 248 kTestCases[i].text, kTestCases[i].column));
249 249
250 EXPECT_EQ(ASCIIToUTF16(kTestCases[i].expected_result), 250 EXPECT_EQ(ASCIIToUTF16(kTestCases[i].expected_result),
251 net::FtpUtil::GetStringPartAfterColumns( 251 net::FtpUtil::GetStringPartAfterColumns(
252 ASCIIToUTF16(kTestCases[i].text), kTestCases[i].column)); 252 ASCIIToUTF16(kTestCases[i].text), kTestCases[i].column));
253 } 253 }
254 } 254 }
255 255
256 } // namespace 256 } // namespace
OLDNEW
« no previous file with comments | « net/ftp/ftp_directory_listing_parser.cc ('k') | net/http/http_auth_handler_basic_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698