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

Unified 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 side-by-side diff with in-line comments
Download patch
« net/dns/dns_util.cc ('K') | « net/dns/dns_util.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/dns/dns_util_unittest.cc
diff --git a/net/dns/dns_util_unittest.cc b/net/dns/dns_util_unittest.cc
index 1d534716b6afead994e02d9789c3ef0f130371ed..c18c7427f9ce448e9263013955348df4e609559e 100644
--- a/net/dns/dns_util_unittest.cc
+++ b/net/dns/dns_util_unittest.cc
@@ -69,4 +69,26 @@ TEST_F(DNSUtilTest, DNSDomainToString) {
EXPECT_EQ("", DNSDomainToString("\x06"));
}
+TEST_F(DNSUtilTest, IsValidDNSDomain) {
+ const char* const bad_hostnames[] = {
+ "%20%20noodles.blorg", "noo dles.blorg ", "noo dles.blorg. ",
+ "^noodles.blorg", "noodles^.blorg", "noo&dles.blorg",
+ "noodles.blorg`", "www.-noodles.blorg",
+ };
+
+ for (size_t i = 0; i < arraysize(bad_hostnames); ++i) {
+ EXPECT_FALSE(IsValidDNSDomain(bad_hostnames[i]));
+ }
+
+ const char* const good_hostnames[] = {
+ "www.noodles.blorg", "1www.noodles.blorg", "www.2noodles.blorg",
+ "www.n--oodles.blorg", "www.noodl_es.blorg", "www.no-_odles.blorg",
+ "www_.noodles.blorg", "www.noodles.blorg.", "_privet._tcp.local",
+ };
+
+ for (size_t i = 0; i < arraysize(good_hostnames); ++i) {
+ EXPECT_TRUE(IsValidDNSDomain(good_hostnames[i]));
+ }
+}
+
} // namespace net
« 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