44// http://www.boost.org/LICENSE_1_0.txt)
55
66
7-
87#define BOOST_TEST_MODULE HTTP URL Test
98#include < boost/config/warning_disable.hpp>
109#include < boost/test/unit_test.hpp>
@@ -20,84 +19,43 @@ typedef boost::mpl::list<
2019 > tag_types;
2120
2221
22+ BOOST_AUTO_TEST_CASE_TEMPLATE (valid_http, T, tag_types)
23+ {
24+ typedef uri::http::basic_uri<T> uri_type;
25+ typedef typename uri_type::string_type string_type;
26+ const std::stringurl (" http://example.com/" );
27+ uri_typeinstance (string_type (boost::begin (url),boost::end (url)));
28+ BOOST_REQUIRE (uri::is_http (instance));
29+ BOOST_REQUIRE (uri::is_valid (instance));
30+ }
31+
32+ BOOST_AUTO_TEST_CASE_TEMPLATE (valid_https, T, tag_types)
33+ {
34+ typedef uri::http::basic_uri<T> uri_type;
35+ typedef typename uri_type::string_type string_type;
36+ const std::stringurl (" https://example.com/" );
37+ uri_typeinstance (string_type (boost::begin (url),boost::end (url)));
38+ BOOST_REQUIRE (uri::is_https (instance));
39+ BOOST_REQUIRE (uri::is_valid (instance));
40+ }
41+
42+ BOOST_AUTO_TEST_CASE_TEMPLATE (invalid_https, T, tag_types)
43+ {
44+ typedef uri::http::basic_uri<T> uri_type;
45+ typedef typename uri_type::string_type string_type;
46+ const std::stringurl (" http://example.com/" );
47+ uri_typeinstance (string_type (boost::begin (url),boost::end (url)));
48+ BOOST_REQUIRE (!uri::is_https (instance));
49+ BOOST_REQUIRE (uri::is_valid (instance));
50+ }
51+
2352BOOST_AUTO_TEST_CASE_TEMPLATE (not_http, T, tag_types)
2453{
2554typedef uri::http::basic_uri<T> uri_type;
2655typedef typename uri_type::string_type string_type;
2756const std::stringurl (" mailto:john.doe@example.com" );
2857 uri_typeinstance (string_type (boost::begin (url),boost::end (url)));
29- // BOOST_CHECK(!uri::is_valid(instance));
58+ BOOST_REQUIRE (!uri::is_http (instance));
59+ BOOST_REQUIRE (!uri::is_https (instance));
60+ BOOST_REQUIRE (!uri::is_valid (instance));
3061}
31-
32- // BOOST_AUTO_TEST_CASE(http_url_test) {
33- // typedef uri::basic_uri<http::tags::http_default_8bit_tcp_resolve> uri_type;
34- // typedef uri_type::string_type string_type;
35- //
36- // const std::string url("http://www.boost.org/");
37- // const std::string scheme("http");
38- // const std::string host("www.boost.org");
39- // const std::string path("/");
40- //
41- // uri_type instance(string_type(boost::begin(url), boost::end(url)));
42- // boost::optional<string_type> host_ = uri::host(instance);
43- // boost::optional<boost::uint16_t> port_ = uri::port(instance);
44- //
45- // BOOST_REQUIRE(uri::is_valid(instance));
46- // BOOST_CHECK_EQUAL(instance.raw(), url);
47- // BOOST_CHECK( !port_ );
48- // string_type scheme_ = uri::scheme(instance);
49- // BOOST_CHECK_EQUAL(scheme_, scheme);
50- // BOOST_CHECK(boost::equal(uri::scheme(instance), scheme));
51- // BOOST_CHECK(boost::equal(uri::host(instance), host));
52- // BOOST_CHECK(boost::equal(uri::path(instance), path));
53- // }
54- //
55- // BOOST_AUTO_TEST_CASE(full_http_url_test) {
56- // typedef uri::basic_uri<http::tags::http_default_8bit_tcp_resolve> uri_type;
57- // typedef uri_type::string_type string_type;
58- //
59- // const std::string url("http://user:password@www.boost.org:8000/path?query#fragment");
60- // const std::string scheme("http");
61- // const std::string user_info("user:password");
62- // const std::string host("www.boost.org");
63- // const boost::uint16_t port = 8000;
64- // const std::string path("/path");
65- // const std::string query("query");
66- // const std::string fragment("fragment");
67- //
68- // uri_type instance(string_type(boost::begin(url), boost::end(url)));
69- // BOOST_REQUIRE(uri::is_valid(instance));
70- // BOOST_CHECK(boost::equal(uri::scheme(instance), scheme));
71- // BOOST_CHECK(boost::equal(uri::user_info(instance), user_info));
72- // BOOST_CHECK(boost::equal(uri::host(instance), host));
73- // BOOST_CHECK_EQUAL(uri::port(instance), port);
74- // BOOST_CHECK(boost::equal(uri::path(instance), path));
75- // BOOST_CHECK(boost::equal(uri::query(instance), query));
76- // BOOST_CHECK(boost::equal(uri::fragment(instance), fragment));
77- // }
78- //
79- // BOOST_AUTO_TEST_CASE(https_url_test) {
80- // typedef uri::basic_uri<http::tags::http_default_8bit_tcp_resolve> uri_type;
81- // typedef uri_type::string_type string_type;
82- //
83- // const std::string url("https://www.boost.org/");
84- // const std::string scheme("https");
85- // const std::string host("www.boost.org");
86- // const boost::uint16_t port = 443;
87- // const std::string path("/");
88- //
89- // uri_type instance(string_type(boost::begin(url), boost::end(url)));
90- // BOOST_REQUIRE(uri::is_valid(instance));
91- // BOOST_CHECK(boost::equal(uri::scheme(instance), scheme));
92- // BOOST_CHECK(boost::equal(uri::host(instance), host));
93- // BOOST_CHECK_EQUAL(uri::port(instance), port);
94- // BOOST_CHECK(boost::equal(uri::path(instance), path));
95- // }
96- //
97- // BOOST_AUTO_TEST_CASE(invalid_http_url_test) {
98- // typedef uri::basic_uri<http::tags::http_default_8bit_tcp_resolve> uri_type;
99- // typedef uri_type::string_type string_type;
100- // const std::string url("ftp://www.boost.org/");
101- // uri_type instance(string_type(boost::begin(url), boost::end(url)));
102- // BOOST_CHECK(!uri::is_valid(instance));
103- // }