|
7 | 7 | #define BOOST_TEST_MODULE HTTP message test
|
8 | 8 | #include <boost/config/warning_disable.hpp>
|
9 | 9 | #include <boost/test/unit_test.hpp>
|
10 |
| -#include <boost/network/protocol/http.hpp> |
| 10 | +#include <boost/network/protocol/http/request.hpp> |
| 11 | +#include <boost/network/protocol/http/response.hpp> |
| 12 | +#include <boost/mpl/list.hpp> |
11 | 13 | // #include <boost/network/protocol/http/traits.hpp>
|
12 | 14 | #include <algorithm>
|
13 | 15 |
|
14 | 16 | using namespace boost::network;
|
15 | 17 |
|
16 |
| -typedef boost::mpl::list<tags::http_default_8bit_tcp_resolve, tags::http_default_8bit_udp_resolve, tags::http_keepalive_8bit_tcp_resolve, tags::http_keepalive_8bit_udp_resolve> tag_types; |
| 18 | +typedef boost::mpl::list< |
| 19 | + tags::http_default_8bit_tcp_resolve |
| 20 | + , tags::http_default_8bit_udp_resolve |
| 21 | + , tags::http_keepalive_8bit_tcp_resolve |
| 22 | + , tags::http_keepalive_8bit_udp_resolve |
| 23 | +> tag_types; |
17 | 24 |
|
18 | 25 | struct fixtures {
|
19 | 26 | };
|
@@ -70,29 +77,47 @@ BOOST_AUTO_TEST_CASE_TEMPLATE (response_constructor_test, T, tag_types) {
|
70 | 77 | }
|
71 | 78 |
|
72 | 79 | BOOST_AUTO_TEST_CASE_TEMPLATE (response_copy_construct_test, T, tag_types) {
|
| 80 | + using namespace http; |
73 | 81 | http::basic_response<T> response;
|
74 |
| - response.version() = "HTTP/1.1"; |
75 |
| - response.status() = 200; |
76 |
| - response.status_message() = "OK"; |
77 |
| - response << body("The quick brown fox jumps over the lazy dog"); |
| 82 | + response << http::version("HTTP/1.1") |
| 83 | + << http::status(200u) |
| 84 | + << body("The quick brown fox jumps over the lazy dog") |
| 85 | + << http::status_message("OK") |
| 86 | + ; |
78 | 87 | http::basic_response<T> copy(response);
|
79 |
| - BOOST_CHECK_EQUAL ( response.version(), copy.version() ); |
80 |
| - BOOST_CHECK_EQUAL ( response.status(), copy.status() ); |
81 |
| - BOOST_CHECK_EQUAL ( response.status_message(), copy.status_message() ); |
| 88 | + |
| 89 | + typename http::basic_response<T>::string_type |
| 90 | + version_orig = version(response) |
| 91 | + , version_copy = version(copy); |
| 92 | + BOOST_CHECK_EQUAL ( version_orig, version_copy ); |
| 93 | + boost::uint16_t status_orig = status(response) |
| 94 | + , status_copy = status(copy); |
| 95 | + BOOST_CHECK_EQUAL ( status_orig, status_copy ); |
| 96 | + typename http::basic_response<T>::string_type |
| 97 | + status_message_orig = status_message(response) |
| 98 | + , status_message_copy = status_message(copy); |
| 99 | + BOOST_CHECK_EQUAL ( status_message_orig, status_message_copy ); |
82 | 100 | BOOST_CHECK_EQUAL ( body(response), body(copy) );
|
83 | 101 | }
|
84 | 102 |
|
85 | 103 | BOOST_AUTO_TEST_CASE_TEMPLATE (response_assignment_construct_test, T, tag_types) {
|
86 | 104 | http::basic_response<T> response;
|
87 |
| - response.version() = "HTTP/1.1"; |
88 |
| - response.status() = 200; |
89 |
| - response.status_message() = "OK"; |
90 |
| - response << body("The quick brown fox jumps over the lazy dog"); |
| 105 | + response << http::version("HTTP/1.1") |
| 106 | + << http::status(200) |
| 107 | + << http::status_message("OK") |
| 108 | + << body("The quick brown fox jumps over the lazy dog"); |
91 | 109 | http::basic_response<T> copy;
|
92 | 110 | copy = response;
|
93 |
| - BOOST_CHECK_EQUAL ( response.version(), copy.version() ); |
94 |
| - BOOST_CHECK_EQUAL ( response.status(), copy.status() ); |
95 |
| - BOOST_CHECK_EQUAL ( response.status_message(), copy.status_message() ); |
| 111 | + typedef http::basic_response<T>::string_type string_type; |
| 112 | + string_type version_orig = version(response) |
| 113 | + , version_copy = version(copy); |
| 114 | + BOOST_CHECK_EQUAL ( version_orig, version_copy ); |
| 115 | + boost::uint16_t status_orig = status(response) |
| 116 | + , status_copy = status(copy); |
| 117 | + BOOST_CHECK_EQUAL ( status_orig, status_copy ); |
| 118 | + string_type status_message_orig = status_message(response) |
| 119 | + , status_message_copy = status_message(copy); |
| 120 | + BOOST_CHECK_EQUAL ( status_message_orig, status_message_copy ); |
96 | 121 | BOOST_CHECK_EQUAL ( body(response), body(copy) );
|
97 | 122 | }
|
98 | 123 |
|
|
0 commit comments