MCPcopy
hub / github.com/stretchr/testify / TestEqualValuesAndNotEqualValues

Function TestEqualValuesAndNotEqualValues

assert/assertions_test.go:981–1035  ·  assert/assertions_test.go::TestEqualValuesAndNotEqualValues
(t *testing.T)

Source from the content-addressed store, hash-verified

979}
980
981func TestEqualValuesAndNotEqualValues(t *testing.T) {
982 t.Parallel()
983
984 mockT := new(testing.T)
985
986 cases := []struct {
987 expected interface{}
988 actual interface{}
989 notEqualResult bool // result for NotEqualValues
990 }{
991 // cases that are expected not to match
992 {"Hello World", "Hello World!", true},
993 {123, 1234, true},
994 {123.5, 123.55, true},
995 {[]byte("Hello World"), []byte("Hello World!"), true},
996 {nil, new(AssertionTesterConformingObject), true},
997
998 // cases that are expected to match
999 {nil, nil, false},
1000 {"Hello World", "Hello World", false},
1001 {123, 123, false},
1002 {123.5, 123.5, false},
1003 {[]byte("Hello World"), []byte("Hello World"), false},
1004 {new(AssertionTesterConformingObject), new(AssertionTesterConformingObject), false},
1005 {&struct{}{}, &struct{}{}, false},
1006
1007 // Different behavior from NotEqual()
1008 {func() int { return 23 }, func() int { return 24 }, true},
1009 {int(10), int(11), true},
1010 {int(10), uint(10), false},
1011
1012 {struct{}{}, struct{}{}, false},
1013 }
1014
1015 for _, c := range cases {
1016 // Test NotEqualValues
1017 t.Run(fmt.Sprintf("NotEqualValues(%#v, %#v)", c.expected, c.actual), func(t *testing.T) {
1018 res := NotEqualValues(mockT, c.expected, c.actual)
1019
1020 if res != c.notEqualResult {
1021 t.Errorf("NotEqualValues(%#v, %#v) should return %#v", c.expected, c.actual, c.notEqualResult)
1022 }
1023 })
1024
1025 // Test EqualValues (inverse of NotEqualValues)
1026 t.Run(fmt.Sprintf("EqualValues(%#v, %#v)", c.expected, c.actual), func(t *testing.T) {
1027 expectedEqualResult := !c.notEqualResult // EqualValues should return opposite of NotEqualValues
1028 res := EqualValues(mockT, c.expected, c.actual)
1029
1030 if res != expectedEqualResult {
1031 t.Errorf("EqualValues(%#v, %#v) should return %#v", c.expected, c.actual, expectedEqualResult)
1032 }
1033 })
1034 }
1035}
1036
1037func TestContainsNotContains(t *testing.T) {
1038 t.Parallel()

Callers

nothing calls this directly

Calls 4

NotEqualValuesFunction · 0.70
EqualValuesFunction · 0.70
ErrorfMethod · 0.65
RunMethod · 0.45

Tested by

no test coverage detected