diff options
| author | Dave Hibberd <hibby@debian.org> | 2025-09-25 21:58:50 +0100 |
|---|---|---|
| committer | Dave Hibberd <hibby@debian.org> | 2025-09-25 21:58:50 +0100 |
| commit | dff1a610625ebe7841fca01e20ca6d86b65ee4d0 (patch) | |
| tree | 97c0482e33cbbd110ac648db8a32ea8e09638134 /tests/unit/test_bitwise.py | |
| parent | f6b2e6e7159906b8b3204dca3a9e58e42c36ccbb (diff) | |
New upstream version 20250912upstream/20250912
Diffstat (limited to 'tests/unit/test_bitwise.py')
| -rw-r--r-- | tests/unit/test_bitwise.py | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/tests/unit/test_bitwise.py b/tests/unit/test_bitwise.py index dc38cb6..c50c3fc 100644 --- a/tests/unit/test_bitwise.py +++ b/tests/unit/test_bitwise.py @@ -248,6 +248,22 @@ class TestBitwiseBCDTypes(BaseTest): def test_lbcd_array(self): self._test_def("lbcd foo[2];", "foo", b"\x12\x34", 3412) + def test_bbcd_array_leading_bits(self): + data = memmap.MemoryMapBytes(bytes(b"\xc7\x54")) + obj = bitwise.parse("bbcd foo[2];", data) + # This is what we interpret a leading 0xC000 as + self.assertEqual(int(obj.foo), 754 + 12000) + + # Ignore the top nibble and we expect just the bottom three + obj.foo[0].ignore_bits(0xF0) + self.assertEqual(int(obj.foo), 754) + + # If wet try to set something in the ignored nibble it should be + # ignored but preserved + obj.foo = 1754 + self.assertEqual(int(obj.foo), 754) + self.assertEqual(data[0][0], 0xC7) + class TestBitwiseCharTypes(BaseTest): def test_char(self): |
