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

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

Issue 2739203003: Measure how often DNS hostnames aren't in preferred name form. (Closed)
Patch Set: We need to allow leading _. Created 3 years, 9 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
« net/dns/dns_util.cc ('K') | « net/dns/dns_util.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 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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_util.h" 5 #include "net/dns/dns_util.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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 DNSDomainToString(IncludeNUL("\003foo\003bar\002uk"))); 62 DNSDomainToString(IncludeNUL("\003foo\003bar\002uk")));
63 63
64 // It should cope with a lack of root label. 64 // It should cope with a lack of root label.
65 EXPECT_EQ("foo.bar", DNSDomainToString("\003foo\003bar")); 65 EXPECT_EQ("foo.bar", DNSDomainToString("\003foo\003bar"));
66 66
67 // Invalid inputs should return an empty string. 67 // Invalid inputs should return an empty string.
68 EXPECT_EQ("", DNSDomainToString(IncludeNUL("\x80"))); 68 EXPECT_EQ("", DNSDomainToString(IncludeNUL("\x80")));
69 EXPECT_EQ("", DNSDomainToString("\x06")); 69 EXPECT_EQ("", DNSDomainToString("\x06"));
70 } 70 }
71 71
72 TEST_F(DNSUtilTest, IsValidDNSDomain) {
73 const char* const bad_hostnames[] = {
74 "%20%20noodles.blorg", "noo dles.blorg ", "noo dles.blorg. ",
75 "^noodles.blorg", "noodles^.blorg", "noo&dles.blorg",
76 "noodles.blorg`", "www.-noodles.blorg",
77 };
78
79 for (size_t i = 0; i < arraysize(bad_hostnames); ++i) {
80 EXPECT_FALSE(IsValidDNSDomain(bad_hostnames[i]));
81 }
82
83 const char* const good_hostnames[] = {
84 "www.noodles.blorg", "1www.noodles.blorg", "www.2noodles.blorg",
85 "www.n--oodles.blorg", "www.noodl_es.blorg", "www.no-_odles.blorg",
86 "www_.noodles.blorg", "www.noodles.blorg.", "_privet._tcp.local",
87 };
88
89 for (size_t i = 0; i < arraysize(good_hostnames); ++i) {
90 EXPECT_TRUE(IsValidDNSDomain(good_hostnames[i]));
91 }
92 }
93
72 } // namespace net 94 } // namespace net
OLDNEW
« net/dns/dns_util.cc ('K') | « net/dns/dns_util.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698