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 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
175 EXPECT_EQ("", url.username()); | 175 EXPECT_EQ("", url.username()); |
176 EXPECT_EQ("", url.password()); | 176 EXPECT_EQ("", url.password()); |
177 EXPECT_EQ("google.com", url.host()); | 177 EXPECT_EQ("google.com", url.host()); |
178 EXPECT_EQ("foo", url.port()); | 178 EXPECT_EQ("foo", url.port()); |
179 EXPECT_EQ(url_parse::PORT_INVALID, url.IntPort()); | 179 EXPECT_EQ(url_parse::PORT_INVALID, url.IntPort()); |
180 EXPECT_EQ("/", url.path()); | 180 EXPECT_EQ("/", url.path()); |
181 EXPECT_EQ("", url.query()); | 181 EXPECT_EQ("", url.query()); |
182 EXPECT_EQ("", url.ref()); | 182 EXPECT_EQ("", url.ref()); |
183 } | 183 } |
184 | 184 |
| 185 TEST(GURLTest, NonURL) { |
| 186 GURL url("random"); |
| 187 EXPECT_FALSE(url.is_valid()); |
| 188 EXPECT_EQ("random", url.possibly_invalid_spec()); |
| 189 } |
| 190 |
185 TEST(GURLTest, Resolve) { | 191 TEST(GURLTest, Resolve) { |
186 // The tricky cases for relative URL resolving are tested in the | 192 // The tricky cases for relative URL resolving are tested in the |
187 // canonicalizer unit test. Here, we just test that the GURL integration | 193 // canonicalizer unit test. Here, we just test that the GURL integration |
188 // works properly. | 194 // works properly. |
189 struct ResolveCase { | 195 struct ResolveCase { |
190 const char* base; | 196 const char* base; |
191 const char* relative; | 197 const char* relative; |
192 bool expected_valid; | 198 bool expected_valid; |
193 const char* expected; | 199 const char* expected; |
194 } resolve_cases[] = { | 200 } resolve_cases[] = { |
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
480 TEST(GURLTest, IsStandard) { | 486 TEST(GURLTest, IsStandard) { |
481 GURL a("http:foo/bar"); | 487 GURL a("http:foo/bar"); |
482 EXPECT_TRUE(a.IsStandard()); | 488 EXPECT_TRUE(a.IsStandard()); |
483 | 489 |
484 GURL b("foo:bar/baz"); | 490 GURL b("foo:bar/baz"); |
485 EXPECT_FALSE(b.IsStandard()); | 491 EXPECT_FALSE(b.IsStandard()); |
486 | 492 |
487 GURL c("foo://bar/baz"); | 493 GURL c("foo://bar/baz"); |
488 EXPECT_FALSE(c.IsStandard()); | 494 EXPECT_FALSE(c.IsStandard()); |
489 } | 495 } |
OLD | NEW |