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

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

Issue 23726043: Added NetworkInterface::network_prefix (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 2 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_posix.cc ('k') | net/base/net_util_win.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) 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 3273 matching lines...) Expand 10 before | Expand all | Expand 10 after
3284 EXPECT_FALSE(net::IsLocalhost("::1:1")); 3284 EXPECT_FALSE(net::IsLocalhost("::1:1"));
3285 EXPECT_FALSE(net::IsLocalhost("0:0:0:0:1:0:0:1")); 3285 EXPECT_FALSE(net::IsLocalhost("0:0:0:0:1:0:0:1"));
3286 EXPECT_FALSE(net::IsLocalhost("::1:1")); 3286 EXPECT_FALSE(net::IsLocalhost("::1:1"));
3287 EXPECT_FALSE(net::IsLocalhost("0:0:0:0:0:0:0:0:1")); 3287 EXPECT_FALSE(net::IsLocalhost("0:0:0:0:0:0:0:0:1"));
3288 } 3288 }
3289 3289
3290 // Verify GetNetworkList(). 3290 // Verify GetNetworkList().
3291 TEST(NetUtilTest, GetNetworkList) { 3291 TEST(NetUtilTest, GetNetworkList) {
3292 NetworkInterfaceList list; 3292 NetworkInterfaceList list;
3293 ASSERT_TRUE(GetNetworkList(&list)); 3293 ASSERT_TRUE(GetNetworkList(&list));
3294
3295 for (NetworkInterfaceList::iterator it = list.begin(); 3294 for (NetworkInterfaceList::iterator it = list.begin();
3296 it != list.end(); ++it) { 3295 it != list.end(); ++it) {
3297 // Verify that the name is not empty. 3296 // Verify that the name is not empty.
3298 EXPECT_FALSE(it->name.empty()); 3297 EXPECT_FALSE(it->name.empty());
3299 3298
3300 // Verify that the address is correct. 3299 // Verify that the address is correct.
3301 EXPECT_TRUE(it->address.size() == kIPv4AddressSize || 3300 EXPECT_TRUE(it->address.size() == kIPv4AddressSize ||
3302 it->address.size() == kIPv6AddressSize) 3301 it->address.size() == kIPv6AddressSize)
3303 << "Invalid address of size " << it->address.size(); 3302 << "Invalid address of size " << it->address.size();
3304 bool all_zeroes = true; 3303 bool all_zeroes = true;
3305 for (size_t i = 0; i < it->address.size(); ++i) { 3304 for (size_t i = 0; i < it->address.size(); ++i) {
3306 if (it->address[i] != 0) { 3305 if (it->address[i] != 0) {
3307 all_zeroes = false; 3306 all_zeroes = false;
3308 break; 3307 break;
3309 } 3308 }
3310 } 3309 }
3311 EXPECT_FALSE(all_zeroes); 3310 EXPECT_FALSE(all_zeroes);
3311 EXPECT_LE(it->network_prefix, it->address.size() * 8);
3312 } 3312 }
3313 } 3313 }
3314 3314
3315 static const base::FilePath::CharType* kSafePortableBasenames[] = { 3315 static const base::FilePath::CharType* kSafePortableBasenames[] = {
3316 FILE_PATH_LITERAL("a"), 3316 FILE_PATH_LITERAL("a"),
3317 FILE_PATH_LITERAL("a.txt"), 3317 FILE_PATH_LITERAL("a.txt"),
3318 FILE_PATH_LITERAL("a b.txt"), 3318 FILE_PATH_LITERAL("a b.txt"),
3319 FILE_PATH_LITERAL("a-b.txt"), 3319 FILE_PATH_LITERAL("a-b.txt"),
3320 FILE_PATH_LITERAL("My Computer"), 3320 FILE_PATH_LITERAL("My Computer"),
3321 FILE_PATH_LITERAL(" Computer"), 3321 FILE_PATH_LITERAL(" Computer"),
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
3468 TEST_P(NetUtilNonUniqueNameTest, IsHostnameNonUnique) { 3468 TEST_P(NetUtilNonUniqueNameTest, IsHostnameNonUnique) {
3469 const NonUniqueNameTestData& test_data = GetParam(); 3469 const NonUniqueNameTestData& test_data = GetParam();
3470 3470
3471 EXPECT_EQ(test_data.is_unique, IsUnique(test_data.hostname)); 3471 EXPECT_EQ(test_data.is_unique, IsUnique(test_data.hostname));
3472 } 3472 }
3473 3473
3474 INSTANTIATE_TEST_CASE_P(, NetUtilNonUniqueNameTest, 3474 INSTANTIATE_TEST_CASE_P(, NetUtilNonUniqueNameTest,
3475 testing::ValuesIn(kNonUniqueNameTestData)); 3475 testing::ValuesIn(kNonUniqueNameTestData));
3476 3476
3477 } // namespace net 3477 } // namespace net
OLDNEW
« no previous file with comments | « net/base/net_util_posix.cc ('k') | net/base/net_util_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698