Example #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)
Example #2
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)
Example #3
0
 def test_no_bits(self):
     bc = BitConsumer(io.BytesIO(b"\x01"))
     self.assertEqual(bc.u_get(0), None)
Example #4
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)
Example #5
0
 def test_big(self):
     bc = BitConsumer(io.BytesIO(b"\xf0\xf0"))
     v = bc.u_get(12)
     self.assertEqual(v, 0b111100001111)
Example #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)
Example #7
0
 def test_get_from_left(self):
     bc = BitConsumer(io.BytesIO(b"\xf0"))
     v = bc.u_get(6)
     self.assertEqual(v, 0b111100)
Example #8
0
 def test_simple(self):
     bc = BitConsumer(io.BytesIO(b"\xff"))
     v = bc.u_get(5)
     self.assertEqual(v, 0x1f)
Example #9
0
 def test_no_bits(self):
     bc = BitConsumer(io.BytesIO(b"\x01"))
     self.assertEqual(bc.u_get(0), None)
Example #10
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)
Example #11
0
 def test_big(self):
     bc = BitConsumer(io.BytesIO(b"\xf0\xf0"))
     v = bc.u_get(12)
     self.assertEqual(v, 0b111100001111)
Example #12
0
 def test_exact_limit_next(self):
     bc = BitConsumer(io.BytesIO(b"\xf0\xf0\xf0"))
     v = bc.u_get(17)
     self.assertEqual(v, 0b11110000111100001)
Example #13
0
 def test_get_from_left(self):
     bc = BitConsumer(io.BytesIO(b"\xf0"))
     v = bc.u_get(6)
     self.assertEqual(v, 0b111100)
Example #14
0
 def test_simple(self):
     bc = BitConsumer(io.BytesIO(b"\xff"))
     v = bc.u_get(5)
     self.assertEqual(v, 0x1f)