]> git.ozlabs.org Git - ccan/blob - ccan/timer/test/run-expiry.c
timer: change timers_expire() to return a single timer.
[ccan] / ccan / timer / test / run-expiry.c
1 #include <ccan/timer/timer.h>
2 /* Include the C files directly. */
3 #include <ccan/timer/timer.c>
4 #include <ccan/tap/tap.h>
5
6 int main(void)
7 {
8         struct timers timers;
9         struct timer t;
10
11         /* This is how many tests you plan to run */
12         plan_tests(7);
13
14         timers_init(&timers, grains_to_time(1364984760903400ULL));
15         ok1(timers.base == 1364984760903400ULL);
16         timer_add(&timers, &t, grains_to_time(1364984761003398ULL));
17         ok1(t.time == 1364984761003398ULL);
18         ok1(timers.first == 1364984761003398ULL);
19         ok1(!timers_expire(&timers, grains_to_time(1364984760903444ULL)));
20         ok1(timers_check(&timers, NULL));
21         ok1(!timers_expire(&timers, grains_to_time(1364984761002667ULL)));
22         ok1(timers_check(&timers, NULL));
23
24         timers_cleanup(&timers);
25
26         /* This exits depending on whether all tests passed */
27         return exit_status();
28 }