| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "net/base/host_port_pair.h" | 5 #include "net/base/host_port_pair.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "net/test/gtest_util.h" | 8 #include "net/test/gtest_util.h" |
| 9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
| 10 | 10 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 TEST(HostPortPairTest, Parsing) { | 31 TEST(HostPortPairTest, Parsing) { |
| 32 HostPortPair foo("foo.com", 10); | 32 HostPortPair foo("foo.com", 10); |
| 33 string foo_str = foo.ToString(); | 33 string foo_str = foo.ToString(); |
| 34 EXPECT_EQ("foo.com:10", foo_str); | 34 EXPECT_EQ("foo.com:10", foo_str); |
| 35 HostPortPair bar = HostPortPair::FromString(foo_str); | 35 HostPortPair bar = HostPortPair::FromString(foo_str); |
| 36 EXPECT_TRUE(foo.Equals(bar)); | 36 EXPECT_TRUE(foo.Equals(bar)); |
| 37 } | 37 } |
| 38 | 38 |
| 39 TEST(HostPortPairTest, BadString) { | 39 TEST(HostPortPairTest, BadString) { |
| 40 const char* kBadStrings[] = { | 40 const char* kBadStrings[] = { |
| 41 "foo.com:2:3", | 41 "foo.com:2:3", "bar.com:two", "www.google.com:-1", |
| 42 "bar.com:two", | 42 "www.google.com:+1", "127.0.0.1:65536", "[2001:db8::42]:65536", |
| 43 "www.google.com:-1", | |
| 44 "127.0.0.1:65536", | |
| 45 "[2001:db8::42]:65536", | |
| 46 }; | 43 }; |
| 47 | 44 |
| 48 for (size_t index = 0; index < arraysize(kBadStrings); ++index) { | 45 for (size_t index = 0; index < arraysize(kBadStrings); ++index) { |
| 49 HostPortPair foo = HostPortPair::FromString(kBadStrings[index]); | 46 HostPortPair foo = HostPortPair::FromString(kBadStrings[index]); |
| 50 EXPECT_TRUE(foo.host().empty()); | 47 EXPECT_TRUE(foo.host().empty()); |
| 51 EXPECT_EQ(0, foo.port()); | 48 EXPECT_EQ(0, foo.port()); |
| 52 } | 49 } |
| 53 } | 50 } |
| 54 | 51 |
| 55 TEST(HostPortPairTest, Emptiness) { | 52 TEST(HostPortPairTest, Emptiness) { |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 | 109 |
| 113 EXPECT_TRUE(new_a_10.Equals(a_10)); | 110 EXPECT_TRUE(new_a_10.Equals(a_10)); |
| 114 EXPECT_FALSE(new_a_10.Equals(a_11)); | 111 EXPECT_FALSE(new_a_10.Equals(a_11)); |
| 115 EXPECT_FALSE(new_a_10.Equals(b_10)); | 112 EXPECT_FALSE(new_a_10.Equals(b_10)); |
| 116 EXPECT_FALSE(new_a_10.Equals(b_11)); | 113 EXPECT_FALSE(new_a_10.Equals(b_11)); |
| 117 } | 114 } |
| 118 | 115 |
| 119 } // namespace | 116 } // namespace |
| 120 | 117 |
| 121 } // namespace net | 118 } // namespace net |
| OLD | NEW |