MCPcopy Create free account
hub / github.com/boostorg/asio / throwing_generator_test

Function throwing_generator_test

test/experimental/coro/exception.cpp:72–102  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

70}
71
72boost::asio::awaitable<void> throwing_generator_test()
73{
74 int val = 0;
75 bool destr = false;
76 {
77 auto gi = throwing_generator(
78 co_await boost::asio::this_coro::executor,
79 val, destr);
80 bool caught = false;
81 try
82 {
83 for (int i = 0; i < 10; i++)
84 {
85 BOOST_ASIO_CHECK(val == i);
86 const auto next = co_await gi.async_resume(boost::asio::use_awaitable);
87 BOOST_ASIO_CHECK(next);
88 BOOST_ASIO_CHECK(val == *next);
89 BOOST_ASIO_CHECK(val == i + 1);
90 }
91 }
92 catch (std::runtime_error &err)
93 {
94 caught = true;
95 using std::operator ""sv;
96 BOOST_ASIO_CHECK(err.what() == "throwing-generator"sv);
97 }
98 BOOST_ASIO_CHECK(val == 3);
99 BOOST_ASIO_CHECK(caught);
100 }
101 BOOST_ASIO_CHECK(destr);
102};
103
104void run_throwing_generator_test()
105{

Callers 1

Calls 2

throwing_generatorFunction · 0.85
async_resumeMethod · 0.45

Tested by

no test coverage detected