Wrong print msg when comparing initialized and uninitialized slice
Opened this issue · 1 comments
samlaf commented
Actual behavior A clear and concise description of what the bug is.
=== RUN TestA
tests/A_test.go:15: Unexpected call to *tests.MockAer.Hello([[]]) at tests/A_test.go:15 because:
expected call at tests/A_test.go:14 doesn't match the argument at index 0.
Got: [] ([][32]uint8)
Want: is equal to [] ([][32]uint8)
Expected behavior
=== RUN TestA
tests/A_test.go:15: Unexpected call to *tests.MockAer.Hello([[]]) at tests/A_test.go:15 because:
expected call at tests/A_test.go:14 doesn't match the argument at index 0.
Got: nil ([][32]uint8)
Want: is equal to [] ([][32]uint8)
To Reproduce Steps to reproduce the behavior
Generate mocks for this interface
type Aer interface {
Hello([][32]byte)
}
Then write this test
func TestA(t *testing.T) {
ctrl := gomock.NewController(t)
mockA := NewMockAer(ctrl)
mockA.EXPECT().Hello([][32]byte{})
mockA.Hello(nil)
}
You will reproduce the above error, which is very confusing. It's showing that Got and Want are the same, even though they actually aren't.
Additional Information
- gomock mode (reflect or source): not sure what this means.
- gomock version or git ref:
go.uber.org/mock v0.2.0
- golang version:
go version go1.20.6 darwin/arm64
deansg commented
Just wanted to mention that a similar issue was opened and not fixed in the archived golang/mock repo:
golang/mock#267
(it was merged into a different issue, whose solution didn't solve the original issue)