Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commita411abd

Browse files
committed
Updated some of the URI tests. Added begin/end accessors to make the URI a valid forward range.
1 parent2c2cf86 commita411abd

File tree

7 files changed

+161
-106
lines changed

7 files changed

+161
-106
lines changed

‎boost/network/uri/uri.hpp‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212
#include<boost/network/tags.hpp>
1313
#include<boost/network/constants.hpp>
1414
#include<boost/network/uri/detail/uri_parts.hpp>
15+
#ifdef BOOST_NETWORK_NO_LIB
16+
#include<boost/network/uri/detail/parse_uri.hpp>
17+
#endif// #ifdef BOOST_NETWORK_NO_LIB
1518
#include<boost/algorithm/string.hpp>
1619
#include<boost/range/iterator_range.hpp>
1720
#include<boost/operators.hpp>
@@ -85,6 +88,22 @@ class basic_uri
8588
boost::swap(is_valid_, other.is_valid_);
8689
}
8790

91+
iterator_typebegin() {
92+
return uri_.begin();
93+
}
94+
95+
const_iterator_typebegin()const {
96+
return uri_.begin();
97+
}
98+
99+
iterator_typeend() {
100+
return uri_.end();
101+
}
102+
103+
const_iterator_typeend()const {
104+
return uri_.end();
105+
}
106+
88107
const_range_typescheme_range()const {
89108
using boost::fusion::at_c;
90109
returnconst_range_type(at_c<0>(at_c<0>(uri_parts_)),

‎libs/network/test/CMakeLists.txt‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@ find_package( Threads )
1010
set(Boost_USE_STATIC_LIBSON)
1111
set(Boost_USE_MULTITHREADEDON)
1212

13+
add_subdirectory(uri)
1314
add_subdirectory(http)
1415

1516
if (Boost_FOUND)
1617
set(
1718
TESTS
1819
message_test
1920
message_transform_test
20-
url_test
2121
utils_thread_pool
2222
)
2323
foreach (test${TESTS})

‎libs/network/test/http/url_test.cpp‎

Lines changed: 0 additions & 89 deletions
This file was deleted.

‎libs/network/test/mailto_url_test.cpp‎

Lines changed: 0 additions & 13 deletions
This file was deleted.
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Copyright (c) Dean Michael Berris 2010.
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+
include_directories(${CPP-NETLIB_SOURCE_DIR})
7+
find_package( Boost 1.41.0 COMPONENTS unit_test_frameworksystemregex date_time filesystem )
8+
find_package( OpenSSL )
9+
find_package( Threads )
10+
set(Boost_USE_STATIC_LIBSON)
11+
set(Boost_USE_MULTITHREADEDON)
12+
13+
14+
if (Boost_FOUND)
15+
set(
16+
TESTS
17+
url_test
18+
url_http_test
19+
)
20+
foreach (test${TESTS})
21+
set_source_files_properties(${test}.cpp
22+
PROPERTIESCOMPILE_FLAGS"-Wall")
23+
add_executable(cpp-netlib-${test}${test}.cpp)
24+
add_dependencies(cpp-netlib-${test} cppnetlib-uri-parsers)
25+
target_link_libraries(cpp-netlib-${test}${Boost_LIBRARIES}${CMAKE_THREAD_LIBS_INIT} cppnetlib-uri-parsers)
26+
if (OPENSSL_FOUND)
27+
target_link_libraries(cpp-netlib-${test}${OPENSSL_LIBRARIES})
28+
endif()
29+
set_target_properties(cpp-netlib-${test}
30+
PROPERTIESRUNTIME_OUTPUT_DIRECTORY ${CPP-NETLIB_BINARY_DIR}/tests)
31+
add_test(cpp-netlib-${test} ${CPP-NETLIB_BINARY_DIR}/tests/cpp-netlib-${test})
32+
endforeach (test)
33+
34+
endif()
Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
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+
7+
8+
#defineBOOST_TEST_MODULE HTTP URL Test
9+
#include<boost/config/warning_disable.hpp>
10+
#include<boost/test/unit_test.hpp>
11+
#include<boost/network/uri/http/uri.hpp>
12+
#include<boost/mpl/list.hpp>
13+
#include<boost/range/algorithm/equal.hpp>
14+
15+
usingnamespaceboost::network;
16+
17+
typedef boost::mpl::list<
18+
tags::default_string
19+
, tags::default_wstring
20+
> tag_types;
21+
22+
23+
BOOST_AUTO_TEST_CASE_TEMPLATE(not_http, T, tag_types)
24+
{
25+
typedef uri::http::basic_uri<T> uri_type;
26+
typedeftypename uri_type::string_type string_type;
27+
const std::stringurl("mailto:john.doe@example.com");
28+
uri_typeinstance(string_type(boost::begin(url),boost::end(url)));
29+
std::copy(instance.begin(), instance.end(),
30+
std::ostream_iterator<char>(std::cout));
31+
std::cout << std::endl;
32+
//BOOST_CHECK(!uri::is_valid(instance));
33+
}
34+
35+
// BOOST_AUTO_TEST_CASE(http_url_test) {
36+
// typedef uri::basic_uri<http::tags::http_default_8bit_tcp_resolve> uri_type;
37+
// typedef uri_type::string_type string_type;
38+
//
39+
// const std::string url("http://www.boost.org/");
40+
// const std::string scheme("http");
41+
// const std::string host("www.boost.org");
42+
// const std::string path("/");
43+
//
44+
// uri_type instance(string_type(boost::begin(url), boost::end(url)));
45+
// boost::optional<string_type> host_ = uri::host(instance);
46+
// boost::optional<boost::uint16_t> port_ = uri::port(instance);
47+
//
48+
// BOOST_REQUIRE(uri::is_valid(instance));
49+
// BOOST_CHECK_EQUAL(instance.raw(), url);
50+
// BOOST_CHECK( !port_ );
51+
// string_type scheme_ = uri::scheme(instance);
52+
// BOOST_CHECK_EQUAL(scheme_, scheme);
53+
// BOOST_CHECK(boost::equal(uri::scheme(instance), scheme));
54+
// BOOST_CHECK(boost::equal(uri::host(instance), host));
55+
// BOOST_CHECK(boost::equal(uri::path(instance), path));
56+
// }
57+
//
58+
// BOOST_AUTO_TEST_CASE(full_http_url_test) {
59+
// typedef uri::basic_uri<http::tags::http_default_8bit_tcp_resolve> uri_type;
60+
// typedef uri_type::string_type string_type;
61+
//
62+
// const std::string url("http://user:password@www.boost.org:8000/path?query#fragment");
63+
// const std::string scheme("http");
64+
// const std::string user_info("user:password");
65+
// const std::string host("www.boost.org");
66+
// const boost::uint16_t port = 8000;
67+
// const std::string path("/path");
68+
// const std::string query("query");
69+
// const std::string fragment("fragment");
70+
//
71+
// uri_type instance(string_type(boost::begin(url), boost::end(url)));
72+
// BOOST_REQUIRE(uri::is_valid(instance));
73+
// BOOST_CHECK(boost::equal(uri::scheme(instance), scheme));
74+
// BOOST_CHECK(boost::equal(uri::user_info(instance), user_info));
75+
// BOOST_CHECK(boost::equal(uri::host(instance), host));
76+
// BOOST_CHECK_EQUAL(uri::port(instance), port);
77+
// BOOST_CHECK(boost::equal(uri::path(instance), path));
78+
// BOOST_CHECK(boost::equal(uri::query(instance), query));
79+
// BOOST_CHECK(boost::equal(uri::fragment(instance), fragment));
80+
// }
81+
//
82+
// BOOST_AUTO_TEST_CASE(https_url_test) {
83+
// typedef uri::basic_uri<http::tags::http_default_8bit_tcp_resolve> uri_type;
84+
// typedef uri_type::string_type string_type;
85+
//
86+
// const std::string url("https://www.boost.org/");
87+
// const std::string scheme("https");
88+
// const std::string host("www.boost.org");
89+
// const boost::uint16_t port = 443;
90+
// const std::string path("/");
91+
//
92+
// uri_type instance(string_type(boost::begin(url), boost::end(url)));
93+
// BOOST_REQUIRE(uri::is_valid(instance));
94+
// BOOST_CHECK(boost::equal(uri::scheme(instance), scheme));
95+
// BOOST_CHECK(boost::equal(uri::host(instance), host));
96+
// BOOST_CHECK_EQUAL(uri::port(instance), port);
97+
// BOOST_CHECK(boost::equal(uri::path(instance), path));
98+
// }
99+
//
100+
//BOOST_AUTO_TEST_CASE(invalid_http_url_test) {
101+
// typedef uri::basic_uri<http::tags::http_default_8bit_tcp_resolve> uri_type;
102+
// typedef uri_type::string_type string_type;
103+
// const std::string url("ftp://www.boost.org/");
104+
// uri_type instance(string_type(boost::begin(url), boost::end(url)));
105+
// BOOST_CHECK(!uri::is_valid(instance));
106+
//}

‎libs/network/test/url_test.cpp‎renamed to ‎libs/network/test/uri/url_test.cpp‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
2-
// Copyright 2009 Dean Michael Berris, Jeroen Habraken.
3-
// Copyright 2010 Glyn Matthews.
1+
// Copyright 2009, 2010, 2011 Dean Michael Berris, Jeroen Habraken, Glyn Matthews.
42
// Distributed under the Boost Software License, Version 1.0.
53
// (See accompanying file LICENSE_1_0.txt of copy at
64
// http://www.boost.org/LICENSE_1_0.txt)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp