diff options
author | ericroman@google.com <ericroman@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-02-19 08:11:42 +0000 |
---|---|---|
committer | ericroman@google.com <ericroman@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-02-19 08:11:42 +0000 |
commit | f6fb2de77993bbd88931ba205b0cc1e3423111f6 (patch) | |
tree | 831dbc093048f60b7d3cfa6548d42cedc340b4d7 /net/base/net_util_unittest.cc | |
parent | 77c846f5d8043e56543668971fff356d58380cf7 (diff) | |
download | chromium_src-f6fb2de77993bbd88931ba205b0cc1e3423111f6.zip chromium_src-f6fb2de77993bbd88931ba205b0cc1e3423111f6.tar.gz chromium_src-f6fb2de77993bbd88931ba205b0cc1e3423111f6.tar.bz2 |
Add parsing for PAC result strings -- ProxyInfo::UsePacString().
Added the support class ProxyServer to avoid losing the proxy server's type information (http, socks) when populating the list.
The format of the configuration strings has been extended accordingly to include an optional [<scheme>"://"] prefix.
(i.e. "http://", "socks4://", "socks5://").
Review URL: http://codereview.chromium.org/20398
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@10010 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/base/net_util_unittest.cc')
-rw-r--r-- | net/base/net_util_unittest.cc | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/net/base/net_util_unittest.cc b/net/base/net_util_unittest.cc index 68ec2b3..d3f7b83 100644 --- a/net/base/net_util_unittest.cc +++ b/net/base/net_util_unittest.cc @@ -735,4 +735,45 @@ TEST(NetUtilTest, GetDirectoryListingEntry) { EXPECT_EQ(test_cases[i].expected, results); } } + +TEST(NetUtilTest, GetHostAndPort) { + const struct { + const char* input; + bool success; + const char* expected_host; + int expected_port; + } tests[] = { + // Valid inputs: + {"foo:10", true, "foo", 10}, + {"foo", true, "foo", -1}, + { + // TODO(eroman): support IPv6 literals. + "[1080:0:0:0:8:800:200C:4171]:11", + false, + "", + -1, + }, + // Invalid inputs: + {"foo:bar", false, "", -1}, + {"foo:", false, "", -1}, + {":", false, "", -1}, + {":80", false, "", -1}, + {"", false, "", -1}, + {"porttoolong:300000", false, "", -1}, + }; + + for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) { + std::string host; + int port; + bool ok = net::GetHostAndPort(tests[i].input, &host, &port); + + EXPECT_EQ(tests[i].success, ok); + + if (tests[i].success) { + EXPECT_EQ(tests[i].expected_host, host); + EXPECT_EQ(tests[i].expected_port, port); + } + } +} + #endif |