impl EqualValues 2 objects have `(T) Equal(T) bool`
Summary
when using EqualValues for 2 objects which are of the same type and implement an (T) Equal(T) bool method, use the method to compare.
Tbh I'd almost put this in Equal, but EqualValues is more correct...
I chose not to implement supporting EqualValues(Foo{1}, &Foo{1}), though I do have a branch with it implemented ...
Motivation
This seems very much inline with many many other languages and makes it much easier to compare custom types, ranging from application level types to decimal.Decimal.
We had to switch to https://github.com/google/go-cmp for the same reason.
We had to switch to https://github.com/google/go-cmp for the same reason.
Do you mean that you integrated google's go-cmp with stretchr, or that you used go-cmp instead. I don't think that go-cmp is a replacement for stretchr.
rebased this old MR, I still think this is a good change! we've been using a fork for years now to have this change...
we use decimal.Decimal extensively and DeepEqual doesn't work well for those because the same decimal can be represented in different ways...
I am firmly against the use of this Equal interface in testify's comparisons because there are examples of existing Equal methods which do not test that the instances are "equal", including in the standard library (see time.Time).
The Equal interface has no relation to the purpose of EqualValues which was to allow people to continue to try to compare types which are not comparable, accepting the false positive and negative matches which occur when you try to do that.
@brackendawson so you might be open for a variant of his with EqualValues interface instead?
No, we will not be changing the logic behind Equal functions any more.