From 719d90a40e83e870be19f8d46cc55caed618aa35 Mon Sep 17 00:00:00 2001 From: Joel Klinghed Date: Wed, 1 Mar 2017 22:54:09 +0100 Subject: Add support for CONNECT --- test/test-url.cc | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) (limited to 'test') diff --git a/test/test-url.cc b/test/test-url.cc index 79e6564..41c41e8 100644 --- a/test/test-url.cc +++ b/test/test-url.cc @@ -170,6 +170,39 @@ bool relative(std::string const& url, std::string const& base, return true; } +bool good_authority(std::string const& str, + std::string const& host, + uint16_t port) { + std::string h; + uint16_t p; + if (!Url::parse_authority(str, &h, &p)) { + std::cerr << "good_authority:" << str << ": Invalid authority" << std::endl; + return false; + } + if (host != h) { + std::cerr << "good_authority:" << str << ":host: Expected " << host + << " got " << h << std::endl; + return false; + } + if (port != p) { + std::cerr << "good_authority:" << str << ":port: Expected " << port + << " got " << p << std::endl; + return false; + } + return true; +} + +bool bad_authority(std::string const& str) { + std::string h; + uint16_t p; + if (Url::parse_authority(str, &h, &p)) { + std::cerr << "bad_authority:" << str << ": Expected invalid autority got " + << h << ':' << p << std::endl; + return false; + } + return true; +} + } // namespace int main() { @@ -208,5 +241,13 @@ int main() { RUN(relative("foo#c", "http://host/#b", "http://host/foo#c")); RUN(relative("foo#c", "http://host/?b", "http://host/foo#c")); RUN(relative("foo", "http://host/?b", "http://host/foo")); + RUN(good_authority("www.example.org", "www.example.org", 0)); + RUN(good_authority("www.example.org:80", "www.example.org", 80)); + RUN(good_authority("localhost:5678", "localhost", 5678)); + RUN(good_authority("[::1]:5678", "::1", 5678)); + RUN(good_authority("::1:5678", "::1", 5678)); + RUN(bad_authority("foo@localhost")); + RUN(bad_authority("")); + RUN(bad_authority(":500")); AFTER; } -- cgit v1.2.3-70-g09d2