core

package
v0.0.0-...-a7d1dd0 Latest Latest
Warning

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

Go to latest
Published: Jan 7, 2021 License: BSD-3-Clause Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AllOf

func AllOf(matchers ...*base.Matcher) *base.Matcher

Returns a short-circuiting Matcher that matches whenever all of the given matchers match a given input value. If any component matcher fails to match an input value, later matchers are not attempted.

func AnyOf

func AnyOf(matchers ...*base.Matcher) *base.Matcher

Returns a short-circuiting Matcher that matches whenever all of the given matchers match a given input value. If any component matcher fails to match an input value, later matchers are not attempted.

func Anything

func Anything() *base.Matcher

Returns a Matcher that matches any input value.

func Applying

func Applying(function interface{}, name string) func(*base.Matcher) *base.Matcher

Returns a function that composes the given function with a Matcher, such as:

ToLength := Composer(func(s string) int { return len(s) }, "ToLength")

And then:

HasLengthThree := ToLength(Is(EqualTo(3)))
HasLengthThree.Match("no").Matched() // false
HasLengthThree.Match("yes").Matched() // true

The given function must be able to accept a single argument and return a single argument.

func DeepEqualTo

func DeepEqualTo(expected interface{}) *base.Matcher

Returns a Matcher that checks if the actual value is (deeply) equal to the given expected value, using reflect.DeepEqual.

For an equality test equivalent to `==`, see the `hamcrest/comparison` package.

func EqualTo

func EqualTo(expected interface{}) *base.Matcher

Returns a matcher that matches values that are equal to the given expected value, using the equality (==) operator.

func False

func False() *base.Matcher

Returns a Matcher that matches the boolean value false.

func GreaterThan

func GreaterThan(expected interface{}) *base.Matcher

Returns a matcher that matches values that are greater-than the given expected value, using the greater-than (<) operator.

func GreaterThanOrEqualTo

func GreaterThanOrEqualTo(expected interface{}) *base.Matcher

Returns a matcher that matches values that are greater-than-or-equal-to the given expected value, using the greater-than-or-equal-to (>=) operator.

func Is

func Is(matcher *base.Matcher) *base.Matcher

Returns a Matcher that decorates another matcher.

func LessThan

func LessThan(expected interface{}) *base.Matcher

Returns a matcher that matches values that are less-than the given expected value, using the less-than (<) operator.

func LessThanOrEqualTo

func LessThanOrEqualTo(expected interface{}) *base.Matcher

Returns a matcher that matches values that are less-than-or-equal-to the given expected value, using the less-than-or-equal-to (<=) operator.

func Nil

func Nil() *base.Matcher

Returns a Matcher that matches if the actual value is nil or the nil value of its type. (Note that this is *not* equivalent to DeeplyEqualTo(nil).)

func NonNil

func NonNil() *base.Matcher

Returns a Matcher that matches if the actual value is neither nil nor the nil value of its type. (Note that this is *not* equivalent to Not(DeeplyEqualTo(nil)).)

func Not

func Not(matcher *base.Matcher) *base.Matcher

Returns a Matcher that decorates another matcher and only matches when the underlying matcher does not match (and vice versa).

func NotEqualTo

func NotEqualTo(expected interface{}) *base.Matcher

Returns a matcher that matches values that are not equal to the given expected value, using the inequality (!=) operator.

func PanicWhenApplying

func PanicWhenApplying(functionOrMatcher interface{}, name string) *base.Matcher

Returns a Matcher that matches on values that cause the given functionOrMatcher to panic.

functionOrMatcher should either be a function that accepts one parameter or a Matcher.

func True

func True() *base.Matcher

Returns a Matcher that matches the boolean value true.

Types

This section is empty.

Jump to

Keyboard shortcuts

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