Ejemplo n.º 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)
Ejemplo n.º 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)
Ejemplo n.º 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)
Ejemplo n.º 4
0
 def test_no_bits(self):
     bc = BitConsumer(io.BytesIO(b"\x01"))
     self.assertEqual(bc.u_get(0), None)
Ejemplo n.º 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)
Ejemplo n.º 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)
Ejemplo n.º 7
0
 def test_big(self):
     bc = BitConsumer(io.BytesIO(b"\xf0\xf0"))
     v = bc.u_get(12)
     self.assertEqual(v, 0b111100001111)
Ejemplo n.º 8
0
 def test_get_from_left(self):
     bc = BitConsumer(io.BytesIO(b"\xf0"))
     v = bc.u_get(6)
     self.assertEqual(v, 0b111100)
Ejemplo n.º 9
0
 def test_simple(self):
     bc = BitConsumer(io.BytesIO(b"\xff"))
     v = bc.u_get(5)
     self.assertEqual(v, 0x1f)
Ejemplo n.º 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)
Ejemplo n.º 11
0
 def test_get_from_left(self):
     bc = BitConsumer(io.BytesIO(b"\xf0"))
     v = bc.u_get(6)
     self.assertEqual(v, 0b111100)
Ejemplo n.º 12
0
 def test_simple(self):
     bc = BitConsumer(io.BytesIO(b"\xff"))
     v = bc.u_get(5)
     self.assertEqual(v, 0x1f)