mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-13 05:02:50 +00:00
Make semantic deep equal public feature
* Use semantic deep equal when validating * More test cases for deep equal
This commit is contained in:
@@ -22,15 +22,28 @@ import (
|
||||
|
||||
func TestEqualities(t *testing.T) {
|
||||
e := Equalities{}
|
||||
type Bar struct {
|
||||
X int
|
||||
}
|
||||
type Baz struct {
|
||||
Y Bar
|
||||
}
|
||||
err := e.AddFuncs(
|
||||
func(a, b int) bool {
|
||||
return a+1 == b
|
||||
},
|
||||
func(a, b Bar) bool {
|
||||
return a.X*10 == b.X
|
||||
},
|
||||
)
|
||||
if err != nil {
|
||||
t.Fatalf("Unexpected: %v", err)
|
||||
}
|
||||
|
||||
type Foo struct {
|
||||
X int
|
||||
}
|
||||
|
||||
table := []struct {
|
||||
a, b interface{}
|
||||
equal bool
|
||||
@@ -38,6 +51,10 @@ func TestEqualities(t *testing.T) {
|
||||
{1, 2, true},
|
||||
{2, 1, false},
|
||||
{"foo", "foo", true},
|
||||
{Foo{1}, Foo{2}, true},
|
||||
{Bar{1}, Bar{10}, true},
|
||||
{&Bar{1}, &Bar{10}, true},
|
||||
{Baz{Bar{1}}, Baz{Bar{10}}, true},
|
||||
{map[string]int{"foo": 1}, map[string]int{"foo": 2}, true},
|
||||
{map[string]int{}, map[string]int(nil), true},
|
||||
{[]int{}, []int(nil), true},
|
||||
|
Reference in New Issue
Block a user