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

Function TestObjectsAreEqualValues

assert/assertions_test.go:139–175  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

137}
138
139func TestObjectsAreEqualValues(t *testing.T) {
140 t.Parallel()
141
142 now := time.Now()
143
144 cases := []struct {
145 expected interface{}
146 actual interface{}
147 result bool
148 }{
149 {uint32(10), int32(10), true},
150 {0, nil, false},
151 {nil, 0, false},
152 {now, now.In(time.Local), false}, // should not be time zone independent
153 {int(270), int8(14), false}, // should handle overflow/underflow
154 {int8(14), int(270), false},
155 {[]int{270, 270}, []int8{14, 14}, false},
156 {complex128(1e+100 + 1e+100i), complex64(complex(math.Inf(0), math.Inf(0))), false},
157 {complex64(complex(math.Inf(0), math.Inf(0))), complex128(1e+100 + 1e+100i), false},
158 {complex128(1e+100 + 1e+100i), 270, false},
159 {270, complex128(1e+100 + 1e+100i), false},
160 {complex128(1e+100 + 1e+100i), 3.14, false},
161 {3.14, complex128(1e+100 + 1e+100i), false},
162 {complex128(1e+10 + 1e+10i), complex64(1e+10 + 1e+10i), true},
163 {complex64(1e+10 + 1e+10i), complex128(1e+10 + 1e+10i), true},
164 }
165
166 for _, c := range cases {
167 t.Run(fmt.Sprintf("ObjectsAreEqualValues(%#v, %#v)", c.expected, c.actual), func(t *testing.T) {
168 res := ObjectsAreEqualValues(c.expected, c.actual)
169
170 if res != c.result {
171 t.Errorf("ObjectsAreEqualValues(%#v, %#v) should return %#v", c.expected, c.actual, c.result)
172 }
173 })
174 }
175}
176
177type Nested struct {
178 Exported interface{}

Callers

nothing calls this directly

Calls 3

ObjectsAreEqualValuesFunction · 0.85
ErrorfMethod · 0.65
RunMethod · 0.45

Tested by

no test coverage detected