summaryrefslogtreecommitdiff
path: root/tests/common
diff options
context:
space:
mode:
Diffstat (limited to 'tests/common')
-rw-r--r--tests/common/bitfield.py29
1 files changed, 29 insertions, 0 deletions
diff --git a/tests/common/bitfield.py b/tests/common/bitfield.py
index aff5de6..75dfb6e 100644
--- a/tests/common/bitfield.py
+++ b/tests/common/bitfield.py
@@ -231,6 +231,35 @@ class TestBitFields(ChrysalideTestCase):
self.assertNotEqual(bf_a, bf_b)
+ def testSearchOfSetBit(self):
+ """Find the next set bit in a bit field."""
+
+ size = 128
+ bf = BitField(size, 0)
+
+ bits = [ 0, 1, 50, 63, 64, 65, 111 ]
+
+ for b in bits:
+ bf.set(b, 1)
+
+ prev = None
+ found = []
+
+ while prev is None or prev < size:
+
+ if prev is None:
+ f = bf.find_next_set()
+ else:
+ f = bf.find_next_set(prev)
+
+ if f < size:
+ found.append(f)
+
+ prev = f
+
+ self.assertEqual(found, bits)
+
+
def testRealCase00(self):
"""Test bits in bitfields against other bitfields in a real case (#02)."""