Documentation ¶
Overview ¶
Package match contains match functions which can be used to create expressions that evaluate to a truth value.
All functions in this package result in a Match type which is simply a function with one generic input and a bool return value. The combination functions Match.And and Match.Or can be used to combine two Match expressions. Not will negate a Match expression.
Example ¶
package main import ( "fmt" "github.com/becheran/smock/match" ) func main() { fmt.Println(match.Eq("foo").Or(match.Eq("bar"))("foo")) fmt.Println(match.Eq(1).Or(match.Eq(2))(3)) fmt.Println(match.Not(match.Eq(1))(1)) }
Output: true false false
Index ¶
- type Match
- func Any[T any]() Match[T]
- func AnyOf[T comparable](other ...T) Match[T]
- func DeepEqual[T any](other T) Match[T]
- func Eq[T comparable](other T) Match[T]
- func MapEq[T ~map[K]V, K, V comparable](other T) Match[T]
- func Not[T any](o Match[T]) Match[T]
- func SliceEq[T ~[]E, E comparable](other T) Match[T]
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Match ¶
Match is a simple expression which evaluates to be either 'true' or 'false'
func Any ¶
Any is the verbose version of 'nil' and will always evaluate to true when passed as expression
func AnyOf ¶
func AnyOf[T comparable](other ...T) Match[T]
EAnyOfq returns a function which will be true if any value of `other` is equal to the input
func DeepEqual ¶
DeepEqual returns a function which will be true if `other` is equal to the input using to the reflect.DeepEqual function
func Eq ¶
func Eq[T comparable](other T) Match[T]
Eq returns a function which will be true if `other` is equal to the input
func MapEq ¶
func MapEq[T ~map[K]V, K, V comparable](other T) Match[T]
MapEq returns a function which will be true if `other` contains the same key/value pairs as in the input
func SliceEq ¶
func SliceEq[T ~[]E, E comparable](other T) Match[T]
Eq returns a function which will be true if all elements of `other` are equal to the input