time: timemono_add.
[ccan] / ccan / time / test / run-monotonic.c
1 #include <ccan/time/time.h>
2 #include <ccan/time/time.c>
3 #include <ccan/tap/tap.h>
4
5 int main(void)
6 {
7         struct timemono t1, t2;
8         struct timerel t3;
9
10         plan_tests(5);
11
12         /* Test time_mono */
13         t1 = time_mono();
14         t2 = time_mono();
15
16         ok1(!time_less_(t2.ts, t1.ts));
17
18         t3.ts.tv_sec = 1;
19         t3.ts.tv_nsec = 0;
20
21         ok1(time_less(timemono_between(t1, t2), t3));
22         ok1(time_less(timemono_since(t1), t3));
23
24         ok1(timemono_add(t1, t3).ts.tv_sec == t1.ts.tv_sec + 1);
25         ok1(timemono_add(t2, t3).ts.tv_nsec == t2.ts.tv_nsec);
26
27         return exit_status();
28 }