OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "testing/gtest/include/gtest/gtest.h" | 7 #include "testing/gtest/include/gtest/gtest.h" |
8 | 8 |
9 namespace net { | 9 namespace net { |
10 | 10 |
11 namespace { | 11 namespace { |
12 | 12 |
13 TEST(HostPortPairTest, Parsing) { | 13 TEST(HostPortPairTest, Parsing) { |
14 HostPortPair foo("foo.com", 10); | 14 HostPortPair foo("foo.com", 10); |
15 std::string foo_str = foo.ToString(); | 15 std::string foo_str = foo.ToString(); |
16 EXPECT_EQ("foo.com:10", foo_str); | 16 EXPECT_EQ("foo.com:10", foo_str); |
17 HostPortPair bar = HostPortPair::FromString(foo_str); | 17 HostPortPair bar = HostPortPair::FromString(foo_str); |
18 EXPECT_TRUE(foo.Equals(bar)); | 18 EXPECT_TRUE(foo.Equals(bar)); |
19 } | 19 } |
20 | 20 |
| 21 TEST(HostPortPairTest, BadString) { |
| 22 HostPortPair foo = HostPortPair::FromString("foo.com:2:3"); |
| 23 EXPECT_TRUE(foo.host().empty()); |
| 24 EXPECT_EQ(0, foo.port()); |
| 25 |
| 26 HostPortPair bar = HostPortPair::FromString("bar.com:two"); |
| 27 EXPECT_TRUE(bar.host().empty()); |
| 28 EXPECT_EQ(0, bar.port()); |
| 29 } |
| 30 |
21 } // namespace | 31 } // namespace |
22 | 32 |
23 } // namespace net | 33 } // namespace net |
OLD | NEW |