bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 3/6] bitset: test: run deterministic tests on several bitset size


From: Akim Demaille
Subject: [PATCH 3/6] bitset: test: run deterministic tests on several bitset sizes
Date: Tue, 17 Nov 2020 18:59:26 +0100

* tests/test-bitset.c (check_attributes): Run it with small and large
sizes.
---
 ChangeLog           |  6 ++++++
 tests/test-bitset.c | 23 +++++++++++++----------
 2 files changed, 19 insertions(+), 10 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 1b3bcbc32..82b67f481 100644
--- 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
diff --git a/tests/test-bitset.c b/tests/test-bitset.c
index ebe9e1d55..9c79d04ff 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);
-- 
2.29.2




reply via email to

[Prev in Thread] Current Thread [Next in Thread]