feat: add length equal

This commit is contained in:
debugtalk
2021-10-03 21:52:47 +08:00
parent cb0e450f18
commit a221afb51d
4 changed files with 71 additions and 13 deletions

View File

@@ -1,6 +1,8 @@
package builtin
import "github.com/stretchr/testify/assert"
import (
"github.com/stretchr/testify/assert"
)
var Assertions = map[string]func(t assert.TestingT, expected interface{}, actual interface{}, msgAndArgs ...interface{}) bool{
"equals": assert.EqualValues,
@@ -12,4 +14,11 @@ var Assertions = map[string]func(t assert.TestingT, expected interface{}, actual
"not_equal": assert.NotEqual,
"contains": assert.Contains,
"regex_match": assert.Regexp,
// custom assertions
"length_equals": EqualLength,
"length_equal": EqualLength, // alias for length_equals
}
func EqualLength(t assert.TestingT, expected, actual interface{}, msgAndArgs ...interface{}) bool {
return assert.Len(t, actual, expected.(int), msgAndArgs...)
}