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

Side by Side Diff: net/proxy/proxy_server_unittest.cc

Issue 3197018: Refactor: change the spdy session pool key to take a ProxyServer instead of a stri... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « net/proxy/proxy_server.cc ('k') | net/spdy/spdy_http_stream_unittest.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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 "base/basictypes.h" 5 #include "base/basictypes.h"
6 #include "net/proxy/proxy_server.h" 6 #include "net/proxy/proxy_server.h"
7 #include "testing/gtest/include/gtest/gtest.h" 7 #include "testing/gtest/include/gtest/gtest.h"
8 8
9 // Test the creation of ProxyServer using ProxyServer::FromURI, which parses 9 // Test the creation of ProxyServer using ProxyServer::FromURI, which parses
10 // inputs of the form [<scheme>"://"]<host>[":"<port>]. Verify that each part 10 // inputs of the form [<scheme>"://"]<host>[":"<port>]. Verify that each part
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after
293 "HTTPS", // missing host/port. 293 "HTTPS", // missing host/port.
294 "SOCKS", // missing host/port. 294 "SOCKS", // missing host/port.
295 "DIRECT foopy:10", // direct cannot have host/port. 295 "DIRECT foopy:10", // direct cannot have host/port.
296 }; 296 };
297 297
298 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) { 298 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) {
299 net::ProxyServer uri = net::ProxyServer::FromPacString(tests[i]); 299 net::ProxyServer uri = net::ProxyServer::FromPacString(tests[i]);
300 EXPECT_FALSE(uri.is_valid()); 300 EXPECT_FALSE(uri.is_valid());
301 } 301 }
302 } 302 }
303
304 TEST(ProxyServerTest, ComparatorAndEquality) {
305 struct {
306 // Inputs.
307 const char* server1;
308 const char* server2;
309
310 // Expectation.
311 // -1 means server1 is less than server2
312 // 0 means server1 equals server2
313 // 1 means server1 is greater than server2
314 int expected_comparison;
315 } tests[] = {
316 { // Equal.
317 "foo:11",
318 "http://foo:11",
319 0
320 },
321 { // Port is different.
322 "foo:333",
323 "foo:444",
324 -1
325 },
326 { // Host is different.
327 "foo:33",
328 "bar:33",
329 1
330 },
331 { // Scheme is different.
332 "socks4://foo:33",
333 "http://foo:33",
334 1
335 },
336 };
337
338 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) {
339 // Parse the expected inputs to ProxyServer instances.
340 const net::ProxyServer server1 =
341 net::ProxyServer::FromURI(
342 tests[i].server1, net::ProxyServer::SCHEME_HTTP);
343
344 const net::ProxyServer server2 =
345 net::ProxyServer::FromURI(
346 tests[i].server2, net::ProxyServer::SCHEME_HTTP);
347
348 switch (tests[i].expected_comparison) {
349 case -1:
350 EXPECT_TRUE(server1 < server2);
351 EXPECT_FALSE(server2 < server1);
352 EXPECT_FALSE(server2 == server1);
353 break;
354 case 0:
355 EXPECT_FALSE(server1 < server2);
356 EXPECT_FALSE(server2 < server1);
357 EXPECT_TRUE(server2 == server1);
358 break;
359 case 1:
360 EXPECT_FALSE(server1 < server2);
361 EXPECT_TRUE(server2 < server1);
362 EXPECT_FALSE(server2 == server1);
363 break;
364 default:
365 FAIL() << "Invalid expectation. Can be only -1, 0, 1";
366 }
367 }
368 }
OLDNEW
« no previous file with comments | « net/proxy/proxy_server.cc ('k') | net/spdy/spdy_http_stream_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698