Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wrong comparison for slices types with Equal() method #32

Open
skinass opened this issue Aug 2, 2019 · 1 comment
Open

wrong comparison for slices types with Equal() method #32

skinass opened this issue Aug 2, 2019 · 1 comment

Comments

@skinass
Copy link

skinass commented Aug 2, 2019

in commit 929fce9 the check of Equal() function was moved under the reflect.Struct case.
and here is an example why this is wrong:
https://play.golang.org/p/AlgXufFrO1g

package main

import (
	"fmt"
	"net"
	"github.com/go-test/deep"
)

func main() {
	ipA := net.ParseIP("1.2.3.4")
	ipB := net.ParseIP("1.2.3.4").To4()
	
	fmt.Println(deep.Equal(ipA, ipB))
	
	fmt.Println(ipA.Equal(ipB))
}

ipA and ipB has different len of their slice inside, but they still represents the same ip. however deep.Equal() say there is a diff between ipA and ipB.

not only structs may have an Equal() method.

@skinass skinass changed the title wrong comparision for slices types with Equal() method wrong comparison for slices types with Equal() method Aug 2, 2019
@daniel-nichter
Copy link
Member

Thanks for the bug report. I'll see if/how to generalize the test for an Equal method to cover all such cases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants