knownvalue

package
v1.7.0 Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2024 License: MPL-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package knownvalue contains the known value interface, and types implementing the known value interface.

Index

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 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 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

func ListPartial(value map[int]Check) 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

func MapExact(value map[string]Check) mapExact

MapExact returns a Check for asserting equality between the supplied map[string]Check and the value passed to the CheckValue method.

func MapPartial

func MapPartial(value map[string]Check) 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

func NumberExact(value *big.Float) 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

func ObjectExact(value map[string]Check) 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

func ObjectPartial(value map[string]Check) 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

func StringRegexp(regex *regexp.Regexp) stringRegexp

StringRegexp returns a Check for asserting equality between the supplied regular expression and a value passed to the CheckValue method.

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).

Jump to

Keyboard shortcuts

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