assert

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Jun 5, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Contains deprecated

func Contains(t *testing.T, container any, item any, message ...any)

Deprecated: Use Inside instead.

Contains fails the test if the container (string, slice, or array) does not include the item.

func DeepEqual

func DeepEqual(t *testing.T, want, have any, message ...any)

DeepEqual fails the test if want and have are not deeply equal. It uses reflect.DeepEqual to compare complex structures, slices, and maps.

func Equal

func Equal[T comparable](t *testing.T, want, have T, message ...any)

Equal fails the test if want and have are not equal.

func ErrorIs added in v0.5.0

func ErrorIs(t *testing.T, want, have error, message ...any)

ErrorIs fails the test if the provided error does not match the expected type, even when wrapped.

func ErrorIsNot added in v0.5.0

func ErrorIsNot(t *testing.T, want, have error, message ...any)

ErrorIsNot fails the test if the provided error matches the specified type, even when wrapped.

func ErrorNotType added in v0.5.0

func ErrorNotType[T error](t *testing.T, have error, message ...any)

ErrorNotType fails the test if the provided error is of the specified type.

func ErrorType added in v0.5.0

func ErrorType[T error](t *testing.T, have error, message ...any)

ErrorType fails the test if the provided error is not of the expected type.

func False

func False(t *testing.T, result bool, message ...any)

False fails the test if the result is true.

func Greater deprecated

func Greater[T internal.Number](t *testing.T, want T, have any, message ...any)

Deprecated: Use GreaterThan instead.

Greater fails the test if have is not greater than want.

func GreaterOrEqual

func GreaterOrEqual[T internal.Number](t *testing.T, want T, have any, message ...any)

GreaterOrEqual fails the test if have is not greater than or equal to want.

func GreaterThan added in v0.4.0

func GreaterThan[T internal.Number](t *testing.T, want T, have any, message ...any)

GreaterThan fails the test if have is not greater than want.

func InDelta

func InDelta(t *testing.T, want, have, delta float64, message ...any)

InDelta fails the test if the absolute difference between want and have is greater than the specified delta.

func Inside added in v0.4.0

func Inside(t *testing.T, item, container any, message ...any)

Inside fails the test if the container (string, slice, or array) does not include the item.

func Len deprecated

func Len[T internal.Number](t *testing.T, want T, have any, message ...any)

Deprecated: Use Size instead.

Len fails the test if the length of 'have' does not match 'want'. It supports Slice, Map, Array, Chan, and String.

func Less deprecated

func Less[T internal.Number](t *testing.T, want T, have any, message ...any)

Deprecated: Use LessThan instead.

Less fails the test if have is not less than want.

func LessOrEqual

func LessOrEqual[T internal.Number](t *testing.T, want T, have any, message ...any)

LessOrEqual fails the test if have is not less than or equal to want.

func LessThan added in v0.4.0

func LessThan[T internal.Number](t *testing.T, want T, have any, message ...any)

LessThan fails the test if have is not less than want.

func Nil

func Nil(t *testing.T, item any, message ...any)

Nil fails the test if the provided item is not nil.

func NotContains deprecated

func NotContains(t *testing.T, container any, item any, message ...any)

Deprecated: Use NotInside instead.

NotContains fails the test if the container includes the item.

func NotEqual

func NotEqual[T comparable](t *testing.T, want, have T, message ...any)

NotEqual fails the test if want and have are equal.

func NotInside added in v0.4.0

func NotInside(t *testing.T, item, container any, message ...any)

NotInside fails the test if the container includes the item.

func NotNil

func NotNil(t *testing.T, item any, message ...any)

NotNil fails the test if the provided item is nil or a nil pointer/interface.

func NotPanic

func NotPanic(t *testing.T, fn func(), message ...any)

NotPanic fails the test if the provided function panics.

func Panic

func Panic(t *testing.T, fn func(), message ...any)

Panic fails the test if the provided function does not panic.

func PanicWithMessage

func PanicWithMessage(t *testing.T, expected string, fn func(), message ...any)

PanicWithMessage fails the test if the function does not panic or if the panic message differs.

func Size added in v0.4.0

func Size[T internal.Number](t *testing.T, want T, have any, message ...any)

Size fails the test if the length of 'have' does not match 'want'. It supports Slice, Map, Array, Chan, and String.

func True

func True(t *testing.T, result bool, message ...any)

True fails the test if the result is false.

func WillClose added in v0.2.0

func WillClose(t *testing.T, ch <-chan struct{}, timeout time.Duration, message ...any)

WillClose fails the test if the provided channel does not close or receive a signal within the specified timeout duration.

Types

This section is empty.

Jump to

Keyboard shortcuts

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