file_manager: Fix a bug where hosted documents could not be opened without active...
[chromium-blink-merge.git] / net / base / host_port_pair_unittest.cc
blobd654622dd0036a4dda06aebaf879ab09f5d1148e
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
3 // found in the LICENSE file.
5 #include "net/base/host_port_pair.h"
7 #include "testing/gtest/include/gtest/gtest.h"
9 namespace net {
11 namespace {
13 TEST(HostPortPairTest, Parsing) {
14 HostPortPair foo("foo.com", 10);
15 std::string foo_str = foo.ToString();
16 EXPECT_EQ("foo.com:10", foo_str);
17 HostPortPair bar = HostPortPair::FromString(foo_str);
18 EXPECT_TRUE(foo.Equals(bar));
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());
26 HostPortPair bar = HostPortPair::FromString("bar.com:two");
27 EXPECT_TRUE(bar.host().empty());
28 EXPECT_EQ(0, bar.port());
31 TEST(HostPortPairTest, Emptiness) {
32 HostPortPair foo;
33 EXPECT_TRUE(foo.IsEmpty());
34 foo = HostPortPair::FromString("foo.com:8080");
35 EXPECT_FALSE(foo.IsEmpty());
38 } // namespace
40 } // namespace net