Documentation
¶
Overview ¶
Package require provides assertion functions that wrap the functions from the `is` package. Unlike `is`, functions in `require` call t.FailNow() upon failure, immediately stopping the current test.
This is useful when a test cannot proceed meaningfully after a specific assertion fails.
Index ¶
- func Contains(t testingT, collection any, element any, msgAndArgs ...any)
- func ContainsKey[K comparable, V any](t testingT, m map[K]V, key K, msgAndArgs ...any)
- func ElementsMatch[T comparable](t testingT, listA []T, listB []T, msgAndArgs ...any)
- func Empty(t testingT, data any, msgAndArgs ...any)
- func Equal[T any](t testingT, got T, want T, msgAndArgs ...any)
- func Error(t testingT, got error, msgAndArgs ...any)
- func ErrorAs(t testingT, got error, targetPtr any, msgAndArgs ...any)
- func ErrorIs(t testingT, got error, target error, msgAndArgs ...any)
- func False(t testingT, value bool, msgAndArgs ...any)
- func Greater[T cmp.Ordered](t testingT, got T, threshold T, msgAndArgs ...any)
- func GreaterOrEqual[T cmp.Ordered](t testingT, got T, threshold T, msgAndArgs ...any)
- func InDelta[T ~float32 | ~float64](t testingT, got T, want T, delta T, msgAndArgs ...any)
- func Len(t testingT, data any, expectedLen int, msgAndArgs ...any)
- func Less[T cmp.Ordered](t testingT, got T, threshold T, msgAndArgs ...any)
- func LessOrEqual[T cmp.Ordered](t testingT, got T, threshold T, msgAndArgs ...any)
- func Negative[T cmp.Ordered](t testingT, got T, msgAndArgs ...any)
- func Nil(t testingT, data any, msgAndArgs ...any)
- func NoError(t testingT, got error, msgAndArgs ...any)
- func NotContains(t testingT, collection any, element any, msgAndArgs ...any)
- func NotContainsKey[K comparable, V any](t testingT, m map[K]V, key K, msgAndArgs ...any)
- func NotEmpty(t testingT, data any, msgAndArgs ...any)
- func NotEqual[T any](t testingT, got T, want T, msgAndArgs ...any)
- func NotInDelta[T ~float32 | ~float64](t testingT, got T, want T, delta T, msgAndArgs ...any)
- func NotNil(t testingT, data any, msgAndArgs ...any)
- func NotPanics(t testingT, f func(), msgAndArgs ...any)
- func NotZero(t testingT, data any, msgAndArgs ...any)
- func Panics(t testingT, f func(), msgAndArgs ...any) (didPanic bool, panicValue any)
- func Positive[T cmp.Ordered](t testingT, got T, msgAndArgs ...any)
- func TimeAfter(t testingT, got, threshold time.Time, msgAndArgs ...any)
- func TimeBefore(t testingT, got, threshold time.Time, msgAndArgs ...any)
- func TimeEqual(t testingT, got, want time.Time, msgAndArgs ...any)
- func TimeEqualWithPrecision(t testingT, got, want time.Time, precision time.Duration, msgAndArgs ...any)
- func True(t testingT, value bool, msgAndArgs ...any)
- func WithinDuration(t testingT, got, want time.Time, delta time.Duration, msgAndArgs ...any)
- func WithinTime(t testingT, got time.Time, start, end time.Time, msgAndArgs ...any)
- func Zero(t testingT, data any, msgAndArgs ...any)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Contains ¶
Contains requires that the specified list(array, slice...) contains the specified element.
func ContainsKey ¶
func ContainsKey[K comparable, V any](t testingT, m map[K]V, key K, msgAndArgs ...any)
ContainsKey requires that the specified map contains the specified key.
func ElementsMatch ¶
func ElementsMatch[T comparable](t testingT, listA []T, listB []T, msgAndArgs ...any)
ElementsMatch requires that the specified lists or maps contain the same elements in any order.
func Empty ¶
Empty requires that the specified object is empty. Objects considered empty are nil, "", false, 0, or a channel, slice, array or map with len == 0.
func GreaterOrEqual ¶
GreaterOrEqual requires that the first element is greater than or equal to the second.
func Len ¶
Len requires that the specified object has the specified length. Len also fails if the object has a type that len() not accept.
func LessOrEqual ¶
LessOrEqual requires that the first element is less than or equal to the second.
func NotContains ¶
NotContains requires that the specified list(array, slice...) does not contain the specified element.
func NotContainsKey ¶
func NotContainsKey[K comparable, V any](t testingT, m map[K]V, key K, msgAndArgs ...any)
NotContainsKey requires that the specified map does not contain the specified key.
func NotEmpty ¶
NotEmpty requires that the specified object is not empty. Objects considered empty are nil, "", false, 0, or a channel, slice, array or map with len == 0.
func NotInDelta ¶
NotInDelta requires that the specified values are not within the delta of each other. It fails if |got - want| <= |delta|.
func NotPanics ¶
func NotPanics(t testingT, f func(), msgAndArgs ...any)
NotPanics requires that the code inside the specified PanicTestFunc does not panic.
func TimeBefore ¶
TimeBefore requires that a time is before a threshold time
func TimeEqualWithPrecision ¶
func TimeEqualWithPrecision(t testingT, got, want time.Time, precision time.Duration, msgAndArgs ...any)
TimeEqualWithPrecision requires that two times are equal within a certain precision
func WithinDuration ¶
WithinDuration requires that two times are within a certain duration of each other
func WithinTime ¶
WithinTime requires that a time is within a given time window
Types ¶
This section is empty.