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

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

Issue 10855163: Revert 151586 - [net/dns] Resolve AF_UNSPEC on dual-stacked systems. Sort addresses according to RF… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 4 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
« no previous file with comments | « net/base/net_util.cc ('k') | net/dns/address_sorter.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Property Changes:
Added: svn:mergeinfo
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 <string.h> 7 #include <string.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 10
(...skipping 3031 matching lines...) Expand 10 before | Expand all | Expand 10 after
3042 EXPECT_TRUE(ParseIPLiteralToNumber("192.168.0.1", &ipv4_number)); 3042 EXPECT_TRUE(ParseIPLiteralToNumber("192.168.0.1", &ipv4_number));
3043 3043
3044 IPAddressNumber ipv6_number = 3044 IPAddressNumber ipv6_number =
3045 ConvertIPv4NumberToIPv6Number(ipv4_number); 3045 ConvertIPv4NumberToIPv6Number(ipv4_number);
3046 3046
3047 // ::ffff:192.168.1.1 3047 // ::ffff:192.168.1.1
3048 EXPECT_EQ("0,0,0,0,0,0,0,0,0,0,255,255,192,168,0,1", 3048 EXPECT_EQ("0,0,0,0,0,0,0,0,0,0,255,255,192,168,0,1",
3049 DumpIPNumber(ipv6_number)); 3049 DumpIPNumber(ipv6_number));
3050 } 3050 }
3051 3051
3052 TEST(NetUtilTest, IsIPv4Mapped) {
3053 IPAddressNumber ipv4_number;
3054 EXPECT_TRUE(ParseIPLiteralToNumber("192.168.0.1", &ipv4_number));
3055 EXPECT_FALSE(IsIPv4Mapped(ipv4_number));
3056
3057 IPAddressNumber ipv6_number;
3058 EXPECT_TRUE(ParseIPLiteralToNumber("::1", &ipv4_number));
3059 EXPECT_FALSE(IsIPv4Mapped(ipv6_number));
3060
3061 IPAddressNumber ipv4mapped_number;
3062 EXPECT_TRUE(ParseIPLiteralToNumber("::ffff:0101:1", &ipv4mapped_number));
3063 EXPECT_TRUE(IsIPv4Mapped(ipv4mapped_number));
3064 }
3065
3066 TEST(NetUtilTest, ConvertIPv4MappedToIPv4) {
3067 IPAddressNumber ipv4mapped_number;
3068 EXPECT_TRUE(ParseIPLiteralToNumber("::ffff:0101:1", &ipv4mapped_number));
3069 IPAddressNumber expected;
3070 EXPECT_TRUE(ParseIPLiteralToNumber("1.1.0.1", &expected));
3071 IPAddressNumber result = ConvertIPv4MappedToIPv4(ipv4mapped_number);
3072 EXPECT_EQ(expected, result);
3073 }
3074
3075 // Test parsing invalid CIDR notation literals. 3052 // Test parsing invalid CIDR notation literals.
3076 TEST(NetUtilTest, ParseCIDRBlock_Invalid) { 3053 TEST(NetUtilTest, ParseCIDRBlock_Invalid) {
3077 const char* bad_literals[] = { 3054 const char* bad_literals[] = {
3078 "foobar", 3055 "foobar",
3079 "", 3056 "",
3080 "192.168.0.1", 3057 "192.168.0.1",
3081 "::1", 3058 "::1",
3082 "/", 3059 "/",
3083 "/1", 3060 "/1",
3084 "1", 3061 "1",
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
3241 if (it->address[i] != 0) { 3218 if (it->address[i] != 0) {
3242 all_zeroes = false; 3219 all_zeroes = false;
3243 break; 3220 break;
3244 } 3221 }
3245 } 3222 }
3246 EXPECT_FALSE(all_zeroes); 3223 EXPECT_FALSE(all_zeroes);
3247 } 3224 }
3248 } 3225 }
3249 3226
3250 } // namespace net 3227 } // namespace net
OLDNEW
« no previous file with comments | « net/base/net_util.cc ('k') | net/dns/address_sorter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698