1 | // Copyright (c) 2022 Klemens D. Morgenstern |
---|---|
2 | // |
3 | // Distributed under the Boost Software License, Version 1.0. (See accompanying |
4 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) |
5 | |
6 | #include <boost/cobalt/run.hpp> |
7 | |
8 | #include <boost/test/unit_test.hpp> |
9 | |
10 | using namespace boost; |
11 | |
12 | BOOST_AUTO_TEST_SUITE(run); |
13 | |
14 | BOOST_AUTO_TEST_CASE(run) |
15 | { |
16 | BOOST_CHECK(42 == cobalt::run([]() -> cobalt::task<int> {co_return 42;}())); |
17 | |
18 | asio::io_context ctx; |
19 | cobalt::this_thread::set_executor(ctx.get_executor()); |
20 | BOOST_CHECK(42 == cobalt::run([]() -> cobalt::task<int> {co_return 42;}())); |
21 | |
22 | BOOST_CHECK(ctx.get_executor() == cobalt::this_thread::get_executor()); |
23 | } |
24 | |
25 | BOOST_AUTO_TEST_SUITE_END(); |
26 |