ObjectsAreEqual: improve list/map support
Summary
Function ObjectsAreEqual now compares two objects of type array/slice/map by iterating over each element. When two objects contain the same value but have different types, the function will now return true.
Changes
- The function
ObjectsAreEqualValuesinassertion.gois changed. - Two helper functions
listsAreEqualValuesandmapsAreEqualValuesare added. - Tests are added accordingly.
Motivation
Currently, assert.EqualValues would fail when two objects are of type array/slice/map and contain values of different types.
// assert would fail
assert.EqualValues(t, []interface{}{1}, []interface{}{int64(1)})
But, assert.EqualValues should always compare objects by value. So the above code should idealy pass.
Related issues
Closes #1057
Hi @harryzcy,
Thanks for your fix. Do you have any idea when this fix will be released?
Hi @harryzcy,
Thanks for your fix. Do you have any idea when this fix will be released?
No, I don't know when maintainers will review them.