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 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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 // Unknown schemes are not standard. |
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, ""}, | 203 {"data:/blahblah", "file.html", true, "data:/file.html"}, |
brettw
2012/12/06 00:25:10
This case seems fine to me. But it seems like we s
mkosiba (inactive)
2012/12/06 16:57:33
Done.
| |
204 // Filesystem URLs have different paths to test. | 204 // 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"}, | 205 {"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"}, | 206 {"filesystem:http://www.google.com/type/", "../foo.html", true, "filesystem: http://www.google.com/type/foo.html"}, |
207 }; | 207 }; |
208 | 208 |
209 for (size_t i = 0; i < ARRAYSIZE(resolve_cases); i++) { | 209 for (size_t i = 0; i < ARRAYSIZE(resolve_cases); i++) { |
210 // 8-bit code path. | 210 // 8-bit code path. |
211 GURL input(resolve_cases[i].base); | 211 GURL input(resolve_cases[i].base); |
212 GURL output = input.Resolve(resolve_cases[i].relative); | 212 GURL output = input.Resolve(resolve_cases[i].relative); |
213 EXPECT_EQ(resolve_cases[i].expected_valid, output.is_valid()) << i; | 213 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) { | 480 TEST(GURLTest, IsStandard) { |
481 GURL a("http:foo/bar"); | 481 GURL a("http:foo/bar"); |
482 EXPECT_TRUE(a.IsStandard()); | 482 EXPECT_TRUE(a.IsStandard()); |
483 | 483 |
484 GURL b("foo:bar/baz"); | 484 GURL b("foo:bar/baz"); |
485 EXPECT_FALSE(b.IsStandard()); | 485 EXPECT_FALSE(b.IsStandard()); |
486 | 486 |
487 GURL c("foo://bar/baz"); | 487 GURL c("foo://bar/baz"); |
488 EXPECT_FALSE(c.IsStandard()); | 488 EXPECT_FALSE(c.IsStandard()); |
489 } | 489 } |
OLD | NEW |