GCC Code Coverage Report


Directory: ./
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 76.3% 370 / 0 / 485
Functions: 85.0% 17 / 0 / 20
Branches: 59.3% 198 / 0 / 334

libs/url/include/boost/url/impl/encode.hpp
Line Branch Exec Source
1 //
2 // Copyright (c) 2019 Vinnie Falco (vinnie.falco@gmail.com)
3 //
4 // Distributed under the Boost Software License, Version 1.0. (See accompanying
5 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6 //
7 // Official repository: https://github.com/boostorg/url
8 //
9
10 #ifndef BOOST_URL_IMPL_ENCODE_HPP
11 #define BOOST_URL_IMPL_ENCODE_HPP
12
13 #include "boost/url/grammar/token_rule.hpp"
14 #include <boost/assert.hpp>
15 #include <boost/core/detail/static_assert.hpp>
16 #include <boost/url/detail/encode.hpp>
17 #include <boost/url/detail/except.hpp>
18 #include <boost/url/encoding_opts.hpp>
19 #include <boost/url/grammar/charset.hpp>
20 #include <boost/url/grammar/hexdig_chars.hpp>
21 #include <boost/url/grammar/string_token.hpp>
22 #include <boost/url/grammar/type_traits.hpp>
23
24 namespace boost {
25 namespace urls {
26
27 //------------------------------------------------
28
29 template<BOOST_URL_CONSTRAINT(grammar::CharSet) CS>
30 std::size_t
31 877 encoded_size(
32 core::string_view s,
33 CS const& allowed,
34 encoding_opts opt) noexcept
35 {
36 /*
37 If you get a compilation error here, it
38 means that the value you passed does
39 not meet the requirements stated in
40 the documentation.
41 */
42 BOOST_CORE_STATIC_ASSERT(
43 grammar::is_charset<CS>::value);
44
45 877 std::size_t n = 0;
46 877 auto it = s.data();
47 877 auto const last = it + s.size();
48
49
8/12
unsigned long boost::urls::encoded_size<boost::urls::encode_test::test_chars>(boost::core::basic_string_view<char>, boost::urls::encode_test::test_chars const&, boost::urls::encoding_opts):
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 21 times.
unsigned long boost::urls::encoded_size<boost::urls::grammar::lut_chars>(boost::core::basic_string_view<char>, boost::urls::grammar::lut_chars const&, boost::urls::encoding_opts):
✓ Branch 0 taken 663 times.
✓ Branch 1 taken 167 times.
unsigned long boost::urls::encoded_size<boost::urls::space_as_plus_test_chars<false, false> >(boost::core::basic_string_view<char>, boost::urls::space_as_plus_test_chars<false, false> const&, boost::urls::encoding_opts):
✗ Branch 0 not taken.
✓ Branch 1 taken 1 time.
unsigned long boost::urls::encoded_size<boost::urls::space_as_plus_test_chars<false, true> >(boost::core::basic_string_view<char>, boost::urls::space_as_plus_test_chars<false, true> const&, boost::urls::encoding_opts):
✗ Branch 0 not taken.
✓ Branch 1 taken 1 time.
unsigned long boost::urls::encoded_size<boost::urls::space_as_plus_test_chars<true, false> >(boost::core::basic_string_view<char>, boost::urls::space_as_plus_test_chars<true, false> const&, boost::urls::encoding_opts):
✗ Branch 0 not taken.
✓ Branch 1 taken 1 time.
unsigned long boost::urls::encoded_size<boost::urls::space_as_plus_test_chars<true, true> >(boost::core::basic_string_view<char>, boost::urls::space_as_plus_test_chars<true, true> const&, boost::urls::encoding_opts):
✗ Branch 0 not taken.
✓ Branch 1 taken 1 time.
877 if (!opt.space_as_plus)
50 {
51
4/12
unsigned long boost::urls::encoded_size<boost::urls::encode_test::test_chars>(boost::core::basic_string_view<char>, boost::urls::encode_test::test_chars const&, boost::urls::encoding_opts):
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 22 times.
unsigned long boost::urls::encoded_size<boost::urls::grammar::lut_chars>(boost::core::basic_string_view<char>, boost::urls::grammar::lut_chars const&, boost::urls::encoding_opts):
✓ Branch 0 taken 2595 times.
✓ Branch 1 taken 663 times.
unsigned long boost::urls::encoded_size<boost::urls::space_as_plus_test_chars<false, false> >(boost::core::basic_string_view<char>, boost::urls::space_as_plus_test_chars<false, false> const&, boost::urls::encoding_opts):
✗ Branch 0 not taken.
✗ Branch 1 not taken.
unsigned long boost::urls::encoded_size<boost::urls::space_as_plus_test_chars<false, true> >(boost::core::basic_string_view<char>, boost::urls::space_as_plus_test_chars<false, true> const&, boost::urls::encoding_opts):
✗ Branch 0 not taken.
✗ Branch 1 not taken.
unsigned long boost::urls::encoded_size<boost::urls::space_as_plus_test_chars<true, false> >(boost::core::basic_string_view<char>, boost::urls::space_as_plus_test_chars<true, false> const&, boost::urls::encoding_opts):
✗ Branch 0 not taken.
✗ Branch 1 not taken.
unsigned long boost::urls::encoded_size<boost::urls::space_as_plus_test_chars<true, true> >(boost::core::basic_string_view<char>, boost::urls::space_as_plus_test_chars<true, true> const&, boost::urls::encoding_opts):
✗ Branch 0 not taken.
✗ Branch 1 not taken.
3310 while (it != last)
52 {
53 2625 char const c = *it;
54
4/12
unsigned long boost::urls::encoded_size<boost::urls::encode_test::test_chars>(boost::core::basic_string_view<char>, boost::urls::encode_test::test_chars const&, boost::urls::encoding_opts):
✓ Branch 1 taken 12 times.
✓ Branch 2 taken 18 times.
unsigned long boost::urls::encoded_size<boost::urls::grammar::lut_chars>(boost::core::basic_string_view<char>, boost::urls::grammar::lut_chars const&, boost::urls::encoding_opts):
✓ Branch 1 taken 2489 times.
✓ Branch 2 taken 106 times.
unsigned long boost::urls::encoded_size<boost::urls::space_as_plus_test_chars<false, false> >(boost::core::basic_string_view<char>, boost::urls::space_as_plus_test_chars<false, false> const&, boost::urls::encoding_opts):
✗ Branch 1 not taken.
✗ Branch 2 not taken.
unsigned long boost::urls::encoded_size<boost::urls::space_as_plus_test_chars<false, true> >(boost::core::basic_string_view<char>, boost::urls::space_as_plus_test_chars<false, true> const&, boost::urls::encoding_opts):
✗ Branch 1 not taken.
✗ Branch 2 not taken.
unsigned long boost::urls::encoded_size<boost::urls::space_as_plus_test_chars<true, false> >(boost::core::basic_string_view<char>, boost::urls::space_as_plus_test_chars<true, false> const&, boost::urls::encoding_opts):
✗ Branch 1 not taken.
✗ Branch 2 not taken.
unsigned long boost::urls::encoded_size<boost::urls::space_as_plus_test_chars<true, true> >(boost::core::basic_string_view<char>, boost::urls::space_as_plus_test_chars<true, true> const&, boost::urls::encoding_opts):
✗ Branch 1 not taken.
✗ Branch 2 not taken.
2625 if (allowed(c))
55 {
56 2501 ++n;
57 }
58 else
59 {
60 124 n += 3;
61 }
62 2625 ++it;
63 }
64 }
65 else
66 {
67 // '+' is always encoded (thus
68 // spending 3 chars) even if
69 // allowed because "%2B" and
70 // "+" have different meanings
71 // when space as plus is enabled
72 using FNT = bool (*)(CS const& allowed, char);
73 192 FNT takes_one_char =
74
6/12
unsigned long boost::urls::encoded_size<boost::urls::encode_test::test_chars>(boost::core::basic_string_view<char>, boost::urls::encode_test::test_chars const&, boost::urls::encoding_opts):
✓ Branch 1 taken 21 times.
✗ Branch 2 not taken.
unsigned long boost::urls::encoded_size<boost::urls::grammar::lut_chars>(boost::core::basic_string_view<char>, boost::urls::grammar::lut_chars const&, boost::urls::encoding_opts):
✓ Branch 1 taken 167 times.
✗ Branch 2 not taken.
unsigned long boost::urls::encoded_size<boost::urls::space_as_plus_test_chars<false, false> >(boost::core::basic_string_view<char>, boost::urls::space_as_plus_test_chars<false, false> const&, boost::urls::encoding_opts):
✗ Branch 1 not taken.
✓ Branch 2 taken 1 time.
unsigned long boost::urls::encoded_size<boost::urls::space_as_plus_test_chars<false, true> >(boost::core::basic_string_view<char>, boost::urls::space_as_plus_test_chars<false, true> const&, boost::urls::encoding_opts):
✗ Branch 1 not taken.
✓ Branch 2 taken 1 time.
unsigned long boost::urls::encoded_size<boost::urls::space_as_plus_test_chars<true, false> >(boost::core::basic_string_view<char>, boost::urls::space_as_plus_test_chars<true, false> const&, boost::urls::encoding_opts):
✓ Branch 1 taken 1 time.
✗ Branch 2 not taken.
unsigned long boost::urls::encoded_size<boost::urls::space_as_plus_test_chars<true, true> >(boost::core::basic_string_view<char>, boost::urls::space_as_plus_test_chars<true, true> const&, boost::urls::encoding_opts):
✓ Branch 1 taken 1 time.
✗ Branch 2 not taken.
384 allowed('+') ?
75
4/12
unsigned long boost::urls::encoded_size<boost::urls::encode_test::test_chars>(boost::core::basic_string_view<char>, boost::urls::encode_test::test_chars const&, boost::urls::encoding_opts):
✗ Branch 1 not taken.
✓ Branch 2 taken 21 times.
unsigned long boost::urls::encoded_size<boost::urls::grammar::lut_chars>(boost::core::basic_string_view<char>, boost::urls::grammar::lut_chars const&, boost::urls::encoding_opts):
✗ Branch 1 not taken.
✓ Branch 2 taken 167 times.
unsigned long boost::urls::encoded_size<boost::urls::space_as_plus_test_chars<false, false> >(boost::core::basic_string_view<char>, boost::urls::space_as_plus_test_chars<false, false> const&, boost::urls::encoding_opts):
✗ Branch 1 not taken.
✗ Branch 2 not taken.
unsigned long boost::urls::encoded_size<boost::urls::space_as_plus_test_chars<false, true> >(boost::core::basic_string_view<char>, boost::urls::space_as_plus_test_chars<false, true> const&, boost::urls::encoding_opts):
✗ Branch 1 not taken.
✗ Branch 2 not taken.
unsigned long boost::urls::encoded_size<boost::urls::space_as_plus_test_chars<true, false> >(boost::core::basic_string_view<char>, boost::urls::space_as_plus_test_chars<true, false> const&, boost::urls::encoding_opts):
✗ Branch 1 not taken.
✓ Branch 2 taken 1 time.
unsigned long boost::urls::encoded_size<boost::urls::space_as_plus_test_chars<true, true> >(boost::core::basic_string_view<char>, boost::urls::space_as_plus_test_chars<true, true> const&, boost::urls::encoding_opts):
✓ Branch 1 taken 1 time.
✗ Branch 2 not taken.
190 (allowed(' ') ?
76
0/4
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1 FNT([](CS const& allowed, char c){ return allowed(c) && c != '+'; }) :
77
6/6
✓ Branch 2 taken 41 times.
✓ Branch 3 taken 1358 times.
✓ Branch 4 taken 17 times.
✓ Branch 5 taken 24 times.
✓ Branch 6 taken 1367 times.
✓ Branch 7 taken 8 times.
1588 FNT([](CS const& allowed, char c){ return (allowed(c) || c == ' ') && c != '+'; })) :
78
2/14
boost::urls::encoded_size<boost::urls::grammar::lut_chars>(boost::core::basic_string_view<char>, boost::urls::grammar::lut_chars const&, boost::urls::encoding_opts)::{lambda(boost::urls::grammar::lut_chars const&, char)#2}::operator()(boost::urls::grammar::lut_chars const&, char) const:
✗ Branch 1 not taken.
✗ Branch 2 not taken.
unsigned long boost::urls::encoded_size<boost::urls::encode_test::test_chars>(boost::core::basic_string_view<char>, boost::urls::encode_test::test_chars const&, boost::urls::encoding_opts):
✗ Branch 1 not taken.
✗ Branch 2 not taken.
unsigned long boost::urls::encoded_size<boost::urls::grammar::lut_chars>(boost::core::basic_string_view<char>, boost::urls::grammar::lut_chars const&, boost::urls::encoding_opts):
✗ Branch 1 not taken.
✗ Branch 2 not taken.
unsigned long boost::urls::encoded_size<boost::urls::space_as_plus_test_chars<false, false> >(boost::core::basic_string_view<char>, boost::urls::space_as_plus_test_chars<false, false> const&, boost::urls::encoding_opts):
✗ Branch 1 not taken.
✓ Branch 2 taken 1 time.
unsigned long boost::urls::encoded_size<boost::urls::space_as_plus_test_chars<false, true> >(boost::core::basic_string_view<char>, boost::urls::space_as_plus_test_chars<false, true> const&, boost::urls::encoding_opts):
✓ Branch 1 taken 1 time.
✗ Branch 2 not taken.
unsigned long boost::urls::encoded_size<boost::urls::space_as_plus_test_chars<true, false> >(boost::core::basic_string_view<char>, boost::urls::space_as_plus_test_chars<true, false> const&, boost::urls::encoding_opts):
✗ Branch 1 not taken.
✗ Branch 2 not taken.
unsigned long boost::urls::encoded_size<boost::urls::space_as_plus_test_chars<true, true> >(boost::core::basic_string_view<char>, boost::urls::space_as_plus_test_chars<true, true> const&, boost::urls::encoding_opts):
✗ Branch 1 not taken.
✗ Branch 2 not taken.
2 (allowed(' ') ?
79 1 FNT([](CS const& allowed, char c){ return allowed(c); }) :
80
0/4
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1 FNT([](CS const& allowed, char c){ return allowed(c) || c == ' '; }));
81
12/14
boost::urls::encoded_size<boost::urls::grammar::lut_chars>(boost::core::basic_string_view<char>, boost::urls::grammar::lut_chars const&, boost::urls::encoding_opts)::{lambda(boost::urls::grammar::lut_chars const&, char)#4}::operator()(boost::urls::grammar::lut_chars const&, char) const:
✓ Branch 0 taken 1399 times.
✓ Branch 1 taken 167 times.
unsigned long boost::urls::encoded_size<boost::urls::encode_test::test_chars>(boost::core::basic_string_view<char>, boost::urls::encode_test::test_chars const&, boost::urls::encoding_opts):
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 21 times.
unsigned long boost::urls::encoded_size<boost::urls::grammar::lut_chars>(boost::core::basic_string_view<char>, boost::urls::grammar::lut_chars const&, boost::urls::encoding_opts):
✗ Branch 0 not taken.
✗ Branch 1 not taken.
unsigned long boost::urls::encoded_size<boost::urls::space_as_plus_test_chars<false, false> >(boost::core::basic_string_view<char>, boost::urls::space_as_plus_test_chars<false, false> const&, boost::urls::encoding_opts):
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 1 time.
unsigned long boost::urls::encoded_size<boost::urls::space_as_plus_test_chars<false, true> >(boost::core::basic_string_view<char>, boost::urls::space_as_plus_test_chars<false, true> const&, boost::urls::encoding_opts):
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 1 time.
unsigned long boost::urls::encoded_size<boost::urls::space_as_plus_test_chars<true, false> >(boost::core::basic_string_view<char>, boost::urls::space_as_plus_test_chars<true, false> const&, boost::urls::encoding_opts):
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 1 time.
unsigned long boost::urls::encoded_size<boost::urls::space_as_plus_test_chars<true, true> >(boost::core::basic_string_view<char>, boost::urls::space_as_plus_test_chars<true, true> const&, boost::urls::encoding_opts):
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 1 time.
1632 while (it != last)
82 {
83 1440 char const c = *it;
84
12/14
boost::urls::encoded_size<boost::urls::grammar::lut_chars>(boost::core::basic_string_view<char>, boost::urls::grammar::lut_chars const&, boost::urls::encoding_opts)::{lambda(boost::urls::grammar::lut_chars const&, char)#4}::operator()(boost::urls::grammar::lut_chars const&, char) const:
✓ Branch 1 taken 1367 times.
✓ Branch 2 taken 32 times.
unsigned long boost::urls::encoded_size<boost::urls::encode_test::test_chars>(boost::core::basic_string_view<char>, boost::urls::encode_test::test_chars const&, boost::urls::encoding_opts):
✓ Branch 1 taken 19 times.
✓ Branch 2 taken 10 times.
unsigned long boost::urls::encoded_size<boost::urls::grammar::lut_chars>(boost::core::basic_string_view<char>, boost::urls::grammar::lut_chars const&, boost::urls::encoding_opts):
✗ Branch 1 not taken.
✗ Branch 2 not taken.
unsigned long boost::urls::encoded_size<boost::urls::space_as_plus_test_chars<false, false> >(boost::core::basic_string_view<char>, boost::urls::space_as_plus_test_chars<false, false> const&, boost::urls::encoding_opts):
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 1 time.
unsigned long boost::urls::encoded_size<boost::urls::space_as_plus_test_chars<false, true> >(boost::core::basic_string_view<char>, boost::urls::space_as_plus_test_chars<false, true> const&, boost::urls::encoding_opts):
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 1 time.
unsigned long boost::urls::encoded_size<boost::urls::space_as_plus_test_chars<true, false> >(boost::core::basic_string_view<char>, boost::urls::space_as_plus_test_chars<true, false> const&, boost::urls::encoding_opts):
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 1 time.
unsigned long boost::urls::encoded_size<boost::urls::space_as_plus_test_chars<true, true> >(boost::core::basic_string_view<char>, boost::urls::space_as_plus_test_chars<true, true> const&, boost::urls::encoding_opts):
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 1 time.
1440 if (takes_one_char(allowed, c))
85 {
86 1394 ++n;
87 }
88 else
89 {
90 46 n += 3;
91 }
92 1440 ++it;
93 }
94 }
95 877 return n;
96 }
97
98 //------------------------------------------------
99
100 template<BOOST_URL_CONSTRAINT(grammar::CharSet) CS>
101 std::size_t
102 560 encode(
103 char* dest,
104 std::size_t size,
105 core::string_view s,
106 CS const& allowed,
107 encoding_opts opt)
108 {
109 /* If you get a compilation error here, it
110 means that the value you passed does
111 not meet the requirements stated in
112 the documentation.
113 */
114 BOOST_CORE_STATIC_ASSERT(
115 grammar::is_charset<CS>::value);
116
117 // '%' must be reserved
118
2/4
unsigned long boost::urls::encode<boost::urls::encode_test::test_chars>(char*, unsigned long, boost::core::basic_string_view<char>, boost::urls::encode_test::test_chars const&, boost::urls::encoding_opts):
✗ Branch 1 not taken.
✓ Branch 2 taken 56 times.
unsigned long boost::urls::encode<boost::urls::grammar::lut_chars>(char*, unsigned long, boost::core::basic_string_view<char>, boost::urls::grammar::lut_chars const&, boost::urls::encoding_opts):
✗ Branch 1 not taken.
✓ Branch 2 taken 504 times.
560 BOOST_ASSERT(!allowed('%'));
119
120 560 char const* const hex =
121 560 detail::hexdigs[opt.lower_case];
122 655 auto const encode = [hex](
123 char*& dest,
124 unsigned char c) noexcept
125 {
126 95 *dest++ = '%';
127 95 *dest++ = hex[c>>4];
128 95 *dest++ = hex[c&0xf];
129 };
130
131 560 auto it = s.data();
132 560 auto const end = dest + size;
133 560 auto const last = it + s.size();
134 560 auto const dest0 = dest;
135 560 auto const end3 = end - 3;
136
137
5/6
boost::urls::encode<boost::urls::grammar::lut_chars>(char*, unsigned long, boost::core::basic_string_view<char>, boost::urls::grammar::lut_chars const&, boost::urls::encoding_opts)::{lambda(char*&, unsigned char)#1}::operator()(char*&, unsigned char) const:
✓ Branch 0 taken 337 times.
✓ Branch 1 taken 166 times.
unsigned long boost::urls::encode<boost::urls::encode_test::test_chars>(char*, unsigned long, boost::core::basic_string_view<char>, boost::urls::encode_test::test_chars const&, boost::urls::encoding_opts):
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 26 times.
unsigned long boost::urls::encode<boost::urls::grammar::lut_chars>(char*, unsigned long, boost::core::basic_string_view<char>, boost::urls::grammar::lut_chars const&, boost::urls::encoding_opts):
✓ Branch 0 taken 1 time.
✗ Branch 1 not taken.
560 if (!opt.space_as_plus)
138 {
139
6/6
boost::urls::encode<boost::urls::grammar::lut_chars>(char*, unsigned long, boost::core::basic_string_view<char>, boost::urls::grammar::lut_chars const&, boost::urls::encoding_opts)::{lambda(char*&, unsigned char)#1}::operator()(char*&, unsigned char) const:
✓ Branch 0 taken 1422 times.
✓ Branch 1 taken 337 times.
unsigned long boost::urls::encode<boost::urls::encode_test::test_chars>(char*, unsigned long, boost::core::basic_string_view<char>, boost::urls::encode_test::test_chars const&, boost::urls::encoding_opts):
✓ Branch 0 taken 46 times.
✓ Branch 1 taken 12 times.
unsigned long boost::urls::encode<boost::urls::grammar::lut_chars>(char*, unsigned long, boost::core::basic_string_view<char>, boost::urls::grammar::lut_chars const&, boost::urls::encoding_opts):
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 1 time.
1831 while(it != last)
140 {
141 1481 char const c = *it;
142
6/6
boost::urls::encode<boost::urls::grammar::lut_chars>(char*, unsigned long, boost::core::basic_string_view<char>, boost::urls::grammar::lut_chars const&, boost::urls::encoding_opts)::{lambda(char*&, unsigned char)#1}::operator()(char*&, unsigned char) const:
✓ Branch 1 taken 1359 times.
✓ Branch 2 taken 63 times.
unsigned long boost::urls::encode<boost::urls::encode_test::test_chars>(char*, unsigned long, boost::core::basic_string_view<char>, boost::urls::encode_test::test_chars const&, boost::urls::encoding_opts):
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 28 times.
unsigned long boost::urls::encode<boost::urls::grammar::lut_chars>(char*, unsigned long, boost::core::basic_string_view<char>, boost::urls::grammar::lut_chars const&, boost::urls::encoding_opts):
✓ Branch 1 taken 12 times.
✓ Branch 2 taken 1 time.
1481 if (allowed(c))
143 {
144
4/6
boost::urls::encode<boost::urls::grammar::lut_chars>(char*, unsigned long, boost::core::basic_string_view<char>, boost::urls::grammar::lut_chars const&, boost::urls::encoding_opts)::{lambda(char*&, unsigned char)#1}::operator()(char*&, unsigned char) const:
✗ Branch 0 not taken.
✓ Branch 1 taken 1359 times.
unsigned long boost::urls::encode<boost::urls::encode_test::test_chars>(char*, unsigned long, boost::core::basic_string_view<char>, boost::urls::encode_test::test_chars const&, boost::urls::encoding_opts):
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 15 times.
unsigned long boost::urls::encode<boost::urls::grammar::lut_chars>(char*, unsigned long, boost::core::basic_string_view<char>, boost::urls::grammar::lut_chars const&, boost::urls::encoding_opts):
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
1389 if(dest == end)
145 3 return dest - dest0;
146 1386 *dest++ = c;
147 1386 ++it;
148 1386 continue;
149 }
150
4/6
boost::urls::encode<boost::urls::grammar::lut_chars>(char*, unsigned long, boost::core::basic_string_view<char>, boost::urls::grammar::lut_chars const&, boost::urls::encoding_opts)::{lambda(char*&, unsigned char)#1}::operator()(char*&, unsigned char) const:
✗ Branch 0 not taken.
✓ Branch 1 taken 63 times.
unsigned long boost::urls::encode<boost::urls::encode_test::test_chars>(char*, unsigned long, boost::core::basic_string_view<char>, boost::urls::encode_test::test_chars const&, boost::urls::encoding_opts):
✓ Branch 0 taken 15 times.
✓ Branch 1 taken 13 times.
unsigned long boost::urls::encode<boost::urls::grammar::lut_chars>(char*, unsigned long, boost::core::basic_string_view<char>, boost::urls::grammar::lut_chars const&, boost::urls::encoding_opts):
✗ Branch 0 not taken.
✓ Branch 1 taken 1 time.
92 if (dest > end3)
151 15 return dest - dest0;
152 77 encode(dest, c);
153 77 ++it;
154 }
155 350 return dest - dest0;
156 }
157 else
158 {
159
4/6
boost::urls::encode<boost::urls::grammar::lut_chars>(char*, unsigned long, boost::core::basic_string_view<char>, boost::urls::grammar::lut_chars const&, boost::urls::encoding_opts)::{lambda(char*&, unsigned char)#1}::operator()(char*&, unsigned char) const:
✓ Branch 0 taken 1384 times.
✓ Branch 1 taken 166 times.
unsigned long boost::urls::encode<boost::urls::encode_test::test_chars>(char*, unsigned long, boost::core::basic_string_view<char>, boost::urls::encode_test::test_chars const&, boost::urls::encoding_opts):
✓ Branch 0 taken 40 times.
✓ Branch 1 taken 12 times.
unsigned long boost::urls::encode<boost::urls::grammar::lut_chars>(char*, unsigned long, boost::core::basic_string_view<char>, boost::urls::grammar::lut_chars const&, boost::urls::encoding_opts):
✗ Branch 0 not taken.
✗ Branch 1 not taken.
1602 while (it != last)
160 {
161 1424 char const c = *it;
162
4/6
boost::urls::encode<boost::urls::grammar::lut_chars>(char*, unsigned long, boost::core::basic_string_view<char>, boost::urls::grammar::lut_chars const&, boost::urls::encoding_opts)::{lambda(char*&, unsigned char)#1}::operator()(char*&, unsigned char) const:
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 1368 times.
unsigned long boost::urls::encode<boost::urls::encode_test::test_chars>(char*, unsigned long, boost::core::basic_string_view<char>, boost::urls::encode_test::test_chars const&, boost::urls::encoding_opts):
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 31 times.
unsigned long boost::urls::encode<boost::urls::grammar::lut_chars>(char*, unsigned long, boost::core::basic_string_view<char>, boost::urls::grammar::lut_chars const&, boost::urls::encoding_opts):
✗ Branch 0 not taken.
✗ Branch 1 not taken.
1424 if (c == ' ')
163 {
164
3/6
boost::urls::encode<boost::urls::grammar::lut_chars>(char*, unsigned long, boost::core::basic_string_view<char>, boost::urls::grammar::lut_chars const&, boost::urls::encoding_opts)::{lambda(char*&, unsigned char)#1}::operator()(char*&, unsigned char) const:
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
unsigned long boost::urls::encode<boost::urls::encode_test::test_chars>(char*, unsigned long, boost::core::basic_string_view<char>, boost::urls::encode_test::test_chars const&, boost::urls::encoding_opts):
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 7 times.
unsigned long boost::urls::encode<boost::urls::grammar::lut_chars>(char*, unsigned long, boost::core::basic_string_view<char>, boost::urls::grammar::lut_chars const&, boost::urls::encoding_opts):
✗ Branch 0 not taken.
✗ Branch 1 not taken.
25 if(dest == end)
165 2 return dest - dest0;
166 23 *dest++ = '+';
167 23 ++it;
168 23 continue;
169 }
170 2748 else if (
171
11/18
boost::urls::encode<boost::urls::grammar::lut_chars>(char*, unsigned long, boost::core::basic_string_view<char>, boost::urls::grammar::lut_chars const&, boost::urls::encoding_opts)::{lambda(char*&, unsigned char)#1}::operator()(char*&, unsigned char) const:
✓ Branch 1 taken 1344 times.
✓ Branch 2 taken 24 times.
✓ Branch 3 taken 1336 times.
✓ Branch 4 taken 8 times.
✓ Branch 5 taken 1336 times.
✓ Branch 6 taken 32 times.
unsigned long boost::urls::encode<boost::urls::encode_test::test_chars>(char*, unsigned long, boost::core::basic_string_view<char>, boost::urls::encode_test::test_chars const&, boost::urls::encoding_opts):
✓ Branch 1 taken 16 times.
✓ Branch 2 taken 15 times.
✓ Branch 3 taken 16 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 16 times.
✓ Branch 6 taken 15 times.
unsigned long boost::urls::encode<boost::urls::grammar::lut_chars>(char*, unsigned long, boost::core::basic_string_view<char>, boost::urls::grammar::lut_chars const&, boost::urls::encoding_opts):
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
1399 allowed(c) &&
172 c != '+')
173 {
174
3/6
boost::urls::encode<boost::urls::grammar::lut_chars>(char*, unsigned long, boost::core::basic_string_view<char>, boost::urls::grammar::lut_chars const&, boost::urls::encoding_opts)::{lambda(char*&, unsigned char)#1}::operator()(char*&, unsigned char) const:
✗ Branch 0 not taken.
✓ Branch 1 taken 1336 times.
unsigned long boost::urls::encode<boost::urls::encode_test::test_chars>(char*, unsigned long, boost::core::basic_string_view<char>, boost::urls::encode_test::test_chars const&, boost::urls::encoding_opts):
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 13 times.
unsigned long boost::urls::encode<boost::urls::grammar::lut_chars>(char*, unsigned long, boost::core::basic_string_view<char>, boost::urls::grammar::lut_chars const&, boost::urls::encoding_opts):
✗ Branch 0 not taken.
✗ Branch 1 not taken.
1352 if(dest == end)
175 3 return dest - dest0;
176 1349 *dest++ = c;
177 1349 ++it;
178 1349 continue;
179 }
180
3/6
boost::urls::encode<boost::urls::grammar::lut_chars>(char*, unsigned long, boost::core::basic_string_view<char>, boost::urls::grammar::lut_chars const&, boost::urls::encoding_opts)::{lambda(char*&, unsigned char)#1}::operator()(char*&, unsigned char) const:
✗ Branch 0 not taken.
✓ Branch 1 taken 32 times.
unsigned long boost::urls::encode<boost::urls::encode_test::test_chars>(char*, unsigned long, boost::core::basic_string_view<char>, boost::urls::encode_test::test_chars const&, boost::urls::encoding_opts):
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 6 times.
unsigned long boost::urls::encode<boost::urls::grammar::lut_chars>(char*, unsigned long, boost::core::basic_string_view<char>, boost::urls::grammar::lut_chars const&, boost::urls::encoding_opts):
✗ Branch 0 not taken.
✗ Branch 1 not taken.
47 if(dest > end3)
181 9 return dest - dest0;
182 38 encode(dest, c);
183 38 ++it;
184 }
185 }
186 178 return dest - dest0;
187 }
188
189 //------------------------------------------------
190
191 // unsafe encode just
192 // asserts on the output buffer
193 //
194 template<BOOST_URL_CONSTRAINT(grammar::CharSet) CS>
195 std::size_t
196 181 encode_unsafe(
197 char* dest,
198 std::size_t size,
199 core::string_view s,
200 CS const& allowed,
201 encoding_opts opt)
202 {
203 BOOST_CORE_STATIC_ASSERT(
204 grammar::is_charset<CS>::value);
205
206 // '%' must be reserved
207
6/12
unsigned long boost::urls::encode_unsafe<boost::urls::encode_test::test_chars>(char*, unsigned long, boost::core::basic_string_view<char>, boost::urls::encode_test::test_chars const&, boost::urls::encoding_opts):
✗ Branch 1 not taken.
✓ Branch 2 taken 17 times.
unsigned long boost::urls::encode_unsafe<boost::urls::grammar::lut_chars>(char*, unsigned long, boost::core::basic_string_view<char>, boost::urls::grammar::lut_chars const&, boost::urls::encoding_opts):
✗ Branch 1 not taken.
✓ Branch 2 taken 160 times.
unsigned long boost::urls::encode_unsafe<boost::urls::space_as_plus_test_chars<false, false> >(char*, unsigned long, boost::core::basic_string_view<char>, boost::urls::space_as_plus_test_chars<false, false> const&, boost::urls::encoding_opts):
✗ Branch 1 not taken.
✓ Branch 2 taken 1 time.
unsigned long boost::urls::encode_unsafe<boost::urls::space_as_plus_test_chars<false, true> >(char*, unsigned long, boost::core::basic_string_view<char>, boost::urls::space_as_plus_test_chars<false, true> const&, boost::urls::encoding_opts):
✗ Branch 1 not taken.
✓ Branch 2 taken 1 time.
unsigned long boost::urls::encode_unsafe<boost::urls::space_as_plus_test_chars<true, false> >(char*, unsigned long, boost::core::basic_string_view<char>, boost::urls::space_as_plus_test_chars<true, false> const&, boost::urls::encoding_opts):
✗ Branch 1 not taken.
✓ Branch 2 taken 1 time.
unsigned long boost::urls::encode_unsafe<boost::urls::space_as_plus_test_chars<true, true> >(char*, unsigned long, boost::core::basic_string_view<char>, boost::urls::space_as_plus_test_chars<true, true> const&, boost::urls::encoding_opts):
✗ Branch 1 not taken.
✓ Branch 2 taken 1 time.
181 BOOST_ASSERT(!allowed('%'));
208
209 181 auto it = s.data();
210 181 auto const last = it + s.size();
211 181 auto const end = dest + size;
212 ignore_unused(end);
213
214 181 char const* const hex =
215 181 detail::hexdigs[opt.lower_case];
216 251 auto const encode = [end, hex](
217 char*& dest,
218 unsigned char c) noexcept
219 {
220 35 ignore_unused(end);
221 35 *dest++ = '%';
222
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35 times.
35 BOOST_ASSERT(dest != end);
223 35 *dest++ = hex[c>>4];
224
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35 times.
35 BOOST_ASSERT(dest != end);
225 35 *dest++ = hex[c&0xf];
226 };
227
228 181 auto const dest0 = dest;
229
8/12
boost::urls::encode_unsafe<boost::urls::grammar::lut_chars>(char*, unsigned long, boost::core::basic_string_view<char>, boost::urls::grammar::lut_chars const&, boost::urls::encoding_opts)::{lambda(char*&, unsigned char)#1}::operator()(char*&, unsigned char) const:
✓ Branch 0 taken 159 times.
✓ Branch 1 taken 1 time.
unsigned long boost::urls::encode_unsafe<boost::urls::encode_test::test_chars>(char*, unsigned long, boost::core::basic_string_view<char>, boost::urls::encode_test::test_chars const&, boost::urls::encoding_opts):
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 8 times.
unsigned long boost::urls::encode_unsafe<boost::urls::space_as_plus_test_chars<false, false> >(char*, unsigned long, boost::core::basic_string_view<char>, boost::urls::space_as_plus_test_chars<false, false> const&, boost::urls::encoding_opts):
✗ Branch 0 not taken.
✓ Branch 1 taken 1 time.
unsigned long boost::urls::encode_unsafe<boost::urls::space_as_plus_test_chars<false, true> >(char*, unsigned long, boost::core::basic_string_view<char>, boost::urls::space_as_plus_test_chars<false, true> const&, boost::urls::encoding_opts):
✗ Branch 0 not taken.
✓ Branch 1 taken 1 time.
unsigned long boost::urls::encode_unsafe<boost::urls::space_as_plus_test_chars<true, false> >(char*, unsigned long, boost::core::basic_string_view<char>, boost::urls::space_as_plus_test_chars<true, false> const&, boost::urls::encoding_opts):
✗ Branch 0 not taken.
✓ Branch 1 taken 1 time.
unsigned long boost::urls::encode_unsafe<boost::urls::space_as_plus_test_chars<true, true> >(char*, unsigned long, boost::core::basic_string_view<char>, boost::urls::space_as_plus_test_chars<true, true> const&, boost::urls::encoding_opts):
✗ Branch 0 not taken.
✓ Branch 1 taken 1 time.
181 if (!opt.space_as_plus)
230 {
231
4/12
boost::urls::encode_unsafe<boost::urls::grammar::lut_chars>(char*, unsigned long, boost::core::basic_string_view<char>, boost::urls::grammar::lut_chars const&, boost::urls::encoding_opts)::{lambda(char*&, unsigned char)#1}::operator()(char*&, unsigned char) const:
✓ Branch 0 taken 441 times.
✓ Branch 1 taken 159 times.
unsigned long boost::urls::encode_unsafe<boost::urls::encode_test::test_chars>(char*, unsigned long, boost::core::basic_string_view<char>, boost::urls::encode_test::test_chars const&, boost::urls::encoding_opts):
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 9 times.
unsigned long boost::urls::encode_unsafe<boost::urls::space_as_plus_test_chars<false, false> >(char*, unsigned long, boost::core::basic_string_view<char>, boost::urls::space_as_plus_test_chars<false, false> const&, boost::urls::encoding_opts):
✗ Branch 0 not taken.
✗ Branch 1 not taken.
unsigned long boost::urls::encode_unsafe<boost::urls::space_as_plus_test_chars<false, true> >(char*, unsigned long, boost::core::basic_string_view<char>, boost::urls::space_as_plus_test_chars<false, true> const&, boost::urls::encoding_opts):
✗ Branch 0 not taken.
✗ Branch 1 not taken.
unsigned long boost::urls::encode_unsafe<boost::urls::space_as_plus_test_chars<true, false> >(char*, unsigned long, boost::core::basic_string_view<char>, boost::urls::space_as_plus_test_chars<true, false> const&, boost::urls::encoding_opts):
✗ Branch 0 not taken.
✗ Branch 1 not taken.
unsigned long boost::urls::encode_unsafe<boost::urls::space_as_plus_test_chars<true, true> >(char*, unsigned long, boost::core::basic_string_view<char>, boost::urls::space_as_plus_test_chars<true, true> const&, boost::urls::encoding_opts):
✗ Branch 0 not taken.
✗ Branch 1 not taken.
623 while(it != last)
232 {
233
2/12
boost::urls::encode_unsafe<boost::urls::grammar::lut_chars>(char*, unsigned long, boost::core::basic_string_view<char>, boost::urls::grammar::lut_chars const&, boost::urls::encoding_opts)::{lambda(char*&, unsigned char)#1}::operator()(char*&, unsigned char) const:
✗ Branch 0 not taken.
✓ Branch 1 taken 441 times.
unsigned long boost::urls::encode_unsafe<boost::urls::encode_test::test_chars>(char*, unsigned long, boost::core::basic_string_view<char>, boost::urls::encode_test::test_chars const&, boost::urls::encoding_opts):
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
unsigned long boost::urls::encode_unsafe<boost::urls::space_as_plus_test_chars<false, false> >(char*, unsigned long, boost::core::basic_string_view<char>, boost::urls::space_as_plus_test_chars<false, false> const&, boost::urls::encoding_opts):
✗ Branch 0 not taken.
✗ Branch 1 not taken.
unsigned long boost::urls::encode_unsafe<boost::urls::space_as_plus_test_chars<false, true> >(char*, unsigned long, boost::core::basic_string_view<char>, boost::urls::space_as_plus_test_chars<false, true> const&, boost::urls::encoding_opts):
✗ Branch 0 not taken.
✗ Branch 1 not taken.
unsigned long boost::urls::encode_unsafe<boost::urls::space_as_plus_test_chars<true, false> >(char*, unsigned long, boost::core::basic_string_view<char>, boost::urls::space_as_plus_test_chars<true, false> const&, boost::urls::encoding_opts):
✗ Branch 0 not taken.
✗ Branch 1 not taken.
unsigned long boost::urls::encode_unsafe<boost::urls::space_as_plus_test_chars<true, true> >(char*, unsigned long, boost::core::basic_string_view<char>, boost::urls::space_as_plus_test_chars<true, true> const&, boost::urls::encoding_opts):
✗ Branch 0 not taken.
✗ Branch 1 not taken.
455 BOOST_ASSERT(dest != end);
234 455 char const c = *it;
235
4/12
boost::urls::encode_unsafe<boost::urls::grammar::lut_chars>(char*, unsigned long, boost::core::basic_string_view<char>, boost::urls::grammar::lut_chars const&, boost::urls::encoding_opts)::{lambda(char*&, unsigned char)#1}::operator()(char*&, unsigned char) const:
✓ Branch 1 taken 406 times.
✓ Branch 2 taken 35 times.
unsigned long boost::urls::encode_unsafe<boost::urls::encode_test::test_chars>(char*, unsigned long, boost::core::basic_string_view<char>, boost::urls::encode_test::test_chars const&, boost::urls::encoding_opts):
✓ Branch 1 taken 6 times.
✓ Branch 2 taken 8 times.
unsigned long boost::urls::encode_unsafe<boost::urls::space_as_plus_test_chars<false, false> >(char*, unsigned long, boost::core::basic_string_view<char>, boost::urls::space_as_plus_test_chars<false, false> const&, boost::urls::encoding_opts):
✗ Branch 1 not taken.
✗ Branch 2 not taken.
unsigned long boost::urls::encode_unsafe<boost::urls::space_as_plus_test_chars<false, true> >(char*, unsigned long, boost::core::basic_string_view<char>, boost::urls::space_as_plus_test_chars<false, true> const&, boost::urls::encoding_opts):
✗ Branch 1 not taken.
✗ Branch 2 not taken.
unsigned long boost::urls::encode_unsafe<boost::urls::space_as_plus_test_chars<true, false> >(char*, unsigned long, boost::core::basic_string_view<char>, boost::urls::space_as_plus_test_chars<true, false> const&, boost::urls::encoding_opts):
✗ Branch 1 not taken.
✗ Branch 2 not taken.
unsigned long boost::urls::encode_unsafe<boost::urls::space_as_plus_test_chars<true, true> >(char*, unsigned long, boost::core::basic_string_view<char>, boost::urls::space_as_plus_test_chars<true, true> const&, boost::urls::encoding_opts):
✗ Branch 1 not taken.
✗ Branch 2 not taken.
455 if(allowed(c))
236 {
237 412 *dest++ = c;
238 }
239 else
240 {
241 43 encode(dest, c);
242 }
243 455 ++it;
244 }
245 }
246 else
247 {
248
12/12
boost::urls::encode_unsafe<boost::urls::grammar::lut_chars>(char*, unsigned long, boost::core::basic_string_view<char>, boost::urls::grammar::lut_chars const&, boost::urls::encoding_opts)::{lambda(char*&, unsigned char)#1}::operator()(char*&, unsigned char) const:
✓ Branch 0 taken 15 times.
✓ Branch 1 taken 1 time.
unsigned long boost::urls::encode_unsafe<boost::urls::encode_test::test_chars>(char*, unsigned long, boost::core::basic_string_view<char>, boost::urls::encode_test::test_chars const&, boost::urls::encoding_opts):
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 8 times.
unsigned long boost::urls::encode_unsafe<boost::urls::space_as_plus_test_chars<false, false> >(char*, unsigned long, boost::core::basic_string_view<char>, boost::urls::space_as_plus_test_chars<false, false> const&, boost::urls::encoding_opts):
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 1 time.
unsigned long boost::urls::encode_unsafe<boost::urls::space_as_plus_test_chars<false, true> >(char*, unsigned long, boost::core::basic_string_view<char>, boost::urls::space_as_plus_test_chars<false, true> const&, boost::urls::encoding_opts):
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 1 time.
unsigned long boost::urls::encode_unsafe<boost::urls::space_as_plus_test_chars<true, false> >(char*, unsigned long, boost::core::basic_string_view<char>, boost::urls::space_as_plus_test_chars<true, false> const&, boost::urls::encoding_opts):
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 1 time.
unsigned long boost::urls::encode_unsafe<boost::urls::space_as_plus_test_chars<true, true> >(char*, unsigned long, boost::core::basic_string_view<char>, boost::urls::space_as_plus_test_chars<true, true> const&, boost::urls::encoding_opts):
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 1 time.
53 while(it != last)
249 {
250
6/12
boost::urls::encode_unsafe<boost::urls::grammar::lut_chars>(char*, unsigned long, boost::core::basic_string_view<char>, boost::urls::grammar::lut_chars const&, boost::urls::encoding_opts)::{lambda(char*&, unsigned char)#1}::operator()(char*&, unsigned char) const:
✗ Branch 0 not taken.
✓ Branch 1 taken 15 times.
unsigned long boost::urls::encode_unsafe<boost::urls::encode_test::test_chars>(char*, unsigned long, boost::core::basic_string_view<char>, boost::urls::encode_test::test_chars const&, boost::urls::encoding_opts):
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
unsigned long boost::urls::encode_unsafe<boost::urls::space_as_plus_test_chars<false, false> >(char*, unsigned long, boost::core::basic_string_view<char>, boost::urls::space_as_plus_test_chars<false, false> const&, boost::urls::encoding_opts):
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
unsigned long boost::urls::encode_unsafe<boost::urls::space_as_plus_test_chars<false, true> >(char*, unsigned long, boost::core::basic_string_view<char>, boost::urls::space_as_plus_test_chars<false, true> const&, boost::urls::encoding_opts):
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
unsigned long boost::urls::encode_unsafe<boost::urls::space_as_plus_test_chars<true, false> >(char*, unsigned long, boost::core::basic_string_view<char>, boost::urls::space_as_plus_test_chars<true, false> const&, boost::urls::encoding_opts):
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
unsigned long boost::urls::encode_unsafe<boost::urls::space_as_plus_test_chars<true, true> >(char*, unsigned long, boost::core::basic_string_view<char>, boost::urls::space_as_plus_test_chars<true, true> const&, boost::urls::encoding_opts):
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
40 BOOST_ASSERT(dest != end);
251 40 char const c = *it;
252
12/12
boost::urls::encode_unsafe<boost::urls::grammar::lut_chars>(char*, unsigned long, boost::core::basic_string_view<char>, boost::urls::grammar::lut_chars const&, boost::urls::encoding_opts)::{lambda(char*&, unsigned char)#1}::operator()(char*&, unsigned char) const:
✓ Branch 0 taken 1 time.
✓ Branch 1 taken 14 times.
unsigned long boost::urls::encode_unsafe<boost::urls::encode_test::test_chars>(char*, unsigned long, boost::core::basic_string_view<char>, boost::urls::encode_test::test_chars const&, boost::urls::encoding_opts):
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 9 times.
unsigned long boost::urls::encode_unsafe<boost::urls::space_as_plus_test_chars<false, false> >(char*, unsigned long, boost::core::basic_string_view<char>, boost::urls::space_as_plus_test_chars<false, false> const&, boost::urls::encoding_opts):
✓ Branch 0 taken 1 time.
✓ Branch 1 taken 2 times.
unsigned long boost::urls::encode_unsafe<boost::urls::space_as_plus_test_chars<false, true> >(char*, unsigned long, boost::core::basic_string_view<char>, boost::urls::space_as_plus_test_chars<false, true> const&, boost::urls::encoding_opts):
✓ Branch 0 taken 1 time.
✓ Branch 1 taken 2 times.
unsigned long boost::urls::encode_unsafe<boost::urls::space_as_plus_test_chars<true, false> >(char*, unsigned long, boost::core::basic_string_view<char>, boost::urls::space_as_plus_test_chars<true, false> const&, boost::urls::encoding_opts):
✓ Branch 0 taken 1 time.
✓ Branch 1 taken 2 times.
unsigned long boost::urls::encode_unsafe<boost::urls::space_as_plus_test_chars<true, true> >(char*, unsigned long, boost::core::basic_string_view<char>, boost::urls::space_as_plus_test_chars<true, true> const&, boost::urls::encoding_opts):
✓ Branch 0 taken 1 time.
✓ Branch 1 taken 2 times.
40 if (c == ' ')
253 {
254 9 *dest++ = '+';
255 }
256 31 else if (
257
29/36
boost::urls::encode_unsafe<boost::urls::grammar::lut_chars>(char*, unsigned long, boost::core::basic_string_view<char>, boost::urls::grammar::lut_chars const&, boost::urls::encoding_opts)::{lambda(char*&, unsigned char)#1}::operator()(char*&, unsigned char) const:
✓ Branch 1 taken 14 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 14 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 14 times.
✗ Branch 6 not taken.
unsigned long boost::urls::encode_unsafe<boost::urls::encode_test::test_chars>(char*, unsigned long, boost::core::basic_string_view<char>, boost::urls::encode_test::test_chars const&, boost::urls::encoding_opts):
✓ Branch 1 taken 6 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 5 times.
✓ Branch 4 taken 1 time.
✓ Branch 5 taken 5 times.
✓ Branch 6 taken 4 times.
unsigned long boost::urls::encode_unsafe<boost::urls::space_as_plus_test_chars<false, false> >(char*, unsigned long, boost::core::basic_string_view<char>, boost::urls::space_as_plus_test_chars<false, false> const&, boost::urls::encoding_opts):
✓ Branch 1 taken 1 time.
✓ Branch 2 taken 1 time.
✓ Branch 3 taken 1 time.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 time.
✓ Branch 6 taken 1 time.
unsigned long boost::urls::encode_unsafe<boost::urls::space_as_plus_test_chars<false, true> >(char*, unsigned long, boost::core::basic_string_view<char>, boost::urls::space_as_plus_test_chars<false, true> const&, boost::urls::encoding_opts):
✓ Branch 1 taken 1 time.
✓ Branch 2 taken 1 time.
✓ Branch 3 taken 1 time.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 time.
✓ Branch 6 taken 1 time.
unsigned long boost::urls::encode_unsafe<boost::urls::space_as_plus_test_chars<true, false> >(char*, unsigned long, boost::core::basic_string_view<char>, boost::urls::space_as_plus_test_chars<true, false> const&, boost::urls::encoding_opts):
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 5 taken 1 time.
✓ Branch 6 taken 1 time.
unsigned long boost::urls::encode_unsafe<boost::urls::space_as_plus_test_chars<true, true> >(char*, unsigned long, boost::core::basic_string_view<char>, boost::urls::space_as_plus_test_chars<true, true> const&, boost::urls::encoding_opts):
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 5 taken 1 time.
✓ Branch 6 taken 1 time.
31 allowed(c) &&
258 c != '+')
259 {
260 23 *dest++ = c;
261 }
262 else
263 {
264 8 encode(dest, c);
265 }
266 40 ++it;
267 }
268 }
269 181 return dest - dest0;
270 }
271
272 //------------------------------------------------
273
274 template<
275 BOOST_URL_CONSTRAINT(string_token::StringToken) StringToken,
276 BOOST_URL_CONSTRAINT(grammar::CharSet) CS>
277 BOOST_URL_STRTOK_RETURN
278 28 encode(
279 core::string_view s,
280 CS const& allowed,
281 encoding_opts opt,
282 StringToken&& token) noexcept
283 {
284 BOOST_CORE_STATIC_ASSERT(
285 grammar::is_charset<CS>::value);
286
287 28 auto const n = encoded_size(
288 s, allowed, opt);
289 28 auto p = token.prepare(n);
290 28 if(n > 0)
291 26 encode_unsafe(
292 p, n, s, allowed, opt);
293 28 return token.result();
294 }
295
296 } // urls
297 } // boost
298
299 #endif
300