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

Side by Side Diff: net/base/url_util_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: Factor out IsDomainMatch from CanonicalCookie and use it in SdchDictionary. 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 unified diff | Download patch
« no previous file with comments | « net/base/url_util.cc ('k') | net/cookies/canonical_cookie.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/base/url_util.h" 5 #include "net/base/url_util.h"
6 6
7 #include <ostream> 7 #include <ostream>
8 8
9 #include "base/format_macros.h" 9 #include "base/format_macros.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
(...skipping 564 matching lines...) Expand 10 before | Expand all | Expand 10 after
575 {GURL("http://google.co"), false}, 575 {GURL("http://google.co"), false},
576 {GURL("http://oggole.com"), false}, 576 {GURL("http://oggole.com"), false},
577 }; 577 };
578 578
579 for (size_t i = 0; i < arraysize(google_host_cases); ++i) { 579 for (size_t i = 0; i < arraysize(google_host_cases); ++i) {
580 EXPECT_EQ(google_host_cases[i].expected_output, 580 EXPECT_EQ(google_host_cases[i].expected_output,
581 HasGoogleHost(google_host_cases[i].url)); 581 HasGoogleHost(google_host_cases[i].url));
582 } 582 }
583 } 583 }
584 584
585 TEST(UrlUtilTest, IsDomainMatch) {
586 GURL url("http://www.example.com/test/foo.html");
587
588 std::string domain = "www.example.com";
589 EXPECT_TRUE(IsDomainMatch(domain, "www.example.com"));
590 EXPECT_FALSE(IsDomainMatch(domain, "foo.www.example.com"));
591 EXPECT_FALSE(IsDomainMatch(domain, "www0.example.com"));
592 EXPECT_FALSE(IsDomainMatch(domain, "example.com"));
593
594 domain = ".www.example.com";
595 EXPECT_TRUE(IsDomainMatch(domain, "www.example.com"));
596 EXPECT_TRUE(IsDomainMatch(domain, "www.example.com"));
597 EXPECT_TRUE(IsDomainMatch(domain, "foo.www.example.com"));
598 EXPECT_FALSE(IsDomainMatch(domain, "www0.example.com"));
599 EXPECT_FALSE(IsDomainMatch(domain, "example.com"));
600 }
601
585 } // namespace 602 } // namespace
586 } // namespace net 603 } // namespace net
OLDNEW
« no previous file with comments | « net/base/url_util.cc ('k') | net/cookies/canonical_cookie.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698