diff options
author | Akim Demaille <akim.demaille@gmail.com> | 2019-03-18 18:27:27 +0100 |
---|---|---|
committer | Akim Demaille <akim.demaille@gmail.com> | 2019-03-21 07:18:17 +0100 |
commit | 7b31451e25f496ba138ee08348f67fc1d382859b (patch) | |
tree | c4882d58731648330f093c4f4fd4568652fef81d /tests | |
parent | 17c967e57bf89d4c6fc0e94453814cf6852e39e2 (diff) | |
download | gnulib-7b31451e25f496ba138ee08348f67fc1d382859b.tar.gz |
bitset: expose bitset_resize
* lib/bitset.h (bitset_resize): Bounce on the polymorphic implementation.
* tests/test-bitset.c (check_attributes): Check bitset_resize.
(main): Use a variable bitset as reference, since fixed does not support resize.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test-bitset.c | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/tests/test-bitset.c b/tests/test-bitset.c index cef910d53a..282ccef4a6 100644 --- a/tests/test-bitset.c +++ b/tests/test-bitset.c @@ -139,6 +139,19 @@ void compare (enum bitset_attr a, enum bitset_attr b) bitset_zero (bdst); assert_bitset_equal (adst, bdst); + /* resize. + + ARRAY bitsets cannot be resized. */ + if (bitset_type_get (bsrc0) != BITSET_ARRAY) + { + const int nbits_new = RANDOM (256); + bitset_copy (adst, asrc0); + bitset_copy (bdst, bsrc0); + ASSERT (nbits_new == bitset_resize (adst, nbits_new)); + ASSERT (nbits_new == bitset_resize (bdst, nbits_new)); + assert_bitset_equal (adst, bdst); + } + bitset_free (bdst); bitset_free (bsrc3); bitset_free (bsrc2); @@ -204,11 +217,11 @@ int main (void) check_attributes (BITSET_FRUGAL); check_attributes (BITSET_GREEDY); - compare (BITSET_FIXED, BITSET_FIXED); - compare (BITSET_FIXED, BITSET_VARIABLE); - compare (BITSET_FIXED, BITSET_DENSE); - compare (BITSET_FIXED, BITSET_SPARSE); - compare (BITSET_FIXED, BITSET_FRUGAL); - compare (BITSET_FIXED, BITSET_GREEDY); + compare (BITSET_VARIABLE, BITSET_FIXED); + compare (BITSET_VARIABLE, BITSET_VARIABLE); + compare (BITSET_VARIABLE, BITSET_DENSE); + compare (BITSET_VARIABLE, BITSET_SPARSE); + compare (BITSET_VARIABLE, BITSET_FRUGAL); + compare (BITSET_VARIABLE, BITSET_GREEDY); return 0; } |