|
| 1 | +// Copyright (c) Glyn Matthews 2011. |
| 2 | +// Distributed under the Boost Software License, Version 1.0. |
| 3 | +// (See accompanying file LICENSE_1_0.txt or copy at |
| 4 | +// http://www.boost.org/LICENSE_1_0.txt) |
| 5 | + |
| 6 | +#define BOOST_TEST_MODULE URI builder test |
| 7 | +#include <boost/config/warning_disable.hpp> |
| 8 | +#include <boost/test/unit_test.hpp> |
| 9 | +#include <boost/network/uri/uri.hpp> |
| 10 | +#include <boost/network/uri/builder.hpp> |
| 11 | +#include <boost/network/tags.hpp> |
| 12 | +#include <boost/mpl/list.hpp> |
| 13 | +#include <boost/range/algorithm/equal.hpp> |
| 14 | +#include <boost/range/algorithm/copy.hpp> |
| 15 | + |
| 16 | + |
| 17 | +using namespace boost::network; |
| 18 | + |
| 19 | +typedef boost::mpl::list< |
| 20 | + tags::default_string |
| 21 | +// , tags::default_wstring |
| 22 | + > tag_types; |
| 23 | + |
| 24 | + |
| 25 | +BOOST_AUTO_TEST_CASE_TEMPLATE(builder_test, T, tag_types) |
| 26 | +{ |
| 27 | + typedef uri::basic_uri<T> uri_type; |
| 28 | + typedef typename uri_type::string_type string_type; |
| 29 | + |
| 30 | + const std::string scheme("http"); |
| 31 | + const std::string host("www.example.com"); |
| 32 | + const std::string path("/"); |
| 33 | + |
| 34 | + uri_type instance; |
| 35 | + uri::basic_builder<T> builder(instance); |
| 36 | + builder << uri::builder::scheme(string_type(boost::begin(scheme), |
| 37 | + boost::end(scheme))) |
| 38 | + << uri::builder::host(string_type(boost::begin(host), |
| 39 | + boost::end(host))) |
| 40 | + << uri::builder::path(string_type(boost::begin(path), |
| 41 | + boost::end(path))) |
| 42 | + ; |
| 43 | + BOOST_REQUIRE(uri::is_valid(instance)); |
| 44 | + BOOST_CHECK(boost::equal(uri::scheme(instance), scheme)); |
| 45 | + BOOST_CHECK(boost::equal(uri::host(instance), host)); |
| 46 | + BOOST_CHECK(boost::equal(uri::path(instance), path)); |
| 47 | +} |
0 commit comments