Add Cmp
This commit is contained in:
parent
d20ac9444a
commit
5f6f4dd047
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)
|
||||
}
|
||||
|
5
go.mod
Normal file
5
go.mod
Normal file
@ -0,0 +1,5 @@
|
||||
module git.fuyu.moe/Fuyu/assert
|
||||
|
||||
go 1.14
|
||||
|
||||
require github.com/google/go-cmp v0.4.0
|
3
go.sum
Normal file
3
go.sum
Normal file
@ -0,0 +1,3 @@
|
||||
github.com/google/go-cmp v0.4.0 h1:xsAVV57WRhGj6kEIi8ReJzQlHHqcBYCElAvkovg3B/4=
|
||||
github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
Loading…
Reference in New Issue
Block a user