コード例 #1
0
 def test_byte_at_raises_error_beyond_data_bounds(self):
     '''
     The byte_at method should raise an IndexError when attempting
     to read a byte beyond the bounds of the BitPack.
     '''
     bp = BitPack(base64.encodestring(b'\x00'))
     with self.assertRaises(IndexError):
         bp.byte_at(1)
コード例 #2
0
 def test_byte_at_happy_path(self):
     '''
     The byte_at method should return a numeric representation of
     the byte at a given index.
     '''
     bp = BitPack(base64.encodestring(b'\x00\x01\x02\x03\xff\xab'))
     self.assertEqual(bp.byte_at(0), 0)
     self.assertEqual(bp.byte_at(1), 1)
     self.assertEqual(bp.byte_at(2), 2)
     self.assertEqual(bp.byte_at(3), 3)
     self.assertEqual(bp.byte_at(4), 0xff)
     self.assertEqual(bp.byte_at(5), 0xab)