Skip to content

Commit

Permalink
added bad_executor test
Browse files Browse the repository at this point in the history
  • Loading branch information
klemens-morgenstern committed Dec 13, 2024
1 parent bff49f6 commit c405a54
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions test/promise.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,14 +99,30 @@ cobalt::promise<void> throw_()
cobalt::promise<void> throw_post()
{
co_await asio::post(cobalt::this_thread::get_executor(), cobalt::use_op);
throw std::runtime_error("throw_");
throw std::runtime_error("throw_post");
co_return ;
}

BOOST_AUTO_TEST_CASE(bad_executor_)
{
BOOST_REQUIRE(!cobalt::this_thread::has_executor());
try
{
auto t = test0();
BOOST_FAIL("Should throw");
}
catch(asio::bad_executor &) {}

}


BOOST_AUTO_TEST_CASE(get)
{
BOOST_CHECK_THROW(throw_().get(), std::exception);
asio::io_context ctx;
cobalt::this_thread::set_executor(ctx.get_executor());
auto t = throw_();
BOOST_REQUIRE(t.ready());
BOOST_CHECK_THROW(t.get(), std::exception);
}

cobalt::promise<void> delay_v(asio::io_context &ctx, std::size_t ms)
Expand Down

0 comments on commit c405a54

Please sign in to comment.