]> git.ozlabs.org Git - ccan/blob - ccan/likely/test/run.c
likely: new module
[ccan] / ccan / likely / test / run.c
1 #include <ccan/likely/likely.c>
2 #include <ccan/likely/likely.h>
3 #include <ccan/tap/tap.h>
4 #include <stdlib.h>
5
6 static bool one_seems_likely(unsigned int val)
7 {
8         if (likely(val == 1))
9                 return true;
10         return false;
11 }
12
13 static bool one_seems_unlikely(unsigned int val)
14 {
15         if (unlikely(val == 1))
16                 return true;
17         return false;
18 }
19
20 static unlikely_func bool calling_is_unlikely(void)
21 {
22         return true;
23 }
24
25 int main(int argc, char *argv[])
26 {
27         plan_tests(5);
28
29         /* Without debug, we can only check that it doesn't effect functions. */
30         ok1(one_seems_likely(1));
31         ok1(!one_seems_likely(2));
32         ok1(one_seems_unlikely(1));
33         ok1(!one_seems_unlikely(2));
34         ok1(calling_is_unlikely());
35         exit(exit_status());
36 }