diff --git a/assert.go b/assert.go index 7d5f90e..1a3166b 100644 --- a/assert.go +++ b/assert.go @@ -3,14 +3,13 @@ package assert import ( "reflect" "runtime" - "testing" ) // Assert is a helper for tests type Assert func(bool, ...interface{}) // New returns a new Assert -func New(t *testing.T) Assert { +func New(t T) Assert { a := func(ok bool, msg ...interface{}) { if !ok { if msg == nil { diff --git a/helper.go b/helper.go index 67cc4a9..e94190b 100644 --- a/helper.go +++ b/helper.go @@ -5,7 +5,6 @@ import ( "reflect" "runtime" "strconv" - "testing" ) func prepMsg(msg []interface{}, format string, args ...interface{}) []interface{} { @@ -16,9 +15,9 @@ func shell(i int) string { return "\x1B[" + strconv.Itoa(i) + "m" } -var ts = map[*runtime.Func]*testing.T{} +var ts = map[*runtime.Func]T{} -func t(a Assert) *testing.T { +func t(a Assert) T { f := runtime.FuncForPC(reflect.ValueOf(a).Pointer()) return ts[f] } diff --git a/type.go b/type.go new file mode 100644 index 0000000..1c9a1fd --- /dev/null +++ b/type.go @@ -0,0 +1,7 @@ +package assert + +// T is an interface of what we use from testing.T +type T interface { + Error(...interface{}) + Helper() +}