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

Side by Side Diff: net/dns/dns_hosts_unittest.cc

Issue 266243004: Clang format slam. Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 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
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/dns/dns_hosts.h" 5 #include "net/dns/dns_hosts.h"
6 6
7 #include "testing/gtest/include/gtest/gtest.h" 7 #include "testing/gtest/include/gtest/gtest.h"
8 8
9 namespace net { 9 namespace net {
10 10
(...skipping 17 matching lines...) Expand all
28 "256.0.0.0 cache3 # bogus IP should not clear parsed IP cache\n" 28 "256.0.0.0 cache3 # bogus IP should not clear parsed IP cache\n"
29 "127.0.0.1 cache4 # should still be reused\n" 29 "127.0.0.1 cache4 # should still be reused\n"
30 "127.0.0.2 cache5\n" 30 "127.0.0.2 cache5\n"
31 "gibberish"; 31 "gibberish";
32 32
33 const struct { 33 const struct {
34 const char* host; 34 const char* host;
35 AddressFamily family; 35 AddressFamily family;
36 const char* ip; 36 const char* ip;
37 } entries[] = { 37 } entries[] = {
38 { "localhost", ADDRESS_FAMILY_IPV4, "127.0.0.1" }, 38 {"localhost", ADDRESS_FAMILY_IPV4, "127.0.0.1"},
39 { "localhost.localdomain", ADDRESS_FAMILY_IPV4, "127.0.0.1" }, 39 {"localhost.localdomain", ADDRESS_FAMILY_IPV4, "127.0.0.1"},
40 { "company", ADDRESS_FAMILY_IPV4, "1.0.0.1" }, 40 {"company", ADDRESS_FAMILY_IPV4, "1.0.0.1"},
41 { "localhost", ADDRESS_FAMILY_IPV6, "::1" }, 41 {"localhost", ADDRESS_FAMILY_IPV6, "::1"},
42 { "ip6-localhost", ADDRESS_FAMILY_IPV6, "::1" }, 42 {"ip6-localhost", ADDRESS_FAMILY_IPV6, "::1"},
43 { "ip6-loopback", ADDRESS_FAMILY_IPV6, "::1" }, 43 {"ip6-loopback", ADDRESS_FAMILY_IPV6, "::1"},
44 { "ip6-localnet", ADDRESS_FAMILY_IPV6, "fe00::0" }, 44 {"ip6-localnet", ADDRESS_FAMILY_IPV6, "fe00::0"},
45 { "company", ADDRESS_FAMILY_IPV6, "2048::1" }, 45 {"company", ADDRESS_FAMILY_IPV6, "2048::1"},
46 { "example", ADDRESS_FAMILY_IPV6, "2048::2" }, 46 {"example", ADDRESS_FAMILY_IPV6, "2048::2"},
47 { "cache1", ADDRESS_FAMILY_IPV4, "127.0.0.1" }, 47 {"cache1", ADDRESS_FAMILY_IPV4, "127.0.0.1"},
48 { "cache2", ADDRESS_FAMILY_IPV4, "127.0.0.1" }, 48 {"cache2", ADDRESS_FAMILY_IPV4, "127.0.0.1"},
49 { "cache4", ADDRESS_FAMILY_IPV4, "127.0.0.1" }, 49 {"cache4", ADDRESS_FAMILY_IPV4, "127.0.0.1"},
50 { "cache5", ADDRESS_FAMILY_IPV4, "127.0.0.2" }, 50 {"cache5", ADDRESS_FAMILY_IPV4, "127.0.0.2"},
51 }; 51 };
52 52
53 DnsHosts expected; 53 DnsHosts expected;
54 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(entries); ++i) { 54 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(entries); ++i) {
55 DnsHostsKey key(entries[i].host, entries[i].family); 55 DnsHostsKey key(entries[i].host, entries[i].family);
56 IPAddressNumber& ip = expected[key]; 56 IPAddressNumber& ip = expected[key];
57 ASSERT_TRUE(ip.empty()); 57 ASSERT_TRUE(ip.empty());
58 ASSERT_TRUE(ParseIPLiteralToNumber(entries[i].ip, &ip)); 58 ASSERT_TRUE(ParseIPLiteralToNumber(entries[i].ip, &ip));
59 ASSERT_EQ(ip.size(), (entries[i].family == ADDRESS_FAMILY_IPV4) ? 4u : 16u); 59 ASSERT_EQ(ip.size(), (entries[i].family == ADDRESS_FAMILY_IPV4) ? 4u : 16u);
60 } 60 }
61 61
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 114
115 TEST(DnsHostsTest, HostsParser_EndsWithNewlineAndToken) { 115 TEST(DnsHostsTest, HostsParser_EndsWithNewlineAndToken) {
116 DnsHosts hosts; 116 DnsHosts hosts;
117 ParseHosts("127.0.0.1 localhost\ntoken", &hosts); 117 ParseHosts("127.0.0.1 localhost\ntoken", &hosts);
118 EXPECT_EQ(1u, hosts.size()); 118 EXPECT_EQ(1u, hosts.size());
119 } 119 }
120 120
121 } // namespace 121 } // namespace
122 122
123 } // namespace net 123 } // namespace net
124
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698