Skip to content

Commit 9a0c242

Browse files
authored
Merge pull request #154 from lmb/cmp-equal-bad-checkf
Turn a panicking cmp.Diff into a bad check
2 parents 6a0f8ad + 636ce19 commit 9a0c242

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

checker.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ func (c *cmpEqualsChecker) Check(got interface{}, args []interface{}, note func(
131131
// structs with unexported fields and neither AllowUnexported nor
132132
// cmpopts.IgnoreUnexported are provided.
133133
if r := recover(); r != nil {
134-
err = fmt.Errorf("%s", r)
134+
err = BadCheckf("%s", r)
135135
}
136136
}()
137137
want := args[0]

checker_test.go

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -538,13 +538,15 @@ want:
538538
},
539539
expectedCheckFailure: `
540540
error:
541-
cannot handle unexported field at root.answer:
541+
bad check: cannot handle unexported field at root.answer:
542+
"github.com/frankban/quicktest_test".(struct { answer int })
543+
consider using a custom Comparer; if you control the implementation of type, you can also consider using an Exporter, AllowUnexported, or cmpopts.IgnoreUnexported
544+
`,
545+
expectedNegateFailure: `
546+
error:
547+
bad check: cannot handle unexported field at root.answer:
542548
"github.com/frankban/quicktest_test".(struct { answer int })
543549
consider using a custom Comparer; if you control the implementation of type, you can also consider using an Exporter, AllowUnexported, or cmpopts.IgnoreUnexported
544-
got:
545-
struct { answer int }{answer:42}
546-
want:
547-
<same as "got">
548550
`,
549551
}, {
550552
about: "CmpEquals: structs with unexported fields ignored",

0 commit comments

Comments
 (0)