diff options
| author | Stefan Majewsky <majewsky@gmx.net> | 2026-06-20 21:32:49 +0200 |
|---|---|---|
| committer | Stefan Majewsky <majewsky@gmx.net> | 2026-06-20 21:32:49 +0200 |
| commit | eb839b45b1da29038500ee6ae52526cbc854c6a1 (patch) | |
| tree | 016117a9420a946a2d52f5af90ae79a12b3f656d /assert/errequal_test.go | |
| parent | f244daebd51216265669ff38143d1ff1fb9cb293 (diff) | |
| download | go-gg-eb839b45b1da29038500ee6ae52526cbc854c6a1.tar.gz | |
assert: fix crash in ErrEqual on expected being a struct kind value
Diffstat (limited to 'assert/errequal_test.go')
| -rw-r--r-- | assert/errequal_test.go | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/assert/errequal_test.go b/assert/errequal_test.go index 5efbdc5..4bb9080 100644 --- a/assert/errequal_test.go +++ b/assert/errequal_test.go @@ -74,4 +74,18 @@ func TestErrEqual(t *testing.T) { Outcome: testcapture.OutcomePanicked, Panic: "cannot handle `expected` of type int", }) + + // an earlier version had a bug because this call caused reflect.Value.IsNil() to be called on a value of kind Struct + expectErrors(t, func(t assert.TestingTB) { + assert.ErrEqual(t, nil, structTypedError{"foo"}) + }, `expected "foo", but got no error`) +} + +type structTypedError struct { + Message string +} + +// Error implements the builtin/error interface. +func (e structTypedError) Error() string { + return e.Message } |
