be

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2025 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Annotate

func Annotate(inner assertion.Assertion, msg string, args ...any) assertion.Annotated

Annotate wraps the given assertion with a message and format arguments.

func Ascending

func Ascending[V cmp.Ordered](list []V) assertion.Assertion

Ascending asserts that the given list is sorted in ascending order (each item is less or equal to the next item).

func DeepEqual

func DeepEqual[V any](expected V, got V) assertion.Assertion

DeepEqual runs a deep-equal assertion

func Descending

func Descending[V cmp.Ordered](list []V) assertion.Assertion

Descending asserts that the given list is sorted in descending order (each item is greater or equal to the next item).

func Empty

func Empty[V any](list []V) assertion.Assertion

Empty asserts that the given list is empty.

func Equal

func Equal[V comparable](expected V, got V) assertion.Assertion

Equal runs a shallow-equal assertion

func ErrorIs

func ErrorIs(v error, target error) assertion.Assertion

ErrorIs asserts that the given error is linked to the target error.

func Eventually

func Eventually(fn func(ctx context.Context) error, tick time.Duration, attempts uint) assertion.Assertion

Eventually runs a function repeatedly until it succeeds or the context is done.

func Failed

func Failed() assertion.Assertion

Failed is a pseudo-assertion that always fails, for placeholder usage.

func False

func False(v bool) assertion.Assertion

False asserts that the given value is false.

func Implemented

func Implemented[T any](v any) assertion.Assertion

Implemented asserts that the given value implements the given interface.

func InDelta

func InDelta[V constraints.Number](a, b, delta V) assertion.Assertion

InDelta asserts that the given values are within the given delta. The delta must be positive. If the delta is zero, the values must be equal.

func InList

func InList[V comparable](list []V, item V) assertion.Assertion

InList asserts that the given item is contained in the list.

func InMap

func InMap[K comparable, V any](m map[K]V, key K) assertion.Assertion

InMap asserts that the given key is present in the map.

func Len

func Len[V any](list []V, expectedLen int) assertion.Assertion

Len asserts that the given list has the given length.

func Nil

func Nil(v any) assertion.Assertion

Nil asserts that the given value is nil, including interface values that contain nil pointers.

func NilPtr

func NilPtr[V any](v *V) assertion.Assertion

NilPtr asserts that the given pointer is nil.

func NoError

func NoError(v error) assertion.Assertion

NoError asserts that the given error is nil.

func NoPanic

func NoPanic(fn func()) assertion.Assertion

NoPanic asserts that the given function does not panic.

func NonEmpty

func NonEmpty[V any](list []V) assertion.Assertion

NonEmpty asserts that the given list is not empty.

func NonNil

func NonNil(v any) assertion.Assertion

NonNil asserts that the given value is not nil, including interface values that contain nil pointers.

func NonNilPtr

func NonNilPtr[V any](v *V) assertion.Assertion

NonNilPtr asserts that the given pointer is not nil.

func Not

Not asserts that the given assertion fails. For better readability and error reporting, use the assertion-specific inverse assertions instead.

func NotDeepEqual

func NotDeepEqual[V any](unexpected V, got V) assertion.Assertion

NotDeepEqual runs a deep-not-equal assertion

func NotEqual

func NotEqual[V comparable](unexpected V, got V) assertion.Assertion

NotEqual runs a shallow-not-equal assertion

func OfType

func OfType[T any](v any) assertion.Assertion

OfType asserts that the given value is of the given type. The reflect type of T is compared to the reflect type of the given value.

func Panic

func Panic(fn func()) assertion.Assertion

Panic asserts that the given function panics.

func Passed

func Passed() assertion.Assertion

Passed is a pseudo-assertion that always passes, for placeholder usage.

func Prefix

func Prefix(v string, prefix string) assertion.Assertion

func Same

func Same[V any](expected *V, got *V) assertion.Assertion

Same asserts that the pointers are pointing to the same thing.

func Substring

func Substring(v string, sub string) assertion.Assertion

func Suffix

func Suffix(v string, suffix string) assertion.Assertion

func True

func True(v bool) assertion.Assertion

True asserts that the given value is true.

Types

This section is empty.

Jump to

Keyboard shortcuts

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