X-Git-Url: http://git.ozlabs.org/?p=ccan;a=blobdiff_plain;f=ccan%2Flikely%2Ftest%2Frun.c;fp=ccan%2Flikely%2Ftest%2Frun.c;h=b6413b15ce29244714d75037ac11ac0e4b5085c9;hp=0000000000000000000000000000000000000000;hb=9f8c65b28acba8e5eabea5d7abd98b19e62d06fe;hpb=6c579abb882331704795349a7d3c5797bc408562 diff --git a/ccan/likely/test/run.c b/ccan/likely/test/run.c new file mode 100644 index 00000000..b6413b15 --- /dev/null +++ b/ccan/likely/test/run.c @@ -0,0 +1,36 @@ +#include +#include +#include +#include + +static bool one_seems_likely(unsigned int val) +{ + if (likely(val == 1)) + return true; + return false; +} + +static bool one_seems_unlikely(unsigned int val) +{ + if (unlikely(val == 1)) + return true; + return false; +} + +static unlikely_func bool calling_is_unlikely(void) +{ + return true; +} + +int main(int argc, char *argv[]) +{ + plan_tests(5); + + /* Without debug, we can only check that it doesn't effect functions. */ + ok1(one_seems_likely(1)); + ok1(!one_seems_likely(2)); + ok1(one_seems_unlikely(1)); + ok1(!one_seems_unlikely(2)); + ok1(calling_is_unlikely()); + exit(exit_status()); +}