MCPcopy Create free account
hub / github.com/Icinga/icinga2 / BOOST_AUTO_TEST_CASE

Function BOOST_AUTO_TEST_CASE

test/base-io-engine.cpp:15–40  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

13BOOST_AUTO_TEST_SUITE(base_io_engine)
14
15BOOST_AUTO_TEST_CASE(timeout_run)
16{
17 boost::asio::io_context io;
18 boost::asio::io_context::strand strand (io);
19 int called = 0;
20
21 IoEngine::SpawnCoroutine(strand, [&](boost::asio::yield_context yc) {
22 boost::asio::deadline_timer timer (io);
23
24 Timeout timeout (strand, boost::posix_time::millisec(300), [&called] { ++called; });
25 BOOST_CHECK_EQUAL(called, 0);
26
27 timer.expires_from_now(boost::posix_time::millisec(200));
28 timer.async_wait(yc);
29 BOOST_CHECK_EQUAL(called, 0);
30
31 timer.expires_from_now(boost::posix_time::millisec(200));
32 timer.async_wait(yc);
33 });
34
35 std::thread eventLoop ([&io] { io.run(); });
36 io.run();
37 eventLoop.join();
38
39 BOOST_CHECK_EQUAL(called, 1);
40}
41
42BOOST_AUTO_TEST_CASE(timeout_cancelled)
43{

Callers

nothing calls this directly

Calls 1

CancelMethod · 0.45

Tested by

no test coverage detected