]> Savannah Git Hosting - gnulib.git/commitdiff
bitset: test: run deterministic tests on several bitset sizes
authorAkim Demaille <akim.demaille@gmail.com>
Tue, 17 Nov 2020 07:23:14 +0000 (08:23 +0100)
committerAkim Demaille <akim.demaille@gmail.com>
Wed, 18 Nov 2020 05:50:28 +0000 (06:50 +0100)
* tests/test-bitset.c (check_attributes): Run it with small and large
sizes.

ChangeLog
tests/test-bitset.c

index 42996e590fcbe9fa8f6ab0cbc4d64b308d414399..a587573a005de5b27ed70d17f75a6abad5827091 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2020-11-17  Akim Demaille  <akim@lrde.epita.fr>
+
+       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  <akim@lrde.epita.fr>
 
        bitset: use ffs where possible in the list implementation
index ebe9e1d55984b7789e63b262e1d81435eaa3f916..9c79d04ff2e887174f344cdeab3f79f2d5d42909 100644 (file)
@@ -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);