From: Akim Demaille Date: Tue, 17 Nov 2020 07:23:14 +0000 (+0100) Subject: bitset: test: run deterministic tests on several bitset sizes X-Git-Tag: v1.0~3498 X-Git-Url: https://gitweb.git.savannah.gnu.org/gitweb/?a=commitdiff_plain;h=927c02dbce880611fab4e245e66863fa2bc617d6;p=gnulib.git bitset: test: run deterministic tests on several bitset sizes * tests/test-bitset.c (check_attributes): Run it with small and large sizes. --- diff --git a/ChangeLog b/ChangeLog index 42996e590f..a587573a00 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2020-11-17 Akim Demaille + + bitset: test: run deterministic tests on several bitset sizes + * tests/test-bitset.c (check_attributes): Run it with small and large + sizes. + 2020-11-17 Akim Demaille bitset: use ffs where possible in the list implementation diff --git a/tests/test-bitset.c b/tests/test-bitset.c index ebe9e1d559..9c79d04ff2 100644 --- a/tests/test-bitset.c +++ b/tests/test-bitset.c @@ -256,12 +256,10 @@ void compare (enum bitset_attr a, enum bitset_attr b) having attributes ATTR. */ static -void check_attributes (enum bitset_attr attr) +void check_attributes (enum bitset_attr attr, int nbits) { - enum { nbits = 32 }; - bitset bs0 = bitset_create (nbits, attr); - ASSERT (bitset_size (bs0) == 32); + ASSERT (bitset_size (bs0) == nbits); ASSERT (bitset_count (bs0) == 0); ASSERT (bitset_empty_p (bs0)); @@ -297,12 +295,17 @@ void check_attributes (enum bitset_attr attr) int main (void) { - check_attributes (BITSET_FIXED); - check_attributes (BITSET_VARIABLE); - check_attributes (BITSET_DENSE); - check_attributes (BITSET_SPARSE); - check_attributes (BITSET_FRUGAL); - check_attributes (BITSET_GREEDY); + for (int i = 0; i < 2; ++i) + { + /* table bitsets have elements that store 256 bits. */ + int nbits = i == 0 ? 32 : 257; + check_attributes (BITSET_FIXED, nbits); + check_attributes (BITSET_VARIABLE, nbits); + check_attributes (BITSET_DENSE, nbits); + check_attributes (BITSET_SPARSE, nbits); + check_attributes (BITSET_FRUGAL, nbits); + check_attributes (BITSET_GREEDY, nbits); + } compare (BITSET_VARIABLE, BITSET_FIXED); compare (BITSET_VARIABLE, BITSET_VARIABLE);