Пример #1
0
 def test_multiple(self):
     bc = BitConsumer(io.BytesIO(b"\xf0\xf0"))
     self.assertEqual(bc.u_get(3), 0b111)
     self.assertEqual(bc.u_get(2), 0b10)
     self.assertEqual(bc.u_get(1), 0b0)
     self.assertEqual(bc.u_get(5), 0b00111)
     self.assertEqual(bc.u_get(3), 0b100)
     self.assertEqual(bc.u_get(2), 0b00)
Пример #2
0
 def test_fixedbit(self):
     bc = BitConsumer(io.BytesIO(b"\x70\xbb\xc3\xd7\x00"))
     self.assertEqual(bc.fb_get(17), 0.8807220458984375)
     self.assertEqual(bc.fb_get(16), -0.470001220703125)
Пример #3
0
 def test_signed(self):
     bc = BitConsumer(io.BytesIO(b"\x7b\xf8"))
     self.assertEqual(bc.s_get(0), None)
     self.assertEqual(bc.s_get(4), 7)
     self.assertEqual(bc.s_get(10), -258)
Пример #4
0
 def test_no_bits(self):
     bc = BitConsumer(io.BytesIO(b"\x01"))
     self.assertEqual(bc.u_get(0), None)
Пример #5
0
 def test_short_bin(self):
     bc = BitConsumer(io.BytesIO(b"\x01"))
     self.assertEqual(bc.u_get(4), 0)
     self.assertEqual(bc.u_get(4), 1)
Пример #6
0
 def test_exact_limit_next(self):
     bc = BitConsumer(io.BytesIO(b"\xf0\xf0\xf0"))
     v = bc.u_get(17)
     self.assertEqual(v, 0b11110000111100001)
Пример #7
0
 def test_big(self):
     bc = BitConsumer(io.BytesIO(b"\xf0\xf0"))
     v = bc.u_get(12)
     self.assertEqual(v, 0b111100001111)
Пример #8
0
 def test_get_from_left(self):
     bc = BitConsumer(io.BytesIO(b"\xf0"))
     v = bc.u_get(6)
     self.assertEqual(v, 0b111100)
Пример #9
0
 def test_simple(self):
     bc = BitConsumer(io.BytesIO(b"\xff"))
     v = bc.u_get(5)
     self.assertEqual(v, 0x1f)
Пример #10
0
 def test_exact_limit_prev(self):
     bc = BitConsumer(io.BytesIO(b"\xf0\xf0\xf0"))
     v = bc.u_get(15)
     self.assertEqual(v, 0b111100001111000)
Пример #11
0
 def test_get_from_left(self):
     bc = BitConsumer(io.BytesIO(b"\xf0"))
     v = bc.u_get(6)
     self.assertEqual(v, 0b111100)
Пример #12
0
 def test_simple(self):
     bc = BitConsumer(io.BytesIO(b"\xff"))
     v = bc.u_get(5)
     self.assertEqual(v, 0x1f)