MCPcopy Create free account
hub / github.com/boostorg/beast / testParseChunkExtensions

Method testParseChunkExtensions

test/beast/http/chunk_encode.cpp:226–280  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

224 }
225
226 void
227 testParseChunkExtensions()
228 {
229 auto const grind =
230 [&](string_view s)
231 {
232 error_code ec;
233 static_string<200> ss(s.data(), s.size());
234 test::fuzz_rand r;
235 for(auto i = 3; i--;)
236 {
237 test::fuzz(ss, 5, 5, r,
238 [&](string_view s)
239 {
240 chunk_extensions c1;
241 c1.parse(s, ec);
242 if(ec)
243 {
244 pass();
245 return;
246 }
247 chunk_extensions c2;
248 c2.parse(c1.str(), ec);
249 if(! BEAST_EXPECTS(! ec, ec.message()))
250 return;
251 chunk_extensions c3;
252 for(auto const& v : c2)
253 if(v.second.empty())
254 c3.insert(v.first);
255 else
256 c3.insert(v.first, v.second);
257 BEAST_EXPECTS(c2.str() == c3.str(), c3.str());
258 });
259 }
260 };
261 auto const good =
262 [&](string_view s)
263 {
264 error_code ec;
265 chunk_extensions ce;
266 ce.parse(s, ec);
267 BEAST_EXPECTS(! ec, ec.message());
268 grind(s);
269 };
270 auto const bad =
271 [&](string_view s)
272 {
273 error_code ec;
274 chunk_extensions ce;
275 ce.parse(s, ec);
276 BEAST_EXPECT(ec);
277 grind(s);
278 };
279 chunkExtensionsTest(good, bad);
280 }
281
282 void
283 run() override

Callers

nothing calls this directly

Calls 8

fuzzFunction · 0.85
chunkExtensionsTestFunction · 0.85
messageMethod · 0.80
dataMethod · 0.45
sizeMethod · 0.45
strMethod · 0.45
emptyMethod · 0.45
insertMethod · 0.45

Tested by

no test coverage detected