MCPcopy Create free account
hub / github.com/boostorg/json / grind

Method grind

test/stream_parser.cpp:382–424  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

380
381 template<class F>
382 static
383 void
384 grind(string_view s, F const& f,
385 const parse_options& po = parse_options())
386 {
387 try
388 {
389 grind_one(s, {}, f, po);
390
391 fail_loop([&](storage_ptr const& sp)
392 {
393 grind_one(s, sp, f, po);
394 });
395
396 if(s.size() > 1)
397 {
398 // Destroy the stream_parser at every
399 // split point to check leaks.
400 for(std::size_t i = 1;
401 i < s.size(); ++i)
402 {
403 fail_resource mr;
404 mr.fail_max = 0;
405 stream_parser p(storage_ptr(), po);
406 system::error_code ec;
407 p.reset(&mr);
408 p.write(s.data(), i, ec);
409 if(BOOST_TEST(! ec))
410 p.write(
411 s.data() + i,
412 s.size() - i, ec);
413 if(BOOST_TEST(! ec))
414 p.finish(ec);
415 if(BOOST_TEST(! ec))
416 f(p.release(), po);
417 }
418 }
419 }
420 catch(std::exception const&)
421 {
422 BOOST_TEST_FAIL();
423 }
424 }
425
426 static
427 void

Callers

nothing calls this directly

Calls 10

parse_optionsClass · 0.85
fail_loopFunction · 0.85
finishMethod · 0.80
fFunction · 0.70
storage_ptrClass · 0.50
sizeMethod · 0.45
resetMethod · 0.45
writeMethod · 0.45
dataMethod · 0.45
releaseMethod · 0.45

Tested by

no test coverage detected