| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 #include <stdint.h> | 6 #include <stdint.h> |
| 7 | 7 |
| 8 #include "base/macros.h" | 8 #include "base/macros.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" |
| 11 #include "url/scheme_host_port.h" | 11 #include "url/scheme_host_port.h" |
| 12 | 12 |
| 13 namespace { | 13 namespace { |
| 14 | 14 |
| 15 TEST(SchemeHostPortTest, Invalid) { | 15 TEST(SchemeHostPortTest, Invalid) { |
| 16 url::SchemeHostPort invalid; | 16 url::SchemeHostPort invalid; |
| 17 EXPECT_EQ("", invalid.scheme()); | 17 EXPECT_EQ("", invalid.scheme()); |
| 18 EXPECT_EQ("", invalid.host()); | 18 EXPECT_EQ("", invalid.host()); |
| 19 EXPECT_EQ(0, invalid.port()); | 19 EXPECT_EQ(0, invalid.port()); |
| 20 EXPECT_TRUE(invalid.IsInvalid()); | 20 EXPECT_TRUE(invalid.IsInvalid()); |
| 21 EXPECT_TRUE(invalid.Equals(invalid)); | 21 EXPECT_TRUE(invalid.Equals(invalid)); |
| 22 | 22 |
| 23 const char* urls[] = {"data:text/html,Hello!", | 23 const char* urls[] = {"data:text/html,Hello!", |
| 24 "javascript:alert(1)", | 24 "javascript:alert(1)", |
| 25 "file://example.com:443/etc/passwd", | 25 "file://example.com:443/etc/passwd", |
| 26 "blob:https://example.com/uuid-goes-here", | 26 "blob:https://example.com/uuid-goes-here", |
| 27 "filesystem:https://example.com/temporary/yay.png"}; | 27 "filesystem:https://example.com/temporary/yay.png"}; |
| 28 | 28 |
| 29 for (const auto& test : urls) { | 29 for (auto* test : urls) { |
| 30 SCOPED_TRACE(test); | 30 SCOPED_TRACE(test); |
| 31 GURL url(test); | 31 GURL url(test); |
| 32 url::SchemeHostPort tuple(url); | 32 url::SchemeHostPort tuple(url); |
| 33 EXPECT_EQ("", tuple.scheme()); | 33 EXPECT_EQ("", tuple.scheme()); |
| 34 EXPECT_EQ("", tuple.host()); | 34 EXPECT_EQ("", tuple.host()); |
| 35 EXPECT_EQ(0, tuple.port()); | 35 EXPECT_EQ(0, tuple.port()); |
| 36 EXPECT_TRUE(tuple.IsInvalid()); | 36 EXPECT_TRUE(tuple.IsInvalid()); |
| 37 EXPECT_TRUE(tuple.Equals(tuple)); | 37 EXPECT_TRUE(tuple.Equals(tuple)); |
| 38 EXPECT_TRUE(tuple.Equals(invalid)); | 38 EXPECT_TRUE(tuple.Equals(invalid)); |
| 39 EXPECT_TRUE(invalid.Equals(tuple)); | 39 EXPECT_TRUE(invalid.Equals(tuple)); |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 210 for (size_t j = i; j < arraysize(tuples); j++) { | 210 for (size_t j = i; j < arraysize(tuples); j++) { |
| 211 url::SchemeHostPort to_compare(tuples[j].scheme, tuples[j].host, | 211 url::SchemeHostPort to_compare(tuples[j].scheme, tuples[j].host, |
| 212 tuples[j].port); | 212 tuples[j].port); |
| 213 EXPECT_EQ(i < j, current < to_compare) << i << " < " << j; | 213 EXPECT_EQ(i < j, current < to_compare) << i << " < " << j; |
| 214 EXPECT_EQ(j < i, to_compare < current) << j << " < " << i; | 214 EXPECT_EQ(j < i, to_compare < current) << j << " < " << i; |
| 215 } | 215 } |
| 216 } | 216 } |
| 217 } | 217 } |
| 218 | 218 |
| 219 } // namespace url | 219 } // namespace url |
| OLD | NEW |