Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(104)

Side by Side Diff: net/base/host_port_pair_unittest.cc

Issue 1829873002: Add base/parse_number.h to generalize number parsing done in //net. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: more tests Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « net/base/host_port_pair.cc ('k') | net/base/ip_address.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
OLDNEW
« no previous file with comments | « net/base/host_port_pair.cc ('k') | net/base/ip_address.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698