Skip to content

Commit 4ab9e48

Browse files
committed
add testcase for boost::network::uri::decode
1 parent 0a5e2fb commit 4ab9e48

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

boost/network/uri/decode.hpp

+2-8
Original file line numberDiff line numberDiff line change
@@ -59,15 +59,9 @@ OutputIterator decode(const InputIterator &in_begin,
5959
OutputIterator out = out_begin;
6060
while (it != in_end) {
6161
if (*it == '%') {
62-
++it;
63-
if (it == in_end) {
64-
throw std::runtime_error("decoding fail because of '%'");
65-
}
62+
if (++it == in_end) throw std::runtime_error("decoding fail because of '%'");
6663
value_type v0 = detail::letter_to_hex(*it);
67-
++it;
68-
if (it == in_end) {
69-
throw std::runtime_error("decoding fail because of '%'");
70-
}
64+
if (++it == in_end) throw std::runtime_error("decoding fail because of '%'");
7165
value_type v1 = detail::letter_to_hex(*it);
7266
++it;
7367
*out++ = 0x10 * v0 + v1;

libs/network/test/uri/uri_encoding_test.cpp

+7
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,10 @@ BOOST_AUTO_TEST_CASE(decoding_multibyte_test) {
4747
uri::decode(encoded, std::back_inserter(instance));
4848
BOOST_CHECK_EQUAL(instance, unencoded);
4949
}
50+
51+
BOOST_AUTO_TEST_CASE(decoding_throw_test) {
52+
const std::string encoded("%");
53+
54+
std::string instance;
55+
BOOST_CHECK_THROW(uri::decoded(encoded), std::runtime_error);
56+
}

0 commit comments

Comments
 (0)