Skip to content

Commit

Permalink
test: Check that wait_until returns if time point is in the past
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcoFalke committed Mar 6, 2020
1 parent 3516a31 commit fab7d14
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/test/scheduler_tests.cpp
Expand Up @@ -98,6 +98,24 @@ BOOST_AUTO_TEST_CASE(manythreads)
BOOST_CHECK_EQUAL(counterSum, 200);
}

BOOST_AUTO_TEST_CASE(wait_until_past)
{
std::condition_variable condvar;
Mutex mtx;
WAIT_LOCK(mtx, lock);

const auto no_wait= [&](const std::chrono::seconds& d) {
return condvar.wait_until(lock, std::chrono::system_clock::now() - d);
};

BOOST_CHECK(std::cv_status::timeout == no_wait(std::chrono::seconds{1}));
BOOST_CHECK(std::cv_status::timeout == no_wait(std::chrono::minutes{1}));
BOOST_CHECK(std::cv_status::timeout == no_wait(std::chrono::hours{1}));
BOOST_CHECK(std::cv_status::timeout == no_wait(std::chrono::hours{10}));
BOOST_CHECK(std::cv_status::timeout == no_wait(std::chrono::hours{100}));
BOOST_CHECK(std::cv_status::timeout == no_wait(std::chrono::hours{1000}));
}

BOOST_AUTO_TEST_CASE(singlethreadedscheduler_ordered)
{
CScheduler scheduler;
Expand Down

0 comments on commit fab7d14

Please sign in to comment.