diff options
author | Cyrille Bagard <nocbos@gmail.com> | 2024-04-17 20:56:39 (GMT) |
---|---|---|
committer | Cyrille Bagard <nocbos@gmail.com> | 2024-04-17 20:56:39 (GMT) |
commit | e97dda4a993713aea7452a604086c9e4f0ebdd7e (patch) | |
tree | af675891f6dc93a38c4ccb00801d13e490eddd6a /tests/common | |
parent | 6b06aa505ee0b183894d0c785f4f4a81839cb906 (diff) |
Diffstat (limited to 'tests/common')
-rw-r--r-- | tests/common/bitfield.py | 29 |
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).""" |