mirror of
https://github.com/falk-werner/webfuse
synced 2024-10-27 20:34:10 +00:00
increases coverage of timer test
This commit is contained in:
parent
50272a3822
commit
54ffb34f3f
@ -49,6 +49,23 @@ TEST(timer, trigger)
|
|||||||
wf_impl_timeout_manager_cleanup(&manager);
|
wf_impl_timeout_manager_cleanup(&manager);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST(timer, trigger_on_cleanup)
|
||||||
|
{
|
||||||
|
struct wf_impl_timeout_manager manager;
|
||||||
|
struct wf_impl_timer timer;
|
||||||
|
|
||||||
|
wf_impl_timeout_manager_init(&manager);
|
||||||
|
wf_impl_timer_init(&timer, &manager);
|
||||||
|
|
||||||
|
bool triggered = false;
|
||||||
|
wf_impl_timer_start(&timer, wf_impl_timepoint_in_msec(5 * 60 * 1000), &on_timeout, reinterpret_cast<void*>(&triggered));
|
||||||
|
|
||||||
|
wf_impl_timeout_manager_cleanup(&manager);
|
||||||
|
ASSERT_TRUE(triggered);
|
||||||
|
|
||||||
|
wf_impl_timer_cleanup(&timer);
|
||||||
|
}
|
||||||
|
|
||||||
TEST(timer, cancel)
|
TEST(timer, cancel)
|
||||||
{
|
{
|
||||||
struct wf_impl_timeout_manager manager;
|
struct wf_impl_timeout_manager manager;
|
||||||
@ -69,6 +86,37 @@ TEST(timer, cancel)
|
|||||||
wf_impl_timeout_manager_cleanup(&manager);
|
wf_impl_timeout_manager_cleanup(&manager);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST(timer, cancel_multiple_timers)
|
||||||
|
{
|
||||||
|
static size_t const count = 5;
|
||||||
|
struct wf_impl_timeout_manager manager;
|
||||||
|
struct wf_impl_timer timer[count];
|
||||||
|
|
||||||
|
wf_impl_timeout_manager_init(&manager);
|
||||||
|
|
||||||
|
bool triggered = false;
|
||||||
|
for(size_t i = 0; i < count; i++)
|
||||||
|
{
|
||||||
|
wf_impl_timer_init(&timer[i], &manager);
|
||||||
|
wf_impl_timer_start(&timer[i], wf_impl_timepoint_in_msec(0), &on_timeout, &triggered);
|
||||||
|
}
|
||||||
|
|
||||||
|
msleep(10);
|
||||||
|
for(size_t i = 0; i < count; i++)
|
||||||
|
{
|
||||||
|
wf_impl_timer_cancel(&timer[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
wf_impl_timeout_manager_check(&manager);
|
||||||
|
ASSERT_FALSE(triggered);
|
||||||
|
|
||||||
|
for(size_t i = 0; i < count; i++)
|
||||||
|
{
|
||||||
|
wf_impl_timer_cleanup(&timer[0]);
|
||||||
|
}
|
||||||
|
wf_impl_timeout_manager_cleanup(&manager);
|
||||||
|
}
|
||||||
|
|
||||||
TEST(timer, multiple_timers)
|
TEST(timer, multiple_timers)
|
||||||
{
|
{
|
||||||
static size_t const count = 5;
|
static size_t const count = 5;
|
||||||
|
Loading…
Reference in New Issue
Block a user