From 9593fc545950782ed75f12f53238b07885559b2b Mon Sep 17 00:00:00 2001 From: William Casarin Date: Mon, 9 Jul 2018 22:28:25 -0700 Subject: remove ccan for now --- ccan/likely/test/run-debug.c | 105 ------------------------------------------- 1 file changed, 105 deletions(-) delete mode 100644 ccan/likely/test/run-debug.c (limited to 'ccan/likely/test/run-debug.c') diff --git a/ccan/likely/test/run-debug.c b/ccan/likely/test/run-debug.c deleted file mode 100644 index 72015ee..0000000 --- a/ccan/likely/test/run-debug.c +++ /dev/null @@ -1,105 +0,0 @@ -#define CCAN_LIKELY_DEBUG 1 -#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 bool likely_one_unlikely_two(unsigned int val1, unsigned int val2) -{ - /* Same line, check we don't get confused! */ - if (likely(val1 == 1) && unlikely(val2 == 2)) - return true; - return false; -} - -int main(void) -{ - char *bad; - - plan_tests(14); - - /* Correct guesses. */ - one_seems_likely(1); - ok1(likely_stats(0, 90) == NULL); - one_seems_unlikely(2); - ok1(likely_stats(0, 90) == NULL); - - /* Incorrect guesses. */ - one_seems_likely(0); - one_seems_likely(2); - /* Hasn't been hit 4 times, so this fails */ - ok1(!likely_stats(4, 90)); - bad = likely_stats(3, 90); - ok(strends(bad, "run-debug.c:9:likely(val == 1) correct 33% (1/3)"), - "likely_stats returned %s", bad); - free(bad); - - /* Nothing else above 90% */ - ok1(!likely_stats(0, 90)); - - /* This should get everything. */ - bad = likely_stats(0, 100); - ok(strends(bad, "run-debug.c:16:unlikely(val == 1) correct 100% (1/1)"), - "likely_stats returned %s", bad); - free(bad); - - /* Nothing left (table is actually cleared) */ - ok1(!likely_stats(0, 100)); - - /* Make sure unlikely works */ - one_seems_unlikely(0); - one_seems_unlikely(2); - one_seems_unlikely(1); - - bad = likely_stats(0, 90); - ok(strends(bad, "run-debug.c:16:unlikely(val == 1) correct 66% (2/3)"), - "likely_stats returned %s", bad); - free(bad); - ok1(!likely_stats(0, 100)); - - likely_one_unlikely_two(1, 1); - likely_one_unlikely_two(1, 1); - likely_one_unlikely_two(1, 1); - ok1(!likely_stats(0, 90)); - likely_one_unlikely_two(1, 2); - - bad = likely_stats(0, 90); - ok(strends(bad, "run-debug.c:24:unlikely(val2 == 2) correct 75% (3/4)"), - "likely_stats returned %s", bad); - free(bad); - bad = likely_stats(0, 100); - ok(strends(bad, "run-debug.c:24:likely(val1 == 1) correct 100% (4/4)"), - "likely_stats returned %s", bad); - free(bad); - - ok1(!likely_stats(0, 100)); - - /* Check that reset works! */ - one_seems_unlikely(0); - one_seems_unlikely(2); - one_seems_unlikely(1); - likely_stats_reset(); - - ok1(!likely_stats(0, 100)); - - exit(exit_status()); -} - -/* Fools ccanlint: it doesn't think we use str, htable or hash. */ -#include -#include -#include -- cgit v1.2.3