Skip to content

Commit 16f8e23

Browse files
committed
increase fields_base test coverage
1 parent de6b110 commit 16f8e23

File tree

1 file changed

+60
-0
lines changed

1 file changed

+60
-0
lines changed

test/unit/fields_base.cpp

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include "test_helpers.hpp"
2121
#include "test_suite.hpp"
2222

23+
#include <stdexcept>
2324
#include <vector>
2425

2526
namespace boost {
@@ -127,6 +128,22 @@ struct fields_base_test
127128
res.capacity_in_bytes(), 0);
128129
}
129130

131+
{
132+
fields f("\r\n");
133+
auto const n =
134+
f.capacity_in_bytes();
135+
BOOST_TEST_GT(n, 0);
136+
BOOST_TEST_EQ(
137+
f.buffer(),
138+
"\r\n");
139+
}
140+
141+
{
142+
BOOST_TEST_THROWS(
143+
fields("HTTP/1.1"),
144+
std::invalid_argument);
145+
}
146+
130147
{
131148
fields f(
132149
"digest: ffce\r\n"
@@ -143,6 +160,28 @@ struct fields_base_test
143160
f.capacity_in_bytes(), n);
144161
}
145162

163+
{
164+
request req(
165+
"POST / HTTP/1.1\r\n"
166+
"\r\n");
167+
auto const n =
168+
req.capacity_in_bytes();
169+
BOOST_TEST_EQ(
170+
req.buffer(),
171+
"POST / HTTP/1.1\r\n\r\n");
172+
BOOST_TEST_EQ(
173+
req.capacity_in_bytes(), n);
174+
}
175+
176+
{
177+
BOOST_TEST_THROWS(
178+
request(
179+
"POST / HTTP/1.1"
180+
"\r\n"),
181+
std::invalid_argument
182+
);
183+
}
184+
146185
{
147186
request req(
148187
"POST / HTTP/1.1\r\n"
@@ -161,6 +200,27 @@ struct fields_base_test
161200
req.capacity_in_bytes(), n);
162201
}
163202

203+
{
204+
response res(
205+
"HTTP/1.1 404 Not Found\r\n"
206+
"\r\n");
207+
auto const n =
208+
res.capacity_in_bytes();
209+
BOOST_TEST_EQ(
210+
res.buffer(),
211+
"HTTP/1.1 404 Not Found\r\n\r\n");
212+
BOOST_TEST_EQ(
213+
res.capacity_in_bytes(), n);
214+
}
215+
216+
{
217+
BOOST_TEST_THROWS(
218+
response(
219+
"HTTP/1.1 404 Not Found"
220+
"\r\n"),
221+
std::invalid_argument);
222+
}
223+
164224
{
165225
response res(
166226
"HTTP/1.1 404 Not Found\r\n"

0 commit comments

Comments
 (0)