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

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

Issue 1809863002: Update some callers to use more direct ways of constructing IPAddress from well known literals. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rch feedbak Created 4 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
« no previous file with comments | « net/base/ip_address.cc ('k') | net/http/http_network_transaction_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) 2015 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2015 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/ip_address.h" 5 #include "net/base/ip_address.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/strings/string_number_conversions.h" 9 #include "base/strings/string_number_conversions.h"
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 EXPECT_TRUE(zero_ipv6_address.IsZero()); 75 EXPECT_TRUE(zero_ipv6_address.IsZero());
76 76
77 uint8_t address4[16] = {10}; 77 uint8_t address4[16] = {10};
78 IPAddress non_zero_ipv6_address(address4); 78 IPAddress non_zero_ipv6_address(address4);
79 EXPECT_FALSE(non_zero_ipv6_address.IsZero()); 79 EXPECT_FALSE(non_zero_ipv6_address.IsZero());
80 80
81 IPAddress empty_address; 81 IPAddress empty_address;
82 EXPECT_FALSE(empty_address.IsZero()); 82 EXPECT_FALSE(empty_address.IsZero());
83 } 83 }
84 84
85 TEST(IPAddressTest, AllZeros) {
86 EXPECT_TRUE(IPAddress::AllZeros(0).empty());
87
88 EXPECT_EQ(3u, IPAddress::AllZeros(3).size());
89 EXPECT_TRUE(IPAddress::AllZeros(3).IsZero());
90
91 EXPECT_EQ("0.0.0.0", IPAddress::IPv4AllZeros().ToString());
92 EXPECT_EQ("::", IPAddress::IPv6AllZeros().ToString());
93 }
94
85 TEST(IPAddressTest, ToString) { 95 TEST(IPAddressTest, ToString) {
86 uint8_t addr1[4] = {0, 0, 0, 0}; 96 uint8_t addr1[4] = {0, 0, 0, 0};
87 IPAddress ip_address1(addr1); 97 IPAddress ip_address1(addr1);
88 EXPECT_EQ("0.0.0.0", ip_address1.ToString()); 98 EXPECT_EQ("0.0.0.0", ip_address1.ToString());
89 99
90 uint8_t addr2[4] = {192, 168, 0, 1}; 100 uint8_t addr2[4] = {192, 168, 0, 1};
91 IPAddress ip_address2(addr2); 101 IPAddress ip_address2(addr2);
92 EXPECT_EQ("192.168.0.1", ip_address2.ToString()); 102 EXPECT_EQ("192.168.0.1", ip_address2.ToString());
93 103
94 uint8_t addr3[16] = {0xFE, 0xDC, 0xBA, 0x98}; 104 uint8_t addr3[16] = {0xFE, 0xDC, 0xBA, 0x98};
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
264 274
265 // Prefix is longer than the address. 275 // Prefix is longer than the address.
266 uint8_t ipv6_prefix5[] = {42, 0, 20, 80, 64, 12, 12, 9, 0, 276 uint8_t ipv6_prefix5[] = {42, 0, 20, 80, 64, 12, 12, 9, 0,
267 0, 0, 0, 0, 0, 0, 0, 10}; 277 0, 0, 0, 0, 0, 0, 0, 10};
268 EXPECT_FALSE(IPAddressStartsWith(ipv6_address, ipv6_prefix5)); 278 EXPECT_FALSE(IPAddressStartsWith(ipv6_address, ipv6_prefix5));
269 } 279 }
270 280
271 } // anonymous namespace 281 } // anonymous namespace
272 282
273 } // namespace net 283 } // namespace net
OLDNEW
« no previous file with comments | « net/base/ip_address.cc ('k') | net/http/http_network_transaction_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698