diff options
author | David Robillard <d@drobilla.net> | 2020-12-31 20:43:30 +0100 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2020-12-31 20:43:30 +0100 |
commit | 2080aef6a68e2e8b18a7a0d61c8c8cf4de9473d5 (patch) | |
tree | 7922ab46aa6a485eedaa5ffde998a67183b9645d | |
parent | 723cc76c44868e61bcff1d06a145f1482bfc15fd (diff) | |
download | zix-2080aef6a68e2e8b18a7a0d61c8c8cf4de9473d5.tar.gz zix-2080aef6a68e2e8b18a7a0d61c8c8cf4de9473d5.tar.bz2 zix-2080aef6a68e2e8b18a7a0d61c8c8cf4de9473d5.zip |
Improve Bitset test coverage
-rw-r--r-- | test/bitset_test.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/test/bitset_test.c b/test/bitset_test.c index 3ed121c..dda59d3 100644 --- a/test/bitset_test.c +++ b/test/bitset_test.c @@ -95,5 +95,27 @@ main(void) } } + zix_bitset_clear(b, t, N_BITS); + for (size_t i = 0; i < N_BITS; ++i) { + if (i % 2 == 0) { + zix_bitset_set(b, t, i); + + const size_t count = zix_bitset_count_up_to_if(b, t, i); + const size_t result = MIN(N_BITS / 2, i / 2); + if (count != result) { + return test_fail("Count to %" PRIuPTR " is %" PRIuPTR " != %" PRIuPTR + "\n", + i, + count, + result); + } + } else { + if (zix_bitset_count_up_to_if(b, t, i) != (size_t)-1) { + return test_fail( + "Got unexpected non-zero count at index %" PRIuPTR "\n", i); + } + } + } + return 0; } |