diff --git a/README.md b/README.md index f6b91a3..9ee8778 100644 --- a/README.md +++ b/README.md @@ -36,7 +36,7 @@ import ( . "gopkg.in/bluesuncorp/assert.v1" ) -func AssertCustomErrorHandler(t *testing.T, errs map[string]string, key, expected string) { +func AssertCustomErrorHandler(t testing.TB, errs map[string]string, key, expected string) { val, ok := errs[key] // using EqualSkip and NotEqualSkip as building blocks for my custom Assert function diff --git a/assert.go b/assert.go index 9d272d0..d72c912 100644 --- a/assert.go +++ b/assert.go @@ -67,14 +67,14 @@ CASE4: } // Equal validates that val1 is equal to val2 and throws an error with line number -func Equal(t *testing.T, val1, val2 interface{}) { +func Equal(t testing.TB, val1, val2 interface{}) { EqualSkip(t, 2, val1, val2) } // EqualSkip validates that val1 is equal to val2 and throws an error with line number // but the skip variable tells EqualSkip how far back on the stack to report the error. // This is a building block to creating your own more complex validation functions. -func EqualSkip(t *testing.T, skip int, val1, val2 interface{}) { +func EqualSkip(t testing.TB, skip int, val1, val2 interface{}) { if !IsEqual(val1, val2) { _, file, line, _ := runtime.Caller(skip) @@ -84,14 +84,14 @@ func EqualSkip(t *testing.T, skip int, val1, val2 interface{}) { } // NotEqual validates that val1 is not equal val2 and throws an error with line number -func NotEqual(t *testing.T, val1, val2 interface{}) { +func NotEqual(t testing.TB, val1, val2 interface{}) { NotEqualSkip(t, 2, val1, val2) } // NotEqualSkip validates that val1 is not equal to val2 and throws an error with line number // but the skip variable tells NotEqualSkip how far back on the stack to report the error. // This is a building block to creating your own more complex validation functions. -func NotEqualSkip(t *testing.T, skip int, val1, val2 interface{}) { +func NotEqualSkip(t testing.TB, skip int, val1, val2 interface{}) { if IsEqual(val1, val2) { _, file, line, _ := runtime.Caller(skip) @@ -101,14 +101,14 @@ func NotEqualSkip(t *testing.T, skip int, val1, val2 interface{}) { } // PanicMatches validates that the panic output of running fn matches the supplied string -func PanicMatches(t *testing.T, fn func(), matches string) { +func PanicMatches(t testing.TB, fn func(), matches string) { PanicMatchesSkip(t, 2, fn, matches) } // PanicMatchesSkip validates that the panic output of running fn matches the supplied string // but the skip variable tells PanicMatchesSkip how far back on the stack to report the error. // This is a building block to creating your own more complex validation functions. -func PanicMatchesSkip(t *testing.T, skip int, fn func(), matches string) { +func PanicMatchesSkip(t testing.TB, skip int, fn func(), matches string) { _, file, line, _ := runtime.Caller(skip) diff --git a/assert_test.go b/assert_test.go index cd798f5..ebd8d48 100644 --- a/assert_test.go +++ b/assert_test.go @@ -16,7 +16,7 @@ import ( // go test -coverprofile cover.out && go tool cover -html=cover.out -o cover.html // -func MyCustomErrorHandler(t *testing.T, errs map[string]string, key, expected string) { +func MyCustomErrorHandler(t testing.TB, errs map[string]string, key, expected string) { val, ok := errs[key] EqualSkip(t, 2, ok, true) NotEqualSkip(t, 2, val, nil) diff --git a/doc.go b/doc.go index cd71815..f13586c 100644 --- a/doc.go +++ b/doc.go @@ -11,7 +11,7 @@ validations. . "gopkg.in/bluesuncorp/assert.v1" ) - func AssertCustomErrorHandler(t *testing.T, errs map[string]string, key, expected string) { + func AssertCustomErrorHandler(t testing.TB, errs map[string]string, key, expected string) { val, ok := errs[key] // using EqualSkip and NotEqualSkip as building blocks for my custom Assert function