OLD | NEW |
1 // Copyright 2007 Google Inc. All Rights Reserved. | 1 // Copyright 2007 Google Inc. All Rights Reserved. |
2 // Author: brettw@google.com (Brett Wilson) | 2 // Author: brettw@google.com (Brett Wilson) |
3 | 3 |
4 #include "googleurl/src/gurl.h" | 4 #include "googleurl/src/gurl.h" |
5 #include "googleurl/src/url_canon.h" | 5 #include "googleurl/src/url_canon.h" |
6 #include "googleurl/src/url_test_utils.h" | 6 #include "googleurl/src/url_test_utils.h" |
7 #include "testing/gtest/include/gtest/gtest.h" | 7 #include "testing/gtest/include/gtest/gtest.h" |
8 | 8 |
9 // Some implementations of base/basictypes.h may define ARRAYSIZE. | 9 // Some implementations of base/basictypes.h may define ARRAYSIZE. |
10 // If it's not defined, we define it to the ARRAYSIZE_UNSAFE macro | 10 // If it's not defined, we define it to the ARRAYSIZE_UNSAFE macro |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
190 const char* base; | 190 const char* base; |
191 const char* relative; | 191 const char* relative; |
192 bool expected_valid; | 192 bool expected_valid; |
193 const char* expected; | 193 const char* expected; |
194 } resolve_cases[] = { | 194 } resolve_cases[] = { |
195 {"http://www.google.com/", "foo.html", true, "http://www.google.com/foo.html
"}, | 195 {"http://www.google.com/", "foo.html", true, "http://www.google.com/foo.html
"}, |
196 {"http://www.google.com/", "http://images.google.com/foo.html", true, "http:
//images.google.com/foo.html"}, | 196 {"http://www.google.com/", "http://images.google.com/foo.html", true, "http:
//images.google.com/foo.html"}, |
197 {"http://www.google.com/blah/bloo?c#d", "../../../hello/./world.html?a#b", t
rue, "http://www.google.com/hello/world.html?a#b"}, | 197 {"http://www.google.com/blah/bloo?c#d", "../../../hello/./world.html?a#b", t
rue, "http://www.google.com/hello/world.html?a#b"}, |
198 {"http://www.google.com/foo#bar", "#com", true, "http://www.google.com/foo#c
om"}, | 198 {"http://www.google.com/foo#bar", "#com", true, "http://www.google.com/foo#c
om"}, |
199 {"http://www.google.com/", "Https:images.google.com", true, "https://images.
google.com/"}, | 199 {"http://www.google.com/", "Https:images.google.com", true, "https://images.
google.com/"}, |
200 // Unknown schemes are not standard. | 200 // A non-standard base can be replaced with a standard absolute URL. |
201 {"data:blahblah", "http://google.com/", true, "http://google.com/"}, | 201 {"data:blahblah", "http://google.com/", true, "http://google.com/"}, |
202 {"data:blahblah", "http:google.com", true, "http://google.com/"}, | 202 {"data:blahblah", "http:google.com", true, "http://google.com/"}, |
203 {"data:/blahblah", "file.html", false, ""}, | |
204 // Filesystem URLs have different paths to test. | 203 // Filesystem URLs have different paths to test. |
205 {"filesystem:http://www.google.com/type/", "foo.html", true, "filesystem:htt
p://www.google.com/type/foo.html"}, | 204 {"filesystem:http://www.google.com/type/", "foo.html", true, "filesystem:htt
p://www.google.com/type/foo.html"}, |
206 {"filesystem:http://www.google.com/type/", "../foo.html", true, "filesystem:
http://www.google.com/type/foo.html"}, | 205 {"filesystem:http://www.google.com/type/", "../foo.html", true, "filesystem:
http://www.google.com/type/foo.html"}, |
207 }; | 206 }; |
208 | 207 |
209 for (size_t i = 0; i < ARRAYSIZE(resolve_cases); i++) { | 208 for (size_t i = 0; i < ARRAYSIZE(resolve_cases); i++) { |
210 // 8-bit code path. | 209 // 8-bit code path. |
211 GURL input(resolve_cases[i].base); | 210 GURL input(resolve_cases[i].base); |
212 GURL output = input.Resolve(resolve_cases[i].relative); | 211 GURL output = input.Resolve(resolve_cases[i].relative); |
213 EXPECT_EQ(resolve_cases[i].expected_valid, output.is_valid()) << i; | 212 EXPECT_EQ(resolve_cases[i].expected_valid, output.is_valid()) << i; |
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
480 TEST(GURLTest, IsStandard) { | 479 TEST(GURLTest, IsStandard) { |
481 GURL a("http:foo/bar"); | 480 GURL a("http:foo/bar"); |
482 EXPECT_TRUE(a.IsStandard()); | 481 EXPECT_TRUE(a.IsStandard()); |
483 | 482 |
484 GURL b("foo:bar/baz"); | 483 GURL b("foo:bar/baz"); |
485 EXPECT_FALSE(b.IsStandard()); | 484 EXPECT_FALSE(b.IsStandard()); |
486 | 485 |
487 GURL c("foo://bar/baz"); | 486 GURL c("foo://bar/baz"); |
488 EXPECT_FALSE(c.IsStandard()); | 487 EXPECT_FALSE(c.IsStandard()); |
489 } | 488 } |
OLD | NEW |