| 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/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 Loading... |
| 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 |
| OLD | NEW |