goconvey
goconvey copied to clipboard
Make ShouldEqual work for slices
There's no point whatsoever in comparing slices by pointers, and it's very strange to see test results like this:

GoConvey can type assert and, if both sides are slices, compare them like ShouldResemble.
ShouldEqual is meant to correspond exactly to the behavior of ==. Sometimes you do actually want to compare the identity of container objects (say you had an algorithm which operated on a slice of slices, and you wanted to verify that it picked exactly the right one).
I do agree, however, that the error message in this case is confusing; It should report the addresses of the two objects in question in addition to their contents.
You can't compare slices in Go with ==. Even if you compare pointers, the results aren't so unambiguous:
https://play.golang.org/p/Wq5Hs1z13qM
You can see that slices a and a[:1] seem to be equal, but they're different, despite the fact that they share their underlying array.
We should refer to reflect.DeepEqual, why not?
If we want to compare two object's address equal, we should add a new OP like 'ShouldAddrEqual' ?