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, error, nil)
|
||||||
assert.Equal(t, ctype, "")
|
assert.Equal(t, ctype, "")
|
||||||
assert.Equal(t, cscope, "")
|
assert.Equal(t, cscope, "")
|
||||||
wantedMessage := []string{}
|
var wantedMessage []string
|
||||||
for i := 0; i < len(wantedMessage); i++ {
|
assert.DeepEqual(t, cmessage, wantedMessage)
|
||||||
if wantedMessage[i] != cmessage[i] {
|
|
||||||
t.Errorf("messages do not match")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
assert.Equal(t, shouldCommit, false)
|
assert.Equal(t, shouldCommit, false)
|
||||||
assert.Equal(t, shouldStage, false)
|
assert.Equal(t, shouldStage, false)
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -1,15 +1,24 @@
|
|||||||
package assert
|
package assert
|
||||||
|
|
||||||
import "testing"
|
import (
|
||||||
|
"testing"
|
||||||
|
"reflect"
|
||||||
|
)
|
||||||
|
|
||||||
func Equal[T comparable](t *testing.T, got, want T) {
|
func Equal[T comparable](t *testing.T, got, want T) {
|
||||||
if (got != want) {
|
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) {
|
func NotEqual[T comparable](t *testing.T, got, want T) {
|
||||||
if (got == want) {
|
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