def test_encode_decode_int(self): signed_integer_encodings = ( (0, "00"), (127, "7f"), (128, "0080"), (256, "0100"), (-1, "ff"), (-128, "80"), (-129, "ff7f") ) for value, enc in signed_integer_encodings: self.assertEqual(types.encode_int(value).encode("hex"), enc) self.assertEqual(types.decode_int(enc.decode("hex")), value) unsigned_integer_encodings = ( (0, "00"), (127, "7f"), (128, "80"), (256, "0100") ) for value, enc in unsigned_integer_encodings: self.assertEqual( types.encode_int(value, signed=False).encode("hex"), enc) self.assertEqual( types.decode_int(enc.decode("hex"), signed=False), value)
def _encode_value(self): return types.encode_int(self._value - 1)