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

Side by Side Diff: net/cookies/cookie_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/cookies/cookie_monster_unittest.cc ('k') | net/dns/dns_hosts_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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 <string> 5 #include <string>
6 #include <utility> 6 #include <utility>
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "net/cookies/cookie_util.h" 10 #include "net/cookies/cookie_util.h"
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 TEST(CookieUtilTest, TestDomainIsHostOnly) { 48 TEST(CookieUtilTest, TestDomainIsHostOnly) {
49 const struct { 49 const struct {
50 const char* str; 50 const char* str;
51 const bool is_host_only; 51 const bool is_host_only;
52 } tests[] = { 52 } tests[] = {
53 { "", true }, 53 { "", true },
54 { "www.google.com", true }, 54 { "www.google.com", true },
55 { ".google.com", false } 55 { ".google.com", false }
56 }; 56 };
57 57
58 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) { 58 for (size_t i = 0; i < arraysize(tests); ++i) {
59 EXPECT_EQ(tests[i].is_host_only, 59 EXPECT_EQ(tests[i].is_host_only,
60 net::cookie_util::DomainIsHostOnly(tests[i].str)); 60 net::cookie_util::DomainIsHostOnly(tests[i].str));
61 } 61 }
62 } 62 }
63 63
64 TEST(CookieUtilTest, TestCookieDateParsing) { 64 TEST(CookieUtilTest, TestCookieDateParsing) {
65 const struct { 65 const struct {
66 const char* str; 66 const char* str;
67 const bool valid; 67 const bool valid;
68 const time_t epoch; 68 const time_t epoch;
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 { "98 April 17 21:01:22", false, 0 }, 131 { "98 April 17 21:01:22", false, 0 },
132 { "Thu, 012-Aug-2008 20:49:07 GMT", false, 0 }, 132 { "Thu, 012-Aug-2008 20:49:07 GMT", false, 0 },
133 { "Thu, 12-Aug-31841 20:49:07 GMT", false, 0 }, 133 { "Thu, 12-Aug-31841 20:49:07 GMT", false, 0 },
134 { "Thu, 12-Aug-9999999999 20:49:07 GMT", false, 0 }, 134 { "Thu, 12-Aug-9999999999 20:49:07 GMT", false, 0 },
135 { "Thu, 999999999999-Aug-2007 20:49:07 GMT", false, 0 }, 135 { "Thu, 999999999999-Aug-2007 20:49:07 GMT", false, 0 },
136 { "Thu, 12-Aug-2007 20:61:99999999999 GMT", false, 0 }, 136 { "Thu, 12-Aug-2007 20:61:99999999999 GMT", false, 0 },
137 { "IAintNoDateFool", false, 0 }, 137 { "IAintNoDateFool", false, 0 },
138 }; 138 };
139 139
140 base::Time parsed_time; 140 base::Time parsed_time;
141 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) { 141 for (size_t i = 0; i < arraysize(tests); ++i) {
142 parsed_time = net::cookie_util::ParseCookieTime(tests[i].str); 142 parsed_time = net::cookie_util::ParseCookieTime(tests[i].str);
143 if (!tests[i].valid) { 143 if (!tests[i].valid) {
144 EXPECT_FALSE(!parsed_time.is_null()) << tests[i].str; 144 EXPECT_FALSE(!parsed_time.is_null()) << tests[i].str;
145 continue; 145 continue;
146 } 146 }
147 EXPECT_TRUE(!parsed_time.is_null()) << tests[i].str; 147 EXPECT_TRUE(!parsed_time.is_null()) << tests[i].str;
148 EXPECT_EQ(tests[i].epoch, parsed_time.ToTimeT()) << tests[i].str; 148 EXPECT_EQ(tests[i].epoch, parsed_time.ToTimeT()) << tests[i].str;
149 } 149 }
150 } 150 }
151 151
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 std::string("\"abcdef\""))); 187 std::string("\"abcdef\"")));
188 tests.back().parsed.push_back(std::make_pair(std::string("otherkey"), 188 tests.back().parsed.push_back(std::make_pair(std::string("otherkey"),
189 std::string("1234"))); 189 std::string("1234")));
190 190
191 for (size_t i = 0; i < tests.size(); i++) { 191 for (size_t i = 0; i < tests.size(); i++) {
192 SCOPED_TRACE(testing::Message() << "Test " << i); 192 SCOPED_TRACE(testing::Message() << "Test " << i);
193 CheckParse(tests[i].str, tests[i].parsed); 193 CheckParse(tests[i].str, tests[i].parsed);
194 CheckSerialize(tests[i].parsed, tests[i].str); 194 CheckSerialize(tests[i].parsed, tests[i].str);
195 } 195 }
196 } 196 }
OLDNEW
« no previous file with comments | « net/cookies/cookie_monster_unittest.cc ('k') | net/dns/dns_hosts_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698