The underlying function ObjectsAreEqualValues did not handle overflow/underflow of values while converting one type to another for comparison. For example:
EqualValues(t, int(270), int8(14))
would return true, even though the values are not equal. Because, when you convert int(270) to int8, it overflows and becomes 14 (270 % 256 = 14)
Changes
This commit fixes that by making sure that the conversion always happens from the smaller type to the larger type, and then comparing the values. Additionally, this commit also separates out the test cases of ObjectsAreEqualValues from TestObjectsAreEqual.
Summary
The underlying function
ObjectsAreEqualValues
did not handle overflow/underflow of values while converting one type to another for comparison. For example:would return
true
, even though the values are not equal. Because, when you convertint(270)
toint8
, it overflows and becomes 14(270 % 256 = 14)
Changes
This commit fixes that by making sure that the conversion always happens from the smaller type to the larger type, and then comparing the values. Additionally, this commit also separates out the test cases of
ObjectsAreEqualValues
fromTestObjectsAreEqual
.Related issues
Closes #1462