Skip to content

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

Description

@skinass

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.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions