This commit is contained in:
lufia 2020-02-07 15:00:23 +09:00
Родитель 2cff4c2adc
Коммит 5918d1c6db
2 изменённых файлов: 38 добавлений и 0 удалений

1
go.sum
Просмотреть файл

@ -4,6 +4,7 @@ github.com/atotto/clipboard v0.0.0-20171229224153-bc5958e1c833 h1:h/E5ryZTJAtOY6
github.com/atotto/clipboard v0.0.0-20171229224153-bc5958e1c833/go.mod h1:ZY9tmq7sm5xIbd9bOK4onWV4S6X0u6GY7Vn0Yu86PYI=
github.com/bmizerany/assert v0.0.0-20160611221934-b7ed37b82869 h1:DDGfHa7BWjL4YnC6+E63dPcxHo2sUxDIu8g3QgEJdRY=
github.com/bmizerany/assert v0.0.0-20160611221934-b7ed37b82869/go.mod h1:Ekp36dRnpXw/yCqJaO+ZrUyxD+3VXMFFr56k5XYrpB4=
github.com/google/go-cmp v0.4.0 h1:xsAVV57WRhGj6kEIi8ReJzQlHHqcBYCElAvkovg3B/4=
github.com/kballard/go-shellquote v0.0.0-20170619183022-cd60e84ee657 h1:vE7J1m7cCpiRVEIr1B5ccDxRpbPsWT5JU3if2Di5nE4=
github.com/kballard/go-shellquote v0.0.0-20170619183022-cd60e84ee657/go.mod h1:CzGEWj7cYgsdH8dAjBGEr58BoE7ScuLd+fwFZ44+/x8=
github.com/kr/pretty v0.0.0-20160823170715-cfb55aafdaf3 h1:dhwb1Ev84SKKVBfLuhR4bw/29yYHzwtTyTLUWWnvYxI=

37
internal/assert/assert.go Normal file
Просмотреть файл

@ -0,0 +1,37 @@
// Package assert provides functions for testing.
package assert
import (
"fmt"
"reflect"
"testing"
"github.com/google/go-cmp/cmp"
)
// Equal makes the test as failed using default formatting if got is not equal to want.
func Equal(t testing.TB, want, got interface{}, args ...interface{}) {
t.Helper()
if !reflect.DeepEqual(want, got) {
msg := fmt.Sprint(args...)
t.Errorf("%s\n%s", msg, cmp.Diff(want, got))
}
}
// NotEqual makes the test as failed using default formatting if got is equal to want.
func NotEqual(t testing.TB, want, got interface{}, args ...interface{}) {
t.Helper()
if reflect.DeepEqual(want, got) {
msg := fmt.Sprint(args...)
t.Errorf("%s\nUnexpected: <%#v>", msg, want)
}
}
// T makes the test as failed using default formatting if ok is false.
func T(t testing.TB, ok bool, args ...interface{}) {
t.Helper()
if !ok {
msg := fmt.Sprint(args...)
t.Errorf("%s\nFailure", msg)
}
}