def __eq__(self, other):
if not isinstance(other, ctypes.Array):
print("Unexpected type. Expected: {0}. Received: {1}".format(ctypes.Array, type(other)))
return False
if len(other) < len(self.expected_string_value) + 1: # +1 for NULL terminating character
print("Unexpected length in C string. Expected at least: {0}. Received {1}".format(len(other), len(self.expected_string_value) + 1))
return False
if not isinstance(other[0], bytes):
print("Unexpected type. Not a string. Received: {0}".format(type(other[0])))
return False
if other.value.decode("ascii") != self.expected_string_value:
print("Unexpected value. Expected {0}. Received: {1}".format(self.expected_string_value, other.value.decode))
return False
return True
# Custom Type
评论列表
文章目录