timer: change to use time_mono (api break!)
[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_init(&t);
17         timer_addmono(&timers, &t, grains_to_time(1364984761003398ULL));
18         ok1(t.time == 1364984761003398ULL);
19         ok1(timers.first == 1364984761003398ULL);
20         ok1(!timers_expire(&timers, grains_to_time(1364984760903444ULL)));
21         ok1(timers_check(&timers, NULL));
22         ok1(!timers_expire(&timers, grains_to_time(1364984761002667ULL)));
23         ok1(timers_check(&timers, NULL));
24
25         timers_cleanup(&timers);
26
27         /* This exits depending on whether all tests passed */
28         return exit_status();
29 }