Skip to content

Commit 0b2b483

Browse files
committed
Converting test to use unified message directives and wrapper protocol for HTTP messages.
1 parent 3c22daa commit 0b2b483

File tree

1 file changed

+41
-16
lines changed

1 file changed

+41
-16
lines changed

libs/network/test/http_message_test.cpp

Lines changed: 41 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,20 @@
77
#define BOOST_TEST_MODULE HTTP message test
88
#include <boost/config/warning_disable.hpp>
99
#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>
1113
// #include <boost/network/protocol/http/traits.hpp>
1214
#include <algorithm>
1315

1416
using namespace boost::network;
1517

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;
1724

1825
struct fixtures {
1926
};
@@ -70,29 +77,47 @@ BOOST_AUTO_TEST_CASE_TEMPLATE (response_constructor_test, T, tag_types) {
7077
}
7178

7279
BOOST_AUTO_TEST_CASE_TEMPLATE (response_copy_construct_test, T, tag_types) {
80+
using namespace http;
7381
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+
;
7887
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 );
82100
BOOST_CHECK_EQUAL ( body(response), body(copy) );
83101
}
84102

85103
BOOST_AUTO_TEST_CASE_TEMPLATE (response_assignment_construct_test, T, tag_types) {
86104
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");
91109
http::basic_response<T> copy;
92110
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 );
96121
BOOST_CHECK_EQUAL ( body(response), body(copy) );
97122
}
98123

0 commit comments

Comments
 (0)