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

Unified 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, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/proxy/proxy_server.cc ('k') | net/spdy/spdy_http_stream_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/proxy/proxy_server_unittest.cc
===================================================================
--- net/proxy/proxy_server_unittest.cc (revision 57276)
+++ net/proxy/proxy_server_unittest.cc (working copy)
@@ -300,3 +300,69 @@
EXPECT_FALSE(uri.is_valid());
}
}
+
+TEST(ProxyServerTest, ComparatorAndEquality) {
+ struct {
+ // Inputs.
+ const char* server1;
+ const char* server2;
+
+ // Expectation.
+ // -1 means server1 is less than server2
+ // 0 means server1 equals server2
+ // 1 means server1 is greater than server2
+ int expected_comparison;
+ } tests[] = {
+ { // Equal.
+ "foo:11",
+ "http://foo:11",
+ 0
+ },
+ { // Port is different.
+ "foo:333",
+ "foo:444",
+ -1
+ },
+ { // Host is different.
+ "foo:33",
+ "bar:33",
+ 1
+ },
+ { // Scheme is different.
+ "socks4://foo:33",
+ "http://foo:33",
+ 1
+ },
+ };
+
+ for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) {
+ // Parse the expected inputs to ProxyServer instances.
+ const net::ProxyServer server1 =
+ net::ProxyServer::FromURI(
+ tests[i].server1, net::ProxyServer::SCHEME_HTTP);
+
+ const net::ProxyServer server2 =
+ net::ProxyServer::FromURI(
+ tests[i].server2, net::ProxyServer::SCHEME_HTTP);
+
+ switch (tests[i].expected_comparison) {
+ case -1:
+ EXPECT_TRUE(server1 < server2);
+ EXPECT_FALSE(server2 < server1);
+ EXPECT_FALSE(server2 == server1);
+ break;
+ case 0:
+ EXPECT_FALSE(server1 < server2);
+ EXPECT_FALSE(server2 < server1);
+ EXPECT_TRUE(server2 == server1);
+ break;
+ case 1:
+ EXPECT_FALSE(server1 < server2);
+ EXPECT_TRUE(server2 < server1);
+ EXPECT_FALSE(server2 == server1);
+ break;
+ default:
+ FAIL() << "Invalid expectation. Can be only -1, 0, 1";
+ }
+ }
+}
« 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