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

Side by Side Diff: webrtc/base/socketaddress_unittest.cc

Issue 1516163003: Add "x"s in the end of a stripped IPv6 address string. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Fixed typo. Rebase. Created 5 years 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 | « webrtc/base/ipaddress_unittest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. 2 * Copyright 2004 The WebRTC Project Authors. All rights reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
11 #if defined(WEBRTC_POSIX) 11 #if defined(WEBRTC_POSIX)
12 #include <netinet/in.h> // for sockaddr_in 12 #include <netinet/in.h> // for sockaddr_in
13 #endif 13 #endif
14 14
15 #include "webrtc/base/gunit.h" 15 #include "webrtc/base/gunit.h"
16 #include "webrtc/base/socketaddress.h" 16 #include "webrtc/base/socketaddress.h"
17 #include "webrtc/base/ipaddress.h" 17 #include "webrtc/base/ipaddress.h"
18 18
19 namespace rtc { 19 namespace rtc {
20 20
21 const in6_addr kTestV6Addr = { { {0x20, 0x01, 0x0d, 0xb8, 21 const in6_addr kTestV6Addr = { { {0x20, 0x01, 0x0d, 0xb8,
22 0x10, 0x20, 0x30, 0x40, 22 0x10, 0x20, 0x30, 0x40,
23 0x50, 0x60, 0x70, 0x80, 23 0x50, 0x60, 0x70, 0x80,
24 0x90, 0xA0, 0xB0, 0xC0} } }; 24 0x90, 0xA0, 0xB0, 0xC0} } };
25 const in6_addr kMappedV4Addr = { { {0x00, 0x00, 0x00, 0x00, 25 const in6_addr kMappedV4Addr = { { {0x00, 0x00, 0x00, 0x00,
26 0x00, 0x00, 0x00, 0x00, 26 0x00, 0x00, 0x00, 0x00,
27 0x00, 0x00, 0xFF, 0xFF, 27 0x00, 0x00, 0xFF, 0xFF,
28 0x01, 0x02, 0x03, 0x04} } }; 28 0x01, 0x02, 0x03, 0x04} } };
29 const std::string kTestV6AddrString = "2001:db8:1020:3040:5060:7080:90a0:b0c0"; 29 const std::string kTestV6AddrString = "2001:db8:1020:3040:5060:7080:90a0:b0c0";
30 const std::string kTestV6AddrAnonymizedString = "2001:db8:1020::"; 30 const std::string kTestV6AddrAnonymizedString = "2001:db8:1020:x:x:x:x:x";
31 const std::string kTestV6AddrFullString = 31 const std::string kTestV6AddrFullString =
32 "[2001:db8:1020:3040:5060:7080:90a0:b0c0]:5678"; 32 "[2001:db8:1020:3040:5060:7080:90a0:b0c0]:5678";
33 const std::string kTestV6AddrFullAnonymizedString = "[2001:db8:1020::]:5678"; 33 const std::string kTestV6AddrFullAnonymizedString =
34 "[2001:db8:1020:x:x:x:x:x]:5678";
34 35
35 TEST(SocketAddressTest, TestDefaultCtor) { 36 TEST(SocketAddressTest, TestDefaultCtor) {
36 SocketAddress addr; 37 SocketAddress addr;
37 EXPECT_FALSE(addr.IsUnresolvedIP()); 38 EXPECT_FALSE(addr.IsUnresolvedIP());
38 EXPECT_EQ(IPAddress(), addr.ipaddr()); 39 EXPECT_EQ(IPAddress(), addr.ipaddr());
39 EXPECT_EQ(0, addr.port()); 40 EXPECT_EQ(0, addr.port());
40 EXPECT_EQ("", addr.hostname()); 41 EXPECT_EQ("", addr.hostname());
41 } 42 }
42 43
43 TEST(SocketAddressTest, TestIPPortCtor) { 44 TEST(SocketAddressTest, TestIPPortCtor) {
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after
341 EXPECT_EQ("[" + kTestV6AddrAnonymizedString + "]", 342 EXPECT_EQ("[" + kTestV6AddrAnonymizedString + "]",
342 addr_v6.HostAsSensitiveURIString()); 343 addr_v6.HostAsSensitiveURIString());
343 EXPECT_EQ(kTestV6AddrFullAnonymizedString, addr_v6.ToSensitiveString()); 344 EXPECT_EQ(kTestV6AddrFullAnonymizedString, addr_v6.ToSensitiveString());
344 #else 345 #else
345 EXPECT_EQ("[" + kTestV6AddrString + "]", addr_v6.HostAsSensitiveURIString()); 346 EXPECT_EQ("[" + kTestV6AddrString + "]", addr_v6.HostAsSensitiveURIString());
346 EXPECT_EQ(kTestV6AddrFullString, addr_v6.ToSensitiveString()); 347 EXPECT_EQ(kTestV6AddrFullString, addr_v6.ToSensitiveString());
347 #endif // defined(NDEBUG) 348 #endif // defined(NDEBUG)
348 } 349 }
349 350
350 } // namespace rtc 351 } // namespace rtc
OLDNEW
« no previous file with comments | « webrtc/base/ipaddress_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698