assert

package
v0.24.0 Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2026 License: MPL-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package assert provides utility functions for testing which help assert provided conditions are met.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ElementsMatch

func ElementsMatch[T comparable](t testing.TB, expected, actual []T) bool

ElementsMatch fails the test if the expected and actual slices do not have the same elements.

func Equal

func Equal(t testing.TB, expected, actual any) bool

Equal fails the test if the expected and actual values are not equal.

func EqualError

func EqualError(t testing.TB, err error, expected string) bool

EqualError fails the test if the expected error is not equal to the actual error message.

func Error

func Error(t testing.TB, err error) bool

Error fails the test if the error is nil.

func ErrorContains

func ErrorContains(t testing.TB, err error, contains string) bool

ErrorContains fails the test if the expected error does not contain the provided string.

func Fail added in v0.5.0

func Fail(t testing.TB, msg string, a ...any) bool

Fail fails the test with the provided message.

func False added in v0.3.0

func False(t testing.TB, actual bool) bool

False fails the test if the actual value is not false.

func IsType

func IsType[T any](t testing.TB, object any) bool

IsType fails the test if the object is not of the expected type. The expected type is specified using a type parameter.

func Len

func Len(t testing.TB, object any, length int) bool

Len fails the test if the object is not of the expected length.

func NoError

func NoError(t testing.TB, err error) bool

NoError fails the test if the error is not nil.

func Panic added in v0.5.0

func Panic(t testing.TB, f func(), expected string) (result bool)

Panic checks that the function panics with the expected message.

func Require

func Require(t testing.TB, isPassing bool)

Require fails the test if the provided boolean is false. It should be used in conjunction with assert functions. Example:

assert.Require(t, assert.AssertError(t, err))

func True

func True(t testing.TB, actual bool) bool

True fails the test if the actual value is not true.

Types

This section is empty.

Jump to

Keyboard shortcuts

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