Esempio n. 1
0
 def Byte(value=None):
     '''
     Match or read a byte (if a value is given, it must match).
     '''
     if value is None:
         return BEnd(8)
     else:
         return _Constant(BitString.from_byte(value))
Esempio n. 2
0
 def Byte(value=None):
     '''
     Match or read a byte (if a value is given, it must match).
     '''
     if value is None:
         return BEnd(8)
     else:
         return _Constant(BitString.from_byte(value))
Esempio n. 3
0
 def test_from_byte(self):
     self.assert_error(lambda: BitString.from_byte(-1))
     self.assert_length_value(8, b'\x00', BitString.from_byte(0))
     self.assert_length_value(8, b'\x01', BitString.from_byte(1))
     self.assert_length_value(8, b'\xff', BitString.from_byte(255))
     self.assert_error(lambda: BitString.from_byte(256))
Esempio n. 4
0
 def test_from_byte(self):
     self.assert_error(lambda: BitString.from_byte(-1))
     self.assert_length_value(8, b'\x00', BitString.from_byte(0))
     self.assert_length_value(8, b'\x01', BitString.from_byte(1))
     self.assert_length_value(8, b'\xff', BitString.from_byte(255))
     self.assert_error(lambda: BitString.from_byte(256))