should

package
v2.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrExpectedCountInvalid  = errors.New("expected count invalid")
	ErrTypeMismatch          = errors.New("type mismatch")
	ErrKindMismatch          = errors.New("kind mismatch")
	ErrAssertionFailure      = errors.New("assertion failure")
	ErrFatalAssertionFailure = errors.New("fatal")
)
View Source
var NOT negated

NOT (a singleton) constrains all negated assertions to their own namespace.

Functions

func BeChronological

func BeChronological(actual any, expected ...any) error

BeChronological asserts whether actual is a []time.Time and whether the values are in chronological order.

func BeEmpty

func BeEmpty(actual any, expected ...any) error

BeEmpty uses reflection to verify that len(actual) == 0.

func BeFalse

func BeFalse(actual any, expected ...any) error

BeFalse verifies that actual is the boolean false value.

func BeGreaterThan

func BeGreaterThan(actual any, EXPECTED ...any) error

BeGreaterThan verifies that actual is greater than expected. Both actual and expected must be strings or numeric in type.

func BeGreaterThanOrEqualTo

func BeGreaterThanOrEqualTo(actual any, expected ...any) error

BeGreaterThanOrEqualTo verifies that actual is less than or equal to expected. Both actual and expected must be strings or numeric in type.

func BeIn

func BeIn(actual any, expected ...any) error

BeIn determines whether actual is a member of expected[0]. It defers to Contain.

func BeLessThan

func BeLessThan(actual any, EXPECTED ...any) error

BeLessThan verifies that actual is less than expected. Both actual and expected must be strings or numeric in type.

func BeLessThanOrEqualTo

func BeLessThanOrEqualTo(actual any, expected ...any) error

BeLessThanOrEqualTo verifies that actual is less than or equal to expected. Both actual and expected must be strings or numeric in type.

func BeNil

func BeNil(actual any, expected ...any) error

BeNil verifies that actual is the nil value.

func BeTrue

func BeTrue(actual any, expected ...any) error

BeTrue verifies that actual is the boolean true value.

func BeZeroValue added in v2.1.0

func BeZeroValue(actual any, expected ...any) error

BeZeroValue verifies that actual is the zero value for its type.

func Contain

func Contain(actual any, expected ...any) error

Contain determines whether actual contains expected[0]. The actual value may be a map, array, slice, or string:

  • In the case of maps the expected value is assumed to be a map key.
  • In the case of slices and arrays the expected value is assumed to be a member.
  • In the case of strings the expected value may be a rune or substring.

func EndWith

func EndWith(actual any, expected ...any) error

EndWith verifies that actual ends with expected[0]. The actual value may be an array, slice, or string.

func Equal

func Equal(actual any, EXPECTED ...any) error

Equal verifies that the actual value is equal to the expected value. It uses reflect.DeepEqual in most cases, but also compares numerics regardless of specific type and compares time.Time values using the time.Equal method.

func HappenAfter

func HappenAfter(actual any, expected ...any) error

HappenAfter ensures that the first time value happens after the second.

func HappenBefore

func HappenBefore(actual any, expected ...any) error

HappenBefore ensures that the first time value happens before the second.

func HappenOn

func HappenOn(actual any, expected ...any) error

HappenOn ensures that two time values happen at the same instant. See the time.Time.Equal method for the details. This function defers to Equal to do the work.

func HappenWithin

func HappenWithin(actual any, expected ...any) error

HappenWithin ensures that the first time value happens within a specified duration of the other time value. The actual value should be a time.Time. The first expected value should be a time.Duration. The second expected value should be a time.Time.

func HaveLength

func HaveLength(actual any, expected ...any) error

HaveLength uses reflection to verify that len(actual) == 0.

func Panic

func Panic(actual any, expected ...any) (err error)

Panic invokes the func() provided as actual and recovers from any panic. It returns an error if actual() does not result in a panic.

func StartWith

func StartWith(actual any, expected ...any) error

StartWith verified that actual starts with expected[0]. The actual value may be an array, slice, or string.

func WrapError

func WrapError(actual any, expected ...any) error

WrapError uses errors.Is to verify that actual is an error value that wraps expected[0] (also an error value).

Types

This section is empty.

Directories

Path Synopsis
internal
go-diff/diffmatchpatch
Package diffmatchpatch offers robust algorithms to perform the operations required for synchronizing plain text.
Package diffmatchpatch offers robust algorithms to perform the operations required for synchronizing plain text.

Jump to

Keyboard shortcuts

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