create and use helper for deep equality
This commit is contained in:
@@ -1,15 +1,24 @@
|
||||
package assert
|
||||
|
||||
import "testing"
|
||||
import (
|
||||
"testing"
|
||||
"reflect"
|
||||
)
|
||||
|
||||
func Equal[T comparable](t *testing.T, got, want T) {
|
||||
if (got != want) {
|
||||
t.Errorf("not equal %v and %v", got, want)
|
||||
t.Errorf("not equal: %v and %v", got, want)
|
||||
}
|
||||
}
|
||||
|
||||
func NotEqual[T comparable](t *testing.T, got, want T) {
|
||||
if (got == want) {
|
||||
t.Errorf("unexpected equal %v and %v", got, want)
|
||||
t.Errorf("unexpected equal: %v and %v", got, want)
|
||||
}
|
||||
}
|
||||
|
||||
func DeepEqual(t *testing.T, got, want interface{}){
|
||||
if !(reflect.DeepEqual(got,want)) {
|
||||
t.Errorf("unequal deep structure: wanted %v; but got %v", want, got)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user