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

Function isEmptyValue

assert/assertions.go:760–775  ·  view source on GitHub ↗

isEmptyValue gets whether the specified reflect.Value is considered empty or not.

(objValue reflect.Value)

Source from the content-addressed store, hash-verified

758
759// isEmptyValue gets whether the specified reflect.Value is considered empty or not.
760func isEmptyValue(objValue reflect.Value) bool {
761 if objValue.IsZero() {
762 return true
763 }
764 // Special cases of non-zero values that we consider empty
765 switch objValue.Kind() {
766 // collection types are empty when they have no element
767 // Note: array types are empty when they match their zero-initialized state.
768 case reflect.Chan, reflect.Map, reflect.Slice:
769 return objValue.Len() == 0
770 // non-nil pointers are empty if the value they point to is empty
771 case reflect.Ptr:
772 return isEmptyValue(objValue.Elem())
773 }
774 return false
775}
776
777// Empty asserts that the given value is "empty".
778//

Callers 1

isEmptyFunction · 0.85

Calls 1

LenMethod · 0.45

Tested by

no test coverage detected