Documentation
¶
Overview ¶
Package knownvalue contains the known value interface, and types implementing the known value interface.
Index ¶
- func Bool(value bool) boolValue
- func Float32Exact(value float32) float32Exact
- func Float64Exact(value float64) float64Exact
- func Int32Exact(value int32) int32Exact
- func Int64Exact(value int64) int64Exact
- func ListExact(value []Check) listExact
- func ListPartial(value map[int]Check) listPartial
- func ListSizeExact(size int) listSizeExact
- func MapExact(value map[string]Check) mapExact
- func MapPartial(value map[string]Check) mapPartial
- func MapSizeExact(size int) mapSizeExact
- func NotNull() notNull
- func Null() null
- func NumberExact(value *big.Float) numberExact
- func ObjectExact(value map[string]Check) objectExact
- func ObjectPartial(value map[string]Check) objectPartial
- func SetExact(value []Check) setExact
- func SetPartial(value []Check) setPartial
- func SetSizeExact(size int) setSizeExact
- func StringExact(value string) stringExact
- func StringRegexp(regex *regexp.Regexp) stringRegexp
- func TupleExact(value []Check) tupleExact
- func TuplePartial(value map[int]Check) tuplePartial
- func TupleSizeExact(size int) tupleSizeExact
- type Check
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Bool ¶
func Bool(value bool) boolValue
Bool returns a Check for asserting equality between the supplied bool and the value passed to the CheckValue method.
func Float32Exact ¶ added in v1.9.0
func Float32Exact(value float32) float32Exact
Float32Exact returns a Check for asserting equality between the supplied float32 and the value passed to the CheckValue method.
func Float64Exact ¶
func Float64Exact(value float64) float64Exact
Float64Exact returns a Check for asserting equality between the supplied float64 and the value passed to the CheckValue method.
func Int32Exact ¶ added in v1.9.0
func Int32Exact(value int32) int32Exact
Int32Exact returns a Check for asserting equality between the supplied int32 and the value passed to the CheckValue method.
func Int64Exact ¶
func Int64Exact(value int64) int64Exact
Int64Exact returns a Check for asserting equality between the supplied int64 and the value passed to the CheckValue method.
func ListExact ¶
func ListExact(value []Check) listExact
ListExact returns a Check for asserting equality between the supplied []Check and the value passed to the CheckValue method. This is an order-dependent check.
func ListPartial ¶
ListPartial returns a Check for asserting partial equality between the supplied map[int]Check and the value passed to the CheckValue method. The map keys represent the zero-ordered element indices within the list that is being checked. Only the elements at the indices defined within the supplied map[int]Check are checked.
func ListSizeExact ¶
func ListSizeExact(size int) listSizeExact
ListSizeExact returns a Check for asserting that a list has size elements.
func MapExact ¶
MapExact returns a Check for asserting equality between the supplied map[string]Check and the value passed to the CheckValue method.
func MapPartial ¶
MapPartial returns a Check for asserting partial equality between the supplied map[string]Check and the value passed to the CheckValue method. Only the elements at the map keys defined within the supplied map[string]Check are checked.
func MapSizeExact ¶
func MapSizeExact(size int) mapSizeExact
MapSizeExact returns a Check for asserting that a map has size elements.
func NotNull ¶
func NotNull() notNull
NotNull returns a Check for asserting the value passed to the CheckValue method is not nil.
func Null ¶
func Null() null
Null returns a Check for asserting the value passed to the CheckValue method is nil.
func NumberExact ¶
NumberExact returns a Check for asserting equality between the supplied *big.Float and the value passed to the CheckValue method. The CheckValue method uses 512-bit precision to perform this assertion.
func ObjectExact ¶
ObjectExact returns a Check for asserting equality between the supplied map[string]Check and the value passed to the CheckValue method. The map keys represent object attribute names.
func ObjectPartial ¶
ObjectPartial returns a Check for asserting partial equality between the supplied map[string]Check and the value passed to the CheckValue method. The map keys represent object attribute names. Only the object attributes defined by the map keys within the supplied map[string]Check are checked.
func SetExact ¶
func SetExact(value []Check) setExact
SetExact returns a Check for asserting equality between the supplied []Check and the value passed to the CheckValue method. This is an order-independent check.
func SetPartial ¶
func SetPartial(value []Check) setPartial
SetPartial returns a Check for asserting partial equality between the supplied []Check and the value passed to the CheckValue method. Only the elements defined within the supplied []Check are checked. This is an order-independent check.
func SetSizeExact ¶
func SetSizeExact(size int) setSizeExact
SetSizeExact returns a Check for asserting that a set has size elements.
func StringExact ¶
func StringExact(value string) stringExact
StringExact returns a Check for asserting equality between the supplied string and a value passed to the CheckValue method.
func StringRegexp ¶
StringRegexp returns a Check for asserting equality between the supplied regular expression and a value passed to the CheckValue method.
func TupleExact ¶ added in v1.8.0
func TupleExact(value []Check) tupleExact
TupleExact returns a Check for asserting equality between the supplied []Check and the value passed to the CheckValue method. This is an order-dependent check.
func TuplePartial ¶ added in v1.8.0
TuplePartial returns a Check for asserting partial equality between the supplied map[int]Check and the value passed to the CheckValue method. The map keys represent the zero-ordered element indices within the tuple that is being checked. Only the elements at the indices defined within the supplied map[int]Check are checked.
func TupleSizeExact ¶ added in v1.8.0
func TupleSizeExact(size int) tupleSizeExact
TupleSizeExact returns a Check for asserting that a tuple has size elements.
Types ¶
type Check ¶
type Check interface { // CheckValue should assert the given known value against any expectations. Use the error // return to signal unexpected values or implementation errors. CheckValue(value any) error // String should return a string representation of the type and value. String() string }
Check defines an interface that is implemented to determine whether type and value match. Individual implementations determine how the match is performed (e.g., exact match, partial match).