mirror of
https://github.com/angr/angr
synced 2026-08-17 12:23:11 -04:00
* Enable ruff isort rule * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
23 lines
652 B
Python
Executable file
23 lines
652 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()
|