to

package
v0.0.0-...-b93a6bd Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2020 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package to exposes all the core matchers that can be used with the should.Expect[E] functions.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func All

func All(matchers ...matcher.Matcher) matcher.Matcher

All checks whenever actual satisfies all the passed matchers.

func Any

func Any(matchers ...matcher.Matcher) matcher.Matcher

Any checks whenever actual satisfies any of the passed matchers.

func Anything

func Anything() matcher.Matcher

Anything returns a matcher that always returns true.

func BeEmpty

func BeEmpty() matcher.Matcher

BeEmpty checks whenever actual is empty (string, slice, map, etc).

func BeFalse

func BeFalse() matcher.Matcher

BeFalse checks whenever actual is false.

func BeNil

func BeNil() matcher.Matcher

BeNil checks whenever actual is nil.

func BeNumerically

func BeNumerically(comparator string, compareTo ...interface{}) matcher.Matcher

BeNumerically checks whenever actual satisfies the comparison.

func BeTrue

func BeTrue() matcher.Matcher

BeTrue checks whenever actual is true.

func BeZero

func BeZero() matcher.Matcher

BeZero checks whenever actual is the zero value of its type.

func ConsistOf

func ConsistOf(elements ...interface{}) matcher.Matcher

ConsistOf checks whenever actual consists of the expected elements (no more, no less).

func ContainElements

func ContainElements(elements ...interface{}) matcher.Matcher

ContainElements checks if actual contains all the given elements. Ordering does not matter, and you can nest other matchers for the elements.

func ContainSubstring

func ContainSubstring(substr string, args ...interface{}) matcher.Matcher

ContainSubstring checks that actual contains the given substring, additional arguments can be passed to construct a formatted string with fmt.Sprintf.

func Equal

func Equal(expected interface{}) matcher.Matcher

Equal uses deep-equal to compare against the expected element.

func Equivalent

func Equivalent(expected interface{}) matcher.Matcher

Equivalent to is like Equal, but a little bit more flexible when checking for equality, for example, int(3) is equivalent to float(3.0).

func HaveKey

func HaveKey(key interface{}) matcher.Matcher

HaveKey checks whenever actual is a map and contains the expected key.

func HaveKeyAndValue

func HaveKeyAndValue(key, value interface{}) matcher.Matcher

HaveKeyAndValue checks whenever actual is a map and contains the expected key and value.

func HaveLen

func HaveLen(count int) matcher.Matcher

HaveLen checks that actual as the given length (it has to be either a string, slice, map, channel, etc).

func MatchRegexp

func MatchRegexp(regexp string, args ...interface{}) matcher.Matcher

MatchRegexp checks that actual matches the given regular expression, additional arguments can be passed to construct a formatted regex with fmt.Sprintf.

func Not

func Not(matcher matcher.Matcher) matcher.Matcher

Not negates the given matcher.

func Success

func Success() matcher.Matcher

Success checks whenever actual is not an error.

func WithTransform

func WithTransform(transform interface{}, matcher matcher.Matcher) matcher.Matcher

WithTransform applies the given transform function to the value being matched before calling the wrapped matcher. The transform function must take one value and return one value.

Types

This section is empty.

Jump to

Keyboard shortcuts

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