summaryrefslogtreecommitdiff
path: root/tests/common
diff options
context:
space:
mode:
Diffstat (limited to 'tests/common')
-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."""