| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 |
| 11 namespace { | 11 namespace { |
| 12 | 12 |
| 13 TEST(DnsHostsTest, ParseHosts) { | 13 TEST(DnsHostsTest, ParseHosts) { |
| 14 std::string contents = | 14 std::string contents = |
| 15 "127.0.0.1 localhost\tlocalhost.localdomain # standard\n" | 15 "127.0.0.1 localhost\tlocalhost.localdomain # standard\n" |
| 16 "\n" | 16 "\n" |
| 17 "1.0.0.1 localhost # ignored, first hit above\n" | 17 "1.0.0.1 localhost # ignored, first hit above\n" |
| 18 "fe00::x example company # ignored, malformed IPv6\n" | 18 "fe00::x example company # ignored, malformed IPv6\n" |
| 19 "1.0.0.300 company # ignored, malformed IPv4\n" | 19 "1.0.0.300 company # ignored, malformed IPv4\n" |
| 20 "1.0.0.1 # ignored, missing hostname\n" | 20 "1.0.0.1 # ignored, missing hostname\n" |
| 21 "1.0.0.1\t company \n" | 21 "1.0.0.1\t CoMpANy # normalized to 'company' \n" |
| 22 "::1\tlocalhost ip6-localhost ip6-loopback # comment # within a comment\n" | 22 "::1\tlocalhost ip6-localhost ip6-loopback # comment # within a comment\n" |
| 23 "\t fe00::0 ip6-localnet\r\n" | 23 "\t fe00::0 ip6-localnet\r\n" |
| 24 "2048::2 example\n" | 24 "2048::2 example\n" |
| 25 "2048::1 company example # ignored for 'example' \n" | 25 "2048::1 company example # ignored for 'example' \n" |
| 26 "gibberish"; | 26 "gibberish"; |
| 27 | 27 |
| 28 const struct { | 28 const struct { |
| 29 const char* host; | 29 const char* host; |
| 30 AddressFamily family; | 30 AddressFamily family; |
| 31 const char* ip; | 31 const char* ip; |
| (...skipping 20 matching lines...) Expand all Loading... |
| 52 | 52 |
| 53 DnsHosts hosts; | 53 DnsHosts hosts; |
| 54 ParseHosts(contents, &hosts); | 54 ParseHosts(contents, &hosts); |
| 55 ASSERT_EQ(expected, hosts); | 55 ASSERT_EQ(expected, hosts); |
| 56 } | 56 } |
| 57 | 57 |
| 58 } // namespace | 58 } // namespace |
| 59 | 59 |
| 60 } // namespace net | 60 } // namespace net |
| 61 | 61 |
| OLD | NEW |