Skip to content

Commit 655ae17

Browse files
author
Dean Karn
authored
Merge pull request #10 from go-playground/v2-development
merge dev changes
2 parents 8eb943f + 7f9e3f3 commit 655ae17

File tree

4 files changed

+9
-9
lines changed

4 files changed

+9
-9
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ import (
3232
. "github.com/go-playground/assert/v2"
3333
)
3434

35-
func AssertCustomErrorHandler(t *testing.T, errs map[string]string, key, expected string) {
35+
func AssertCustomErrorHandler(t testing.TB, errs map[string]string, key, expected string) {
3636
val, ok := errs[key]
3737

3838
// using EqualSkip and NotEqualSkip as building blocks for my custom Assert function

assert.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -134,14 +134,14 @@ func regexMatches(regex interface{}, value string) (*regexp.Regexp, bool, error)
134134
}
135135

136136
// Equal validates that val1 is equal to val2 and throws an error with line number
137-
func Equal(t *testing.T, val1, val2 interface{}) {
137+
func Equal(t testing.TB, val1, val2 interface{}) {
138138
EqualSkip(t, 2, val1, val2)
139139
}
140140

141141
// EqualSkip validates that val1 is equal to val2 and throws an error with line number
142142
// but the skip variable tells EqualSkip how far back on the stack to report the error.
143143
// This is a building block to creating your own more complex validation functions.
144-
func EqualSkip(t *testing.T, skip int, val1, val2 interface{}) {
144+
func EqualSkip(t testing.TB, skip int, val1, val2 interface{}) {
145145

146146
if !IsEqual(val1, val2) {
147147
_, file, line, _ := runtime.Caller(skip)
@@ -151,14 +151,14 @@ func EqualSkip(t *testing.T, skip int, val1, val2 interface{}) {
151151
}
152152

153153
// NotEqual validates that val1 is not equal val2 and throws an error with line number
154-
func NotEqual(t *testing.T, val1, val2 interface{}) {
154+
func NotEqual(t testing.TB, val1, val2 interface{}) {
155155
NotEqualSkip(t, 2, val1, val2)
156156
}
157157

158158
// NotEqualSkip validates that val1 is not equal to val2 and throws an error with line number
159159
// but the skip variable tells NotEqualSkip how far back on the stack to report the error.
160160
// This is a building block to creating your own more complex validation functions.
161-
func NotEqualSkip(t *testing.T, skip int, val1, val2 interface{}) {
161+
func NotEqualSkip(t testing.TB, skip int, val1, val2 interface{}) {
162162

163163
if IsEqual(val1, val2) {
164164
_, file, line, _ := runtime.Caller(skip)
@@ -168,14 +168,14 @@ func NotEqualSkip(t *testing.T, skip int, val1, val2 interface{}) {
168168
}
169169

170170
// PanicMatches validates that the panic output of running fn matches the supplied string
171-
func PanicMatches(t *testing.T, fn func(), matches string) {
171+
func PanicMatches(t testing.TB, fn func(), matches string) {
172172
PanicMatchesSkip(t, 2, fn, matches)
173173
}
174174

175175
// PanicMatchesSkip validates that the panic output of running fn matches the supplied string
176176
// but the skip variable tells PanicMatchesSkip how far back on the stack to report the error.
177177
// This is a building block to creating your own more complex validation functions.
178-
func PanicMatchesSkip(t *testing.T, skip int, fn func(), matches string) {
178+
func PanicMatchesSkip(t testing.TB, skip int, fn func(), matches string) {
179179

180180
_, file, line, _ := runtime.Caller(skip)
181181

assert_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import (
1616
// go test -coverprofile cover.out && go tool cover -html=cover.out -o cover.html
1717
//
1818

19-
func MyCustomErrorHandler(t *testing.T, errs map[string]string, key, expected string) {
19+
func MyCustomErrorHandler(t testing.TB, errs map[string]string, key, expected string) {
2020
val, ok := errs[key]
2121
EqualSkip(t, 2, ok, true)
2222
NotEqualSkip(t, 2, val, nil)

doc.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ validations.
1111
. "github.com/go-playground/assert.v1"
1212
)
1313
14-
func AssertCustomErrorHandler(t *testing.T, errs map[string]string, key, expected string) {
14+
func AssertCustomErrorHandler(t testing.TB, errs map[string]string, key, expected string) {
1515
val, ok := errs[key]
1616
1717
// using EqualSkip and NotEqualSkip as building blocks for my custom Assert function

0 commit comments

Comments
 (0)