be_reflected

package
v0.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 21, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package be_reflected offers Be matchers for reflection in Go, enabling expressive and versatile assertions on values' reflect kinds.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AsBytes

func AsBytes() types.BeMatcher

AsBytes succeeds if actual is assignable to a slice of bytes ([]byte).

func AsChan

func AsChan() types.BeMatcher

AsChan succeeds if actual is of kind reflect.Chan.

func AsFinalPointer

func AsFinalPointer() types.BeMatcher

AsFinalPointer succeeds if the actual value is a final pointer, meaning it's a pointer to a non-pointer type.

func AsFloatish

func AsFloatish() types.BeMatcher

AsFloatish succeeds if actual is a numeric value that represents a floating-point value.

func AsFloatishString

func AsFloatishString() types.BeMatcher

AsFloatishString succeeds if actual is a string that can be parsed into a valid floating-point value.

func AsFunc

func AsFunc() types.BeMatcher

AsFunc succeeds if actual is of kind reflect.Func.

func AsIntish

func AsIntish() types.BeMatcher

AsIntish succeeds if actual is a numeric value that represents an integer (from reflect.Int up to reflect.Uint64).

func AsIntishString

func AsIntishString() types.BeMatcher

AsIntishString succeeds if actual is a string that can be parsed into a valid integer value.

func AsKind

func AsKind(args ...any) types.BeMatcher

AsKind succeeds if actual is assignable to any of the specified kinds or matches the provided matchers.

func AsMap

func AsMap() types.BeMatcher

AsMap succeeds if actual is of kind reflect.Map.

func AsNumeric

func AsNumeric() types.BeMatcher

AsNumeric 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

func AsNumericString() types.BeMatcher

AsNumericString succeeds if actual is a string that can be parsed into a valid numeric value.

func AsObject

func AsObject() types.BeMatcher

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 AsObjects

func AsObjects() types.BeMatcher

func AsPointer

func AsPointer() types.BeMatcher

AsPointer succeeds if the actual value is a pointer.

func AsPointerToMap

func AsPointerToMap() types.BeMatcher

AsPointerToMap succeeds if actual is a pointer to a map.

func AsPointerToObject

func AsPointerToObject() types.BeMatcher

AsPointerToObject succeeds if actual is a pointer to a value that matches AsObject after applying dereference.

func AsPointerToSlice

func AsPointerToSlice() types.BeMatcher

AsPointerToSlice succeeds if actual is a pointer to a slice.

func AsPointerToStruct

func AsPointerToStruct() types.BeMatcher

AsPointerToStruct succeeds if actual is a pointer to a struct.

func AsReader

func AsReader() types.BeMatcher

AsReader succeeds if actual implements the io.Reader interface.

func AsSlice

func AsSlice() types.BeMatcher

AsSlice succeeds if actual is of kind reflect.Slice.

func AsSliceOf

func AsSliceOf[T any]() types.BeMatcher

AsSliceOf succeeds if actual is of kind reflect.Slice and each element of the slice is assignable to the specified type T.

func AsString

func AsString() types.BeMatcher

AsString succeeds if actual is of kind reflect.String.

func AsStringer

func AsStringer() types.BeMatcher

AsStringer succeeds if actual implements the fmt.Stringer interface.

func AsStruct

func AsStruct() types.BeMatcher

AsStruct succeeds if actual is of kind reflect.Struct.

func AssignableTo

func AssignableTo[T any]() types.BeMatcher

AssignableTo succeeds if actual is assignable to the specified type T.

func Implementing

func Implementing[T any]() types.BeMatcher

Implementing succeeds if actual implements the specified interface type T.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL