MCPcopy
hub / github.com/istio/istio / Compare

Function Compare

pkg/test/util/assert/assert.go:76–81  ·  view source on GitHub ↗

Compare compares two objects and returns and error if they are not the same.

(a, b T)

Source from the content-addressed store, hash-verified

74
75// Compare compares two objects and returns and error if they are not the same.
76func Compare[T any](a, b T) error {
77 if !cmp.Equal(a, b, opts(a)...) {
78 return fmt.Errorf("found diff: %v\nLeft: %v\nRight: %v", cmp.Diff(a, b, opts(a)...), a, b)
79 }
80 return nil
81}
82
83// Equal compares two objects and fails if they are not the same.
84func Equal[T any](t test.Failer, a, b T, context ...string) {

Callers 5

TestGenerateOptionsFunction · 0.92
TestLocalityFunction · 0.92

Calls 4

optsFunction · 0.85
EqualMethod · 0.65
ErrorfMethod · 0.65
DiffMethod · 0.45

Tested by 5

TestGenerateOptionsFunction · 0.74
TestLocalityFunction · 0.74

Used in the wild real call sites across dependent graphs

searching dependent graphs…