|
|
|
@ -8,6 +8,7 @@ class TestBits(TestCase):
|
|
|
|
|
{"bytes": b'\x7f',
|
|
|
|
|
"str": "01111111",
|
|
|
|
|
"int": 127,
|
|
|
|
|
"hex": "7f",
|
|
|
|
|
"reverse": 254,
|
|
|
|
|
"bitsObject": Bits(127),
|
|
|
|
|
"list": [Bit(0),
|
|
|
|
@ -23,6 +24,7 @@ class TestBits(TestCase):
|
|
|
|
|
{"bytes": b'\xcf',
|
|
|
|
|
"str": "11001111",
|
|
|
|
|
"int": 207,
|
|
|
|
|
"hex": "cf",
|
|
|
|
|
"reverse": 243,
|
|
|
|
|
"bitsObject": Bits(207),
|
|
|
|
|
"list": [1, 1, 0, 0, 1, 1, 1, 1]
|
|
|
|
@ -30,6 +32,7 @@ class TestBits(TestCase):
|
|
|
|
|
{"bytes": b'{',
|
|
|
|
|
"str": "01111011",
|
|
|
|
|
"int": 123,
|
|
|
|
|
"hex": "7b",
|
|
|
|
|
"reverse": 222,
|
|
|
|
|
"bitsObject": Bits(123),
|
|
|
|
|
"list": ["0", "1", "1", "1", "1", "0", "1", "1"]
|
|
|
|
@ -38,6 +41,7 @@ class TestBits(TestCase):
|
|
|
|
|
{"bytes": b'<',
|
|
|
|
|
"str": "00111100",
|
|
|
|
|
"int": 60,
|
|
|
|
|
"hex": "3c",
|
|
|
|
|
"reverse": 60,
|
|
|
|
|
"bitsObject": Bits(60),
|
|
|
|
|
"list": [False,
|
|
|
|
@ -53,6 +57,7 @@ class TestBits(TestCase):
|
|
|
|
|
{"bytes": b'>',
|
|
|
|
|
"str": "00111110",
|
|
|
|
|
"int": 62,
|
|
|
|
|
"hex": "3e",
|
|
|
|
|
"reverse": 124,
|
|
|
|
|
"bitsObject": Bits(62),
|
|
|
|
|
"list": [0,
|
|
|
|
@ -68,6 +73,7 @@ class TestBits(TestCase):
|
|
|
|
|
{"bytes": b'=',
|
|
|
|
|
"str": "00111101",
|
|
|
|
|
"int": 61,
|
|
|
|
|
"hex": "3d",
|
|
|
|
|
"reverse": 188,
|
|
|
|
|
"bitsObject": Bits(61),
|
|
|
|
|
"list": [True, 1, 1, True, Bit(0), Bit(1)]
|
|
|
|
@ -101,6 +107,12 @@ class TestBits(TestCase):
|
|
|
|
|
with self.subTest("testcase[\"int\"]: " + str(testcase["int"])):
|
|
|
|
|
self.assertEqual(int(testcase["bitsObject"]), testcase["int"])
|
|
|
|
|
|
|
|
|
|
def test_hex(self):
|
|
|
|
|
"""Test conversion to hex"""
|
|
|
|
|
for testcase in self.testObjects:
|
|
|
|
|
with self.subTest("testcase[\"hex\"]: " + str(testcase["hex"])):
|
|
|
|
|
self.assertEqual(testcase["bitsObject"].hex(), testcase["hex"])
|
|
|
|
|
|
|
|
|
|
def test_str(self):
|
|
|
|
|
"""Test string representation"""
|
|
|
|
|
for testcase in self.testObjects:
|
|
|
|
|