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

Function getLen

assert/assertions.go:821–827  ·  view source on GitHub ↗

getLen tries to get the length of an object. It returns (0, false) if impossible.

(x interface{})

Source from the content-addressed store, hash-verified

819// getLen tries to get the length of an object.
820// It returns (0, false) if impossible.
821func getLen(x interface{}) (length int, ok bool) {
822 v := reflect.ValueOf(x)
823 defer func() {
824 ok = recover() == nil
825 }()
826 return v.Len(), true
827}
828
829// Len asserts that the specified object has specific length.
830// Len also fails if the object has a type that len() not accept.

Callers 2

Test_getLenFunction · 0.85
LenFunction · 0.85

Calls 1

LenMethod · 0.45

Tested by 1

Test_getLenFunction · 0.68