MCPcopy
hub / github.com/stretchr/testify / Len

Function Len

assert/assertions.go:833–846  ·  assert/assertions.go::Len

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

831//
832// assert.Len(t, mySlice, 3)
833func Len(t TestingT, object interface{}, length int, msgAndArgs ...interface{}) bool {
834 if h, ok := t.(tHelper); ok {
835 h.Helper()
836 }
837 l, ok := getLen(object)
838 if !ok {
839 return Fail(t, fmt.Sprintf("\"%v\" could not be applied builtin len()", object), msgAndArgs...)
840 }
841
842 if l != length {
843 return Fail(t, fmt.Sprintf("\"%v\" should have %d item(s), but has %d", object, length, l), msgAndArgs...)
844 }
845 return true
846}
847
848// True asserts that the specified value is true.
849//

Callers 11

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

Calls 3

getLenFunction · 0.85
FailFunction · 0.70
HelperMethod · 0.65