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

Side by Side Diff: net/base/net_util_unittest.cc

Issue 6711046: Add an opt-out header for HTTP throttling. Never throttle for localhost. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Update copyright years. Created 9 years, 9 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2010 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/base/net_util.h" 5 #include "net/base/net_util.h"
6 6
7 #include "base/file_path.h" 7 #include "base/file_path.h"
8 #include "base/format_macros.h" 8 #include "base/format_macros.h"
9 #include "base/string_number_conversions.h" 9 #include "base/string_number_conversions.h"
10 #include "base/string_util.h" 10 #include "base/string_util.h"
11 #include "base/stringprintf.h" 11 #include "base/stringprintf.h"
(...skipping 2147 matching lines...) Expand 10 before | Expand all | Expand 10 after
2159 EXPECT_TRUE(net::ParseCIDRBlock(tests[i].cidr_literal, 2159 EXPECT_TRUE(net::ParseCIDRBlock(tests[i].cidr_literal,
2160 &ip_prefix, 2160 &ip_prefix,
2161 &prefix_length_in_bits)); 2161 &prefix_length_in_bits));
2162 2162
2163 EXPECT_EQ(tests[i].expected_to_match, 2163 EXPECT_EQ(tests[i].expected_to_match,
2164 net::IPNumberMatchesPrefix(ip_number, 2164 net::IPNumberMatchesPrefix(ip_number,
2165 ip_prefix, 2165 ip_prefix,
2166 prefix_length_in_bits)); 2166 prefix_length_in_bits));
2167 } 2167 }
2168 } 2168 }
2169
2170 TEST(NetUtilTest, IsLocalhost) {
2171 EXPECT_TRUE(net::IsLocalhost("localhost"));
2172 EXPECT_TRUE(net::IsLocalhost("127.0.0.1"));
2173 EXPECT_TRUE(net::IsLocalhost("127.0.1.0"));
2174 EXPECT_TRUE(net::IsLocalhost("127.1.0.0"));
2175 EXPECT_TRUE(net::IsLocalhost("127.0.0.255"));
2176 EXPECT_TRUE(net::IsLocalhost("127.0.255.0"));
2177 EXPECT_TRUE(net::IsLocalhost("127.255.0.0"));
2178 EXPECT_TRUE(net::IsLocalhost("::1"));
2179 EXPECT_TRUE(net::IsLocalhost("0:0:0:0:0:0:0:1"));
2180
2181 EXPECT_FALSE(net::IsLocalhost("127.0.0.1.1"));
2182 EXPECT_FALSE(net::IsLocalhost(".127.0.0.255"));
2183 EXPECT_FALSE(net::IsLocalhost("::1:1"));
2184 EXPECT_FALSE(net::IsLocalhost("0:0:0:0:1:0:0:1"));
2185 EXPECT_FALSE(net::IsLocalhost("::1:1"));
2186 EXPECT_FALSE(net::IsLocalhost("0:0:0:0:0:0:0:0:1"));
2187 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698