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

Side by Side Diff: third_party/WebKit/Source/platform/network/NetworkUtilsTest.cpp

Issue 2701993002: DO NOT COMMIT: Results of running new (proposed) clang-format on Blink (Closed)
Patch Set: Created 3 years, 10 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
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "platform/network/NetworkUtils.h" 5 #include "platform/network/NetworkUtils.h"
6 6
7 #include "net/base/ip_address.h" 7 #include "net/base/ip_address.h"
8 #include "testing/gtest/include/gtest/gtest.h" 8 #include "testing/gtest/include/gtest/gtest.h"
9 #include "wtf/text/WTFString.h" 9 #include "wtf/text/WTFString.h"
10 10
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 EXPECT_TRUE(NetworkUtils::isReservedIPAddress( 52 EXPECT_TRUE(NetworkUtils::isReservedIPAddress(
53 String::fromUTF8(addressString.data(), addressString.length()))); 53 String::fromUTF8(addressString.data(), addressString.length())));
54 } else { 54 } else {
55 EXPECT_FALSE(NetworkUtils::isReservedIPAddress( 55 EXPECT_FALSE(NetworkUtils::isReservedIPAddress(
56 String::fromUTF8(addressString.data(), addressString.length()))); 56 String::fromUTF8(addressString.data(), addressString.length())));
57 } 57 }
58 } 58 }
59 } 59 }
60 60
61 TEST(NetworkUtilsTest, GetDomainAndRegistry) { 61 TEST(NetworkUtilsTest, GetDomainAndRegistry) {
62 EXPECT_EQ("", NetworkUtils::getDomainAndRegistry( 62 EXPECT_EQ("",
63 "", NetworkUtils::IncludePrivateRegistries)); 63 NetworkUtils::getDomainAndRegistry(
64 EXPECT_EQ("", NetworkUtils::getDomainAndRegistry( 64 "", NetworkUtils::IncludePrivateRegistries));
65 ".", NetworkUtils::IncludePrivateRegistries)); 65 EXPECT_EQ("",
66 EXPECT_EQ("", NetworkUtils::getDomainAndRegistry( 66 NetworkUtils::getDomainAndRegistry(
67 "..", NetworkUtils::IncludePrivateRegistries)); 67 ".", NetworkUtils::IncludePrivateRegistries));
68 EXPECT_EQ("", NetworkUtils::getDomainAndRegistry( 68 EXPECT_EQ("",
69 "com", NetworkUtils::IncludePrivateRegistries)); 69 NetworkUtils::getDomainAndRegistry(
70 EXPECT_EQ("", NetworkUtils::getDomainAndRegistry( 70 "..", NetworkUtils::IncludePrivateRegistries));
71 ".com", NetworkUtils::IncludePrivateRegistries)); 71 EXPECT_EQ("",
72 NetworkUtils::getDomainAndRegistry(
73 "com", NetworkUtils::IncludePrivateRegistries));
74 EXPECT_EQ("",
75 NetworkUtils::getDomainAndRegistry(
76 ".com", NetworkUtils::IncludePrivateRegistries));
72 EXPECT_EQ( 77 EXPECT_EQ(
73 "", NetworkUtils::getDomainAndRegistry( 78 "",
74 "www.example.com:8000", NetworkUtils::IncludePrivateRegistries)); 79 NetworkUtils::getDomainAndRegistry(
80 "www.example.com:8000", NetworkUtils::IncludePrivateRegistries));
75 81
76 EXPECT_EQ("", NetworkUtils::getDomainAndRegistry( 82 EXPECT_EQ("",
77 "localhost", NetworkUtils::IncludePrivateRegistries)); 83 NetworkUtils::getDomainAndRegistry(
78 EXPECT_EQ("", NetworkUtils::getDomainAndRegistry( 84 "localhost", NetworkUtils::IncludePrivateRegistries));
79 "127.0.0.1", NetworkUtils::IncludePrivateRegistries)); 85 EXPECT_EQ("",
86 NetworkUtils::getDomainAndRegistry(
87 "127.0.0.1", NetworkUtils::IncludePrivateRegistries));
80 88
81 EXPECT_EQ("example.com", 89 EXPECT_EQ("example.com",
82 NetworkUtils::getDomainAndRegistry( 90 NetworkUtils::getDomainAndRegistry(
83 "example.com", NetworkUtils::IncludePrivateRegistries)); 91 "example.com", NetworkUtils::IncludePrivateRegistries));
84 EXPECT_EQ("example.com", 92 EXPECT_EQ("example.com",
85 NetworkUtils::getDomainAndRegistry( 93 NetworkUtils::getDomainAndRegistry(
86 "www.example.com", NetworkUtils::IncludePrivateRegistries)); 94 "www.example.com", NetworkUtils::IncludePrivateRegistries));
87 EXPECT_EQ("example.com", 95 EXPECT_EQ("example.com",
88 NetworkUtils::getDomainAndRegistry( 96 NetworkUtils::getDomainAndRegistry(
89 "static.example.com", NetworkUtils::IncludePrivateRegistries)); 97 "static.example.com", NetworkUtils::IncludePrivateRegistries));
90 EXPECT_EQ("example.com", NetworkUtils::getDomainAndRegistry( 98 EXPECT_EQ("example.com",
91 "multilevel.www.example.com", 99 NetworkUtils::getDomainAndRegistry(
92 NetworkUtils::IncludePrivateRegistries)); 100 "multilevel.www.example.com",
101 NetworkUtils::IncludePrivateRegistries));
93 EXPECT_EQ("example.co.uk", 102 EXPECT_EQ("example.co.uk",
94 NetworkUtils::getDomainAndRegistry( 103 NetworkUtils::getDomainAndRegistry(
95 "www.example.co.uk", NetworkUtils::IncludePrivateRegistries)); 104 "www.example.co.uk", NetworkUtils::IncludePrivateRegistries));
96 105
97 // Verify proper handling of 'private registries'. 106 // Verify proper handling of 'private registries'.
98 EXPECT_EQ("foo.appspot.com", 107 EXPECT_EQ("foo.appspot.com",
99 NetworkUtils::getDomainAndRegistry( 108 NetworkUtils::getDomainAndRegistry(
100 "www.foo.appspot.com", NetworkUtils::IncludePrivateRegistries)); 109 "www.foo.appspot.com", NetworkUtils::IncludePrivateRegistries));
101 EXPECT_EQ("appspot.com", 110 EXPECT_EQ("appspot.com",
102 NetworkUtils::getDomainAndRegistry( 111 NetworkUtils::getDomainAndRegistry(
103 "www.foo.appspot.com", NetworkUtils::ExcludePrivateRegistries)); 112 "www.foo.appspot.com", NetworkUtils::ExcludePrivateRegistries));
104 113
105 // Verify that unknown registries are included. 114 // Verify that unknown registries are included.
106 EXPECT_EQ("example.notarealregistry", 115 EXPECT_EQ("example.notarealregistry",
107 NetworkUtils::getDomainAndRegistry( 116 NetworkUtils::getDomainAndRegistry(
108 "www.example.notarealregistry", 117 "www.example.notarealregistry",
109 NetworkUtils::IncludePrivateRegistries)); 118 NetworkUtils::IncludePrivateRegistries));
110 } 119 }
111 120
112 } // namespace blink 121 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698