Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 6 additions & 6 deletions assert.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion assert_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down