Add Cmp
This commit is contained in:
parent
d20ac9444a
commit
5f6f4dd047
3 changed files with 19 additions and 0 deletions
11
assert.go
11
assert.go
|
@ -3,6 +3,8 @@ package assert
|
|||
import (
|
||||
"reflect"
|
||||
"runtime"
|
||||
|
||||
"github.com/google/go-cmp/cmp"
|
||||
)
|
||||
|
||||
// Assert is a helper for tests
|
||||
|
@ -167,3 +169,12 @@ func (a Assert) SameElements(expected, actual interface{}, msg ...interface{}) {
|
|||
|
||||
a(false, msg...)
|
||||
}
|
||||
|
||||
func (a Assert) Cmp(expected, actual interface{}, opts ...cmp.Option) {
|
||||
diff := cmp.Diff(expected, actual, opts...)
|
||||
if diff == `` {
|
||||
return
|
||||
}
|
||||
|
||||
a(false, "\n"+diff)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue