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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: net/base/net_util_unittest.cc
diff --git a/net/base/net_util_unittest.cc b/net/base/net_util_unittest.cc
index 46293a3aaec8340255e7190d3c0b2f19cc45c57b..a4c7a5ce997eafc6db7b6a7f799d61ab941a1c2b 100644
--- a/net/base/net_util_unittest.cc
+++ b/net/base/net_util_unittest.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -2166,3 +2166,22 @@ TEST(NetUtilTest, IPNumberMatchesPrefix) {
prefix_length_in_bits));
}
}
+
+TEST(NetUtilTest, IsLocalhost) {
+ EXPECT_TRUE(net::IsLocalhost("localhost"));
+ EXPECT_TRUE(net::IsLocalhost("127.0.0.1"));
+ EXPECT_TRUE(net::IsLocalhost("127.0.1.0"));
+ EXPECT_TRUE(net::IsLocalhost("127.1.0.0"));
+ EXPECT_TRUE(net::IsLocalhost("127.0.0.255"));
+ EXPECT_TRUE(net::IsLocalhost("127.0.255.0"));
+ EXPECT_TRUE(net::IsLocalhost("127.255.0.0"));
+ EXPECT_TRUE(net::IsLocalhost("::1"));
+ EXPECT_TRUE(net::IsLocalhost("0:0:0:0:0:0:0:1"));
+
+ EXPECT_FALSE(net::IsLocalhost("127.0.0.1.1"));
+ EXPECT_FALSE(net::IsLocalhost(".127.0.0.255"));
+ EXPECT_FALSE(net::IsLocalhost("::1:1"));
+ EXPECT_FALSE(net::IsLocalhost("0:0:0:0:1:0:0:1"));
+ EXPECT_FALSE(net::IsLocalhost("::1:1"));
+ EXPECT_FALSE(net::IsLocalhost("0:0:0:0:0:0:0:0:1"));
+}

Powered by Google App Engine
This is Rietveld 408576698