create and use helper for deep equality
This commit is contained in:
@@ -11,12 +11,8 @@ func TestParse(t *testing.T) {
|
||||
assert.Equal(t, error, nil)
|
||||
assert.Equal(t, ctype, "")
|
||||
assert.Equal(t, cscope, "")
|
||||
wantedMessage := []string{}
|
||||
for i := 0; i < len(wantedMessage); i++ {
|
||||
if wantedMessage[i] != cmessage[i] {
|
||||
t.Errorf("messages do not match")
|
||||
}
|
||||
}
|
||||
var wantedMessage []string
|
||||
assert.DeepEqual(t, cmessage, wantedMessage)
|
||||
assert.Equal(t, shouldCommit, false)
|
||||
assert.Equal(t, shouldStage, false)
|
||||
})
|
||||
|
||||
@@ -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