MCPcopy Index your code
hub / github.com/expr-lang/expr / TestEqual

Function TestEqual

internal/testify/assert/assertions_test.go:517–556  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

515}
516
517func TestEqual(t *testing.T) {
518 type myType string
519
520 mockT := new(testing.T)
521 var m map[string]interface{}
522
523 cases := []struct {
524 expected interface{}
525 actual interface{}
526 result bool
527 remark string
528 }{
529 {"Hello World", "Hello World", true, ""},
530 {123, 123, true, ""},
531 {123.5, 123.5, true, ""},
532 {[]byte("Hello World"), []byte("Hello World"), true, ""},
533 {nil, nil, true, ""},
534 {int32(123), int32(123), true, ""},
535 {uint64(123), uint64(123), true, ""},
536 {myType("1"), myType("1"), true, ""},
537 {&struct{}{}, &struct{}{}, true, "pointer equality is based on equality of underlying value"},
538
539 // Not expected to be equal
540 {m["bar"], "something", false, ""},
541 {myType("1"), myType("2"), false, ""},
542
543 // A case that might be confusing, especially with numeric literals
544 {10, uint(10), false, ""},
545 }
546
547 for _, c := range cases {
548 t.Run(fmt.Sprintf("Equal(%#v, %#v)", c.expected, c.actual), func(t *testing.T) {
549 res := Equal(mockT, c.expected, c.actual)
550
551 if res != c.result {
552 t.Errorf("Equal(%#v, %#v) should return %#v: %s", c.expected, c.actual, c.result, c.remark)
553 }
554 })
555 }
556}
557
558func ptr(i int) *int {
559 return &i

Callers

nothing calls this directly

Calls 5

myTypeTypeAlias · 0.85
RunMethod · 0.80
SprintfMethod · 0.80
EqualFunction · 0.70
ErrorfMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…