MCPcopy
hub / github.com/expr-lang/expr / Len

Function Len

internal/testify/assert/assertions.go:794–807  ·  view source on GitHub ↗

Len asserts that the specified object has specific length. Len also fails if the object has a type that len() not accept. assert.Len(t, mySlice, 3)

(t TestingT, object interface{}, length int, msgAndArgs ...interface{})

Source from the content-addressed store, hash-verified

792//
793// assert.Len(t, mySlice, 3)
794func Len(t TestingT, object interface{}, length int, msgAndArgs ...interface{}) bool {
795 if h, ok := t.(tHelper); ok {
796 h.Helper()
797 }
798 l, ok := getLen(object)
799 if !ok {
800 return Fail(t, fmt.Sprintf("\"%v\" could not be applied builtin len()", object), msgAndArgs...)
801 }
802
803 if l != length {
804 return Fail(t, fmt.Sprintf("\"%v\" should have %d item(s), but has %d", object, length, l), msgAndArgs...)
805 }
806 return true
807}
808
809// True asserts that the specified value is true.
810//

Callers 9

LenFunction · 0.92
LenfFunction · 0.70
TestLenFunction · 0.70
TestEventuallyWithTFalseFunction · 0.70
TestEventuallyWithTTrueFunction · 0.70
InEpsilonSliceFunction · 0.70
LenMethod · 0.70

Calls 4

getLenFunction · 0.85
SprintfMethod · 0.80
FailFunction · 0.70
HelperMethod · 0.45