blob: 49c6e3744c1e3e9991e9fea9db09f5ac2f3decdd (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
#include <ccan/timer/timer.h>
/* Include the C files directly. */
#include <ccan/timer/timer.c>
#include <ccan/tap/tap.h>
static struct timeabs timeabs_from_usec(unsigned long long usec)
{
struct timeabs epoch = { { 0, 0 } };
return timeabs_add(epoch, time_from_usec(usec));
}
int main(void)
{
struct timers timers;
struct timer t, *expired;
/* This is how many tests you plan to run */
plan_tests(3);
timers_init(&timers, timeabs_from_usec(1364726722653919ULL));
timer_init(&t);
timer_add(&timers, &t, timeabs_from_usec(1364726722703919ULL));
ok1(!timers_expire(&timers, timeabs_from_usec(1364726722653920ULL)));
expired = timers_expire(&timers, timeabs_from_usec(1364726725454187ULL));
ok1(expired == &t);
ok1(!timers_expire(&timers, timeabs_from_usec(1364726725454187ULL)));
timers_cleanup(&timers);
/* This exits depending on whether all tests passed */
return exit_status();
}
|