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

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

Issue 1692353002: Make IP Address related functions return the empty string when used on an invalid address. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fixes Created 4 years, 10 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
« net/base/ip_address_number.cc ('K') | « net/base/ip_endpoint.h ('k') | no next file » | 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/ip_endpoint.h" 5 #include "net/base/ip_endpoint.h"
6 6
7 #include "build/build_config.h" 7 #include "build/build_config.h"
8 8
9 #if defined(OS_WIN) 9 #if defined(OS_WIN)
10 #include <winsock2.h> 10 #include <winsock2.h>
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 IPEndPoint endpoint; 191 IPEndPoint endpoint;
192 EXPECT_EQ(0, endpoint.port()); 192 EXPECT_EQ(0, endpoint.port());
193 193
194 for (uint16_t index = 0; index < test_count; ++index) { 194 for (uint16_t index = 0; index < test_count; ++index) {
195 uint16_t port = 100 + index; 195 uint16_t port = 100 + index;
196 IPEndPoint endpoint(tests[index].ip_address, port); 196 IPEndPoint endpoint(tests[index].ip_address, port);
197 const std::string result = endpoint.ToString(); 197 const std::string result = endpoint.ToString();
198 EXPECT_EQ(tests[index].host_normalized + ":" + base::UintToString(port), 198 EXPECT_EQ(tests[index].host_normalized + ":" + base::UintToString(port),
199 result); 199 result);
200 } 200 }
201
202 // ToString() shouldn't crash on invalid addresses.
203 IPAddress invalid_address;
204 IPEndPoint invalid_endpoint(invalid_address, 8080);
205 EXPECT_EQ("", invalid_endpoint.ToString());
206 EXPECT_EQ("", invalid_endpoint.ToStringWithoutPort());
201 } 207 }
202 208
203 } // namespace 209 } // namespace
204 210
205 } // namespace net 211 } // namespace net
OLDNEW
« net/base/ip_address_number.cc ('K') | « net/base/ip_endpoint.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698