Documentation ¶
Overview ¶
Package be_reflected provides Be matchers that use reflection, enabling expressive assertions on values' reflect kinds and types. It consists of several "core" matchers e.g. AsKind / AssignableTo / Implementing And many other matchers that are made on-top on core ones. E.g. AsFunc / AsString / AsNumber / etc
Index ¶
- func AsBytes() types.BeMatcher
- func AsChan() types.BeMatcher
- func AsFinalPointer() types.BeMatcher
- func AsFloat() types.BeMatcher
- func AsFloatString() types.BeMatcher
- func AsFunc() types.BeMatcher
- func AsInteger() types.BeMatcher
- func AsIntegerString() types.BeMatcher
- func AsKind(args ...any) types.BeMatcher
- func AsMap() types.BeMatcher
- func AsNumber() types.BeMatcher
- func AsNumericString() types.BeMatcher
- func AsObject() types.BeMatcher
- func AsObjects() types.BeMatcher
- func AsPointer() types.BeMatcher
- func AsPointerToMap() types.BeMatcher
- func AsPointerToObject() types.BeMatcher
- func AsPointerToSlice() types.BeMatcher
- func AsPointerToStruct() types.BeMatcher
- func AsReader() types.BeMatcher
- func AsSlice() types.BeMatcher
- func AsSliceOf[T any]() types.BeMatcher
- func AsString() types.BeMatcher
- func AsStringer() types.BeMatcher
- func AsStruct() types.BeMatcher
- func AssignableTo[T any]() types.BeMatcher
- func Implementing[T any]() types.BeMatcher
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AsFinalPointer ¶
AsFinalPointer succeeds if the actual value is a final pointer, meaning it's a pointer to a non-pointer type.
func AsFloat ¶ added in v0.2.0
AsFloat succeeds if actual is a numeric value that represents a floating-point value.
func AsFloatString ¶ added in v0.2.0
AsFloatString succeeds if actual is a string that can be parsed into a valid floating-point value.
func AsInteger ¶ added in v0.2.0
AsInteger succeeds if actual is a numeric value that represents an integer (from reflect.Int up to reflect.Uint64).
func AsIntegerString ¶ added in v0.2.0
AsIntegerString succeeds if actual is a string that can be parsed into a valid integer value.
func AsKind ¶
AsKind succeeds if actual is assignable to any of the specified kinds or matches the provided matchers.
func AsNumber ¶ added in v0.2.0
AsNumber succeeds if actual is a numeric value, supporting various integer kinds: reflect.Int, ... reflect.Int64, and floating-point kinds: reflect.Float32, reflect.Float64
func AsNumericString ¶
AsNumericString succeeds if actual is a string that can be parsed into a valid numeric value.
func AsObject ¶
AsObject is more specific than AsMap. It checks if the given `actual` value is a map with string keys and values of any type. This is particularly useful in the context of BeJson matcher, where the term 'Object' aligns with JSON notation.
func AsPointerToMap ¶
AsPointerToMap succeeds if actual is a pointer to a map.
func AsPointerToObject ¶
AsPointerToObject succeeds if actual is a pointer to a value that matches AsObject after applying dereference.
func AsPointerToSlice ¶
AsPointerToSlice succeeds if actual is a pointer to a slice.
func AsPointerToStruct ¶
AsPointerToStruct succeeds if actual is a pointer to a struct.
func AsSliceOf ¶
AsSliceOf succeeds if actual is of kind reflect.Slice and each element of the slice is assignable to the specified type T.
func AsStringer ¶
AsStringer succeeds if actual implements the fmt.Stringer interface.
func AssignableTo ¶
AssignableTo succeeds if actual is assignable to the specified type T.
func Implementing ¶
Implementing succeeds if actual implements the specified interface type T.
Types ¶
This section is empty.