| OLD | NEW |
| 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 <stddef.h> | 5 #include <stddef.h> |
| 6 | 6 |
| 7 #include "base/macros.h" | 7 #include "base/macros.h" |
| 8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
| 9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
| 10 #include "url/gurl.h" | 10 #include "url/gurl.h" |
| (...skipping 566 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 577 {"http://[x/", "[x", "[x"}, | 577 {"http://[x/", "[x", "[x"}, |
| 578 {"http://x]/", "x]", "x]"}, | 578 {"http://x]/", "x]", "x]"}, |
| 579 {"http://[/", "[", "["}, | 579 {"http://[/", "[", "["}, |
| 580 {"http://]/", "]", "]"}, | 580 {"http://]/", "]", "]"}, |
| 581 {"", "", ""}, | 581 {"", "", ""}, |
| 582 }; | 582 }; |
| 583 for (size_t i = 0; i < arraysize(cases); i++) { | 583 for (size_t i = 0; i < arraysize(cases); i++) { |
| 584 GURL url(cases[i].input); | 584 GURL url(cases[i].input); |
| 585 EXPECT_EQ(cases[i].expected_host, url.host()); | 585 EXPECT_EQ(cases[i].expected_host, url.host()); |
| 586 EXPECT_EQ(cases[i].expected_plainhost, url.HostNoBrackets()); | 586 EXPECT_EQ(cases[i].expected_plainhost, url.HostNoBrackets()); |
| 587 EXPECT_EQ(cases[i].expected_plainhost, url.HostNoBracketsPiece()); |
| 587 } | 588 } |
| 588 } | 589 } |
| 589 | 590 |
| 590 TEST(GURLTest, DomainIs) { | 591 TEST(GURLTest, DomainIs) { |
| 591 GURL url_1("http://google.com/foo"); | 592 GURL url_1("http://google.com/foo"); |
| 592 EXPECT_TRUE(url_1.DomainIs("google.com")); | 593 EXPECT_TRUE(url_1.DomainIs("google.com")); |
| 593 | 594 |
| 594 // Subdomain and port are ignored. | 595 // Subdomain and port are ignored. |
| 595 GURL url_2("http://www.google.com:99/foo"); | 596 GURL url_2("http://www.google.com:99/foo"); |
| 596 EXPECT_TRUE(url_2.DomainIs("google.com")); | 597 EXPECT_TRUE(url_2.DomainIs("google.com")); |
| (...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 823 // A versus B. | 824 // A versus B. |
| 824 EXPECT_EQ(test_case.are_equals, | 825 EXPECT_EQ(test_case.are_equals, |
| 825 GURL(test_case.url_a).EqualsIgnoringRef(GURL(test_case.url_b))); | 826 GURL(test_case.url_a).EqualsIgnoringRef(GURL(test_case.url_b))); |
| 826 // B versus A. | 827 // B versus A. |
| 827 EXPECT_EQ(test_case.are_equals, | 828 EXPECT_EQ(test_case.are_equals, |
| 828 GURL(test_case.url_b).EqualsIgnoringRef(GURL(test_case.url_a))); | 829 GURL(test_case.url_b).EqualsIgnoringRef(GURL(test_case.url_a))); |
| 829 } | 830 } |
| 830 } | 831 } |
| 831 | 832 |
| 832 } // namespace url | 833 } // namespace url |
| OLD | NEW |