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

Unified Diff: net/base/sdch_dictionary_unittest.cc

Issue 1876683002: Implement SDCH Dictionary domain matching as per RFC 2965 Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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/base/sdch_dictionary.cc ('K') | « net/base/sdch_dictionary.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/base/sdch_dictionary_unittest.cc
diff --git a/net/base/sdch_dictionary_unittest.cc b/net/base/sdch_dictionary_unittest.cc
index d9fd92e7db41ba8e77791f8ed1287607cd219702..46696bc31ced75406e53f3025382bfe393238bcf 100644
--- a/net/base/sdch_dictionary_unittest.cc
+++ b/net/base/sdch_dictionary_unittest.cc
@@ -116,6 +116,23 @@ TEST(SdchDictionaryTest, PathMatch) {
EXPECT_FALSE(PathMatch("/abc", "/ABC"));
}
+TEST(SdchDictionaryTest, DomainMatch) {
+ bool (*DomainMatch)(const GURL& url, const std::string& restriction) =
+ SdchDictionary::DomainMatch;
+ EXPECT_TRUE(DomainMatch(GURL("http://example.com"), "example.com"));
+ EXPECT_TRUE(DomainMatch(GURL("http://www.example.com"), ".example.com"));
+
+ // Trailing dot handling
+ EXPECT_TRUE(DomainMatch(GURL("http://example.com./"), "example.com"));
+ EXPECT_TRUE(DomainMatch(GURL("http://example.com/"), "example.com."));
+
+ EXPECT_FALSE(DomainMatch(GURL("http://www.example.com"), "example.com"));
+ EXPECT_FALSE(DomainMatch(GURL("http://badexample.com"), "example.com"));
+ EXPECT_FALSE(DomainMatch(GURL("http://badexample.com"), ".example.com"));
+ EXPECT_FALSE(DomainMatch(GURL("http://example.com.tld"), "example.com"));
+ EXPECT_FALSE(DomainMatch(GURL("http://example.com.tld"), ".example.com"));
+}
+
TEST(SdchDictionaryTest, Expired) {
EXPECT_TRUE(
SdchDictionary("xyzzy", 0u, "ch", "sh", GURL("http://www.example.com"),
« net/base/sdch_dictionary.cc ('K') | « net/base/sdch_dictionary.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698