summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2022-12-09 07:57:36 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2022-12-09 07:57:52 (GMT)
commitc27f884ec1d18d9cff0d19d6ba8de1dd54d991c4 (patch)
tree6549b81a21142c6e5ace2ba12039d45b6cd12084 /tests
parent6dea5e4fed979cb57f3dbc0c9144f1ff1854b800 (diff)
Allow OR operations in bit fields at a given position.
Diffstat (limited to 'tests')
-rw-r--r--tests/common/bitfield.py37
1 files changed, 37 insertions, 0 deletions
diff --git a/tests/common/bitfield.py b/tests/common/bitfield.py
index 7359a8a..8c4a470 100644
--- a/tests/common/bitfield.py
+++ b/tests/common/bitfield.py
@@ -19,6 +19,23 @@ class TestBitFields(ChrysalideTestCase):
self.assertEqual(bf.popcount, bf2.popcount)
+ def testResizeBitField(self):
+ """Resize bitfields."""
+
+ bf_a = BitField(10, 0)
+
+ bf_b = BitField(6, 0)
+ bf_b.resize(10)
+
+ self.assertEqual(bf_a, bf_b)
+
+ bf_a = BitField(133, 1)
+
+ bf_b = BitField(64, 1)
+ bf_b.resize(133)
+
+ self.assertEqual(bf_a, bf_b)
+
def testBitFieldValues(self):
"""Evaluate bitfields basic values."""
@@ -70,6 +87,26 @@ class TestBitFields(ChrysalideTestCase):
self.assertEqual(bf_f.popcount, bf_a.popcount)
+ def testBitFieldLogicalOperationsAt(self):
+ """Perform logical operations on bitfields at a given position."""
+
+ bf_a = BitField(75, 0)
+
+ bf_b = BitField(4, 1)
+ bf_b.reset(2, 1)
+
+ bf_a.or_at(bf_b, 63)
+
+ self.assertFalse(bf_a.test(62))
+
+ self.assertTrue(bf_a.test(63))
+ self.assertTrue(bf_a.test(64))
+ self.assertFalse(bf_a.test(65))
+ self.assertTrue(bf_a.test(66))
+
+ self.assertFalse(bf_a.test(67))
+
+
def testBitFieldSwitch(self):
"""Switch various bits in bitfields."""