is

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2023 License: BSD-3-Clause Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AllOf

func AllOf[A any](allMatchers ...*gocrest.Matcher[A]) *gocrest.Matcher[A]

AllOf takes some matchers and checks if all the matchers return true. Returns a matcher that performs the test on the input matchers.

func AnyOf

func AnyOf[A any](allMatchers ...*gocrest.Matcher[A]) *gocrest.Matcher[A]

AnyOf takes some matchers and checks if at least one of the matchers return true. Returns a matcher that performs the test on the input matchers.

func ArrayContaining added in v1.0.8

func ArrayContaining[A comparable](expected ...A) *gocrest.Matcher[[]A]

ArrayContaining finds if all x's are contained in y. Acts like "ContainsAll", all elements given must be present in actual in the same order as the expected values.

func ArrayMatching added in v1.0.8

func ArrayMatching[A comparable](expected ...*gocrest.Matcher[A]) *gocrest.Matcher[[]A]

ArrayMatching finds if all x's are matched in y. Acts like "ContainsAll", all elements given must be present in actual in the same order as the expected values.

func Empty

func Empty[A any]() *gocrest.Matcher[[]A]

Empty matches if the actual array or slice is len(actual) is 0. Returns a matcher that evaluates true if actual is "empty".

func EmptyMap added in v1.1.1

func EmptyMap[K comparable, V any]() *gocrest.Matcher[map[K]V]

EmptyMap matches if the actual maps if len(actual) is 0. Returns a matcher that evaluates true if actual is "empty".

func EmptyString added in v1.1.1

func EmptyString() *gocrest.Matcher[string]

EmptyString matches if the actual string if they are "" (==len(0)) Returns a matcher that evaluates true if actual is "empty".

func EqualTo

func EqualTo[A any](expected A) *gocrest.Matcher[A]

EqualTo checks if two values are equal. Uses DeepEqual (could be slow). Like DeepEquals, if the types are not the same the matcher returns false. Returns a matcher that will return true if two values are equal.

func EqualToIgnoringWhitespace added in v1.0.1

func EqualToIgnoringWhitespace(expected string) (matcher *gocrest.Matcher[string])

EqualToIgnoringWhitespace tests whether two strings have identical content without any whitespace comparison. For example:

"a bc" is EqualToIgnoringWhitespace when compared with "a b c" "a b c" is EqualToIgnoringWhitespace when compared with "a \nb \tc" "ab\tc" is EqualToIgnoringWhitespace when compared with "a \nb \tc" .. and so on.

func False added in v1.0.3

func False() *gocrest.Matcher[bool]

False returns true if the actual equals false. Confusing but true.

func GreaterThan

func GreaterThan[A Comparable](expected A) *gocrest.Matcher[A]

GreaterThan matcher compares two values that are numeric or string values, and when called returns true if actual > expected. Strings are compared lexicographically with '>'. Returns a matcher that checks if actual is greater than expected.

func GreaterThanOrEqualTo

func GreaterThanOrEqualTo[A Comparable](expected A) *gocrest.Matcher[A]

GreaterThanOrEqualTo is a shorthand matcher for anyOf(greaterThan(x), equalTo(x)) Returns a matcher matching if actual >= expected (using deepEquals).

func LessThan

func LessThan[A Comparable](expected A) *gocrest.Matcher[A]

LessThan matcher compares two values that are numeric or string values, and when called returns true if actual < expected. Strings are compared lexicographically with '<'. Returns a matcher that checks if actual is greater than expected.

func LessThanOrEqualTo

func LessThanOrEqualTo[A Comparable](expected A) *gocrest.Matcher[A]

LessThanOrEqualTo is a short hand matcher for anyOf(lessThan(x), equalTo(x)) Returns a matcher matching if actual <= expected (using deepEquals).

func MapContaining added in v1.0.8

func MapContaining[K comparable, V comparable](expected map[K]V) *gocrest.Matcher[map[K]V]

MapContaining finds if all map[k] 's value V is contained as a value of actual[k] Acts like "ContainsAll", all elements given must be present in actual in the same order as the expected values.

func MapContainingValues added in v1.0.8

func MapContainingValues[K comparable, V comparable](expected ...V) *gocrest.Matcher[map[K]V]

MapContainingValues finds if all values V is contained as a value of actual[k] Acts like "ContainsAll", all elements given must be present in actual in the same order as the expected values.

func MapMatchingValues added in v1.0.8

func MapMatchingValues[K comparable, V comparable](expected ...*gocrest.Matcher[V]) *gocrest.Matcher[map[K]V]

MapMatchingValues finds if all values V is match a value of actual[k] Acts like "ContainsAll", all elements given must match in actual in the same order as the expected values.

func MatchForPattern

func MatchForPattern(expected string) *gocrest.Matcher[string]

MatchForPattern matches if actual string matches the expected regex String provided must be a valid for compilation with regexp.Compile. Returns a matcher that uses the expected for a regex to match the actual value.

func Nil

func Nil() *gocrest.Matcher[error]

Nil matches if the actual error value is nil

func NilArray added in v1.1.1

func NilArray[A any]() *gocrest.Matcher[[]A]

NilArray matches if the actual array value is nil

func NilMap added in v1.1.1

func NilMap[K comparable, V any]() *gocrest.Matcher[map[K]V]

NilMap matches if the actual map value is nil

func NilPtr added in v1.1.1

func NilPtr[T any]() *gocrest.Matcher[*T]

NilPtr matches if the actual pointer to T is nil

func Not

func Not[A any](matcher *gocrest.Matcher[A]) *gocrest.Matcher[A]

Not negates the given matcher. Returns a matcher that returns logical not of the matcher given.

func StringContaining added in v1.0.8

func StringContaining(expected ...string) *gocrest.Matcher[string]

StringContaining finds if all x's are contained as value in y. Acts like "ContainsAll", all elements given must be present.

func True added in v1.0.3

func True[A bool]() *gocrest.Matcher[A]

True returns true if the actual matches true

Types

type Comparable added in v1.1.1

type Comparable interface {
	~int | ~int8 | ~int16 | ~int32 | ~int64 | ~float32 | ~float64 | ~uint | ~uint16 | ~uint32 | ~uint64 | ~string
}

Jump to

Keyboard shortcuts

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