Documentation ¶
Index ¶
- func AllOf[A any](allMatchers ...*gocrest.Matcher[A]) *gocrest.Matcher[A]
- func AnyOf[A any](allMatchers ...*gocrest.Matcher[A]) *gocrest.Matcher[A]
- func ArrayContaining[A comparable](expected ...A) *gocrest.Matcher[[]A]
- func ArrayMatching[A comparable](expected ...*gocrest.Matcher[A]) *gocrest.Matcher[[]A]
- func Empty[A any]() *gocrest.Matcher[[]A]
- func EmptyMap[K comparable, V any]() *gocrest.Matcher[map[K]V]
- func EmptyString() *gocrest.Matcher[string]
- func EqualTo[A any](expected A) *gocrest.Matcher[A]
- func EqualToIgnoringWhitespace(expected string) (matcher *gocrest.Matcher[string])
- func False() *gocrest.Matcher[bool]
- func GreaterThan[A Comparable](expected A) *gocrest.Matcher[A]
- func GreaterThanOrEqualTo[A Comparable](expected A) *gocrest.Matcher[A]
- func LessThan[A Comparable](expected A) *gocrest.Matcher[A]
- func LessThanOrEqualTo[A Comparable](expected A) *gocrest.Matcher[A]
- func MapContaining[K comparable, V comparable](expected map[K]V) *gocrest.Matcher[map[K]V]
- func MapContainingValues[K comparable, V comparable](expected ...V) *gocrest.Matcher[map[K]V]
- func MapMatchingValues[K comparable, V comparable](expected ...*gocrest.Matcher[V]) *gocrest.Matcher[map[K]V]
- func MatchForPattern(expected string) *gocrest.Matcher[string]
- func Nil() *gocrest.Matcher[error]
- func NilArray[A any]() *gocrest.Matcher[[]A]
- func NilMap[K comparable, V any]() *gocrest.Matcher[map[K]V]
- func NilPtr[T any]() *gocrest.Matcher[*T]
- func Not[A any](matcher *gocrest.Matcher[A]) *gocrest.Matcher[A]
- func StringContaining(expected ...string) *gocrest.Matcher[string]
- func True[A bool]() *gocrest.Matcher[A]
- type Comparable
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AllOf ¶
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 ¶
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 ¶
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
EmptyString matches if the actual string if they are "" (==len(0)) Returns a matcher that evaluates true if actual is "empty".
func EqualTo ¶
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
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 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 ¶
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 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 Not ¶
Not negates the given matcher. Returns a matcher that returns logical not of the matcher given.
func StringContaining ¶ added in v1.0.8
StringContaining finds if all x's are contained as value in y. Acts like "ContainsAll", all elements given must be present.