1
0
mirror of https://github.com/angr/angr synced 2026-06-08 13:09:39 +00:00
Files
angr-angr/tests/utils/test_bits.py
Fish 5ee75140ff Dev: Switch from black to ruff format. (#6097)
* Dev: Switch from black to ruff format.

* Reformat all the files.
2026-02-05 14:29:21 -07:00

23 lines
651 B
Python
Executable File

#!/usr/bin/env python3
from __future__ import annotations
import unittest
from angr.utils.bits import truncate_bits
# pylint: disable=missing-class-docstring,disable=no-self-use
class TestBits(unittest.TestCase):
def test_truncate_bits(self):
with self.assertRaises(ValueError):
truncate_bits(0, -1)
assert truncate_bits(0, 0) == 0
assert truncate_bits(0, 8) == 0
assert truncate_bits(0x1234, 0) == 0
assert truncate_bits(0x1234, 8) == 0x34
assert truncate_bits(0x1234, 16) == 0x1234
assert truncate_bits(0x1234, 32) == 0x1234
if __name__ == "__main__":
unittest.main()