Changeset View
Changeset View
Standalone View
Standalone View
src/test/scheduler_tests.cpp
Show First 20 Lines • Show All 172 Lines • ▼ Show 20 Lines | BOOST_AUTO_TEST_CASE(schedule_every) { | ||||
} | } | ||||
BOOST_CHECK_EQUAL(counter, 0); | BOOST_CHECK_EQUAL(counter, 0); | ||||
scheduler.stop(true); | scheduler.stop(true); | ||||
schedulerThread.join(); | schedulerThread.join(); | ||||
BOOST_CHECK_EQUAL(counter, 42); | BOOST_CHECK_EQUAL(counter, 42); | ||||
} | } | ||||
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) { | BOOST_AUTO_TEST_CASE(singlethreadedscheduler_ordered) { | ||||
CScheduler scheduler; | CScheduler scheduler; | ||||
// each queue should be well ordered with respect to itself but not other | // each queue should be well ordered with respect to itself but not other | ||||
// queues | // queues | ||||
SingleThreadedSchedulerClient queue1(&scheduler); | SingleThreadedSchedulerClient queue1(&scheduler); | ||||
SingleThreadedSchedulerClient queue2(&scheduler); | SingleThreadedSchedulerClient queue2(&scheduler); | ||||
▲ Show 20 Lines • Show All 82 Lines • Show Last 20 Lines |