assert

package
v0.30.0-dev3 Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Assert

func Assert(t interface {
	Errorf(format string, args ...any)
	Helper()
}, condition bool, msgAndArgs ...any) bool

Assert verifies that the condition is true. If not, it formats an error message and reports it through the test interface.

func Contains

func Contains(t interface {
	Errorf(format string, args ...any)
	Helper()
}, item any, collection any, msgAndArgs ...any) bool

Contains checks if an item is present in a collection, or if a collection contains another collection

func ContainsAnyOf

func ContainsAnyOf(t interface {
	Errorf(format string, args ...any)
	Helper()
}, expected any, collection any, msgAndArgs ...any) bool

ContainsAnyOf checks if the collection contains any elements from expected. For slice expected vs single value collection: checks if any element from the slice equals the single value. For string expected vs slice of strings collection: checks if each character in expected exists in any element of collection. For slice of strings expected vs string collection: checks if any string from the slice is contained in the collection string.

func ContainsInAnyOrder

func ContainsInAnyOrder[T any](t interface {
	Errorf(format string, args ...any)
	Helper()
}, expected, actual []T, msgAndArgs ...any) bool

ContainsInAnyOrder checks if the actual slice contains all elements from the expected slice in any order. Extra elements in the actual slice are allowed.

func ContainsOnly

func ContainsOnly[T any](t interface {
	Errorf(format string, args ...any)
	Helper()
}, expected, actual []T, msgAndArgs ...any) bool

ContainsOnly compares two slices and returns true if they contain exactly the same elements in the same order. If not, it formats an error message and reports it through the test interface.

func ContainsOnlyInAnyOrder

func ContainsOnlyInAnyOrder[T any](t interface {
	Errorf(format string, args ...any)
	Helper()
}, expected, actual []T, msgAndArgs ...any) bool

ContainsOnlyInAnyOrder compares two slices and returns true if they contain exactly the same elements in any order. If not, it formats an error message and reports it through the test interface.

func Equal

func Equal[T any](t interface {
	Errorf(format string, args ...any)
	Helper()
}, expected, actual T, msgAndArgs ...any) bool

Equal compares two values of the same type and returns true if they're equal. If they're not equal, it formats an error message and reports it through the test interface.

func Error

func Error(t interface {
	Errorf(format string, args ...any)
	Helper()
}, err error, msgAndArgs ...any) bool

Error checks if the error is not nil and returns true if it is not.

func False

func False(t interface {
	Errorf(format string, args ...any)
	Helper()
}, condition bool, msgAndArgs ...any) bool

False checks if the condition is false and returns true if it is.

func Nil

func Nil(t interface {
	Errorf(format string, args ...any)
	Helper()
}, value any, msgAndArgs ...any) bool

Nil checks if the value is nil and returns true if it is. If the value is not nil, it formats an error message and reports it through the test interface.

func NoError

func NoError(t interface {
	Errorf(format string, args ...any)
	Helper()
}, err error, msgAndArgs ...any) bool

NoError checks if the error is nil and returns true if it is. If the error is not nil, it formats an error message and reports it through the test interface.

func NotEmpty

func NotEmpty(t interface {
	Errorf(format string, args ...any)
	Helper()
}, collection any, msgAndArgs ...any) bool

NotEmpty verifies that the collection (slice, map, string, etc.) is not empty. If it is empty, it formats an error message and reports it through the test interface.

func NotEqual

func NotEqual[T any](t interface {
	Errorf(format string, args ...any)
	Helper()
}, expected, actual T, msgAndArgs ...any) bool

NotEqual compares two values of the same type and returns true if they're not equal. If they're equal, it formats an error message and reports it through the test interface.

func NotNil

func NotNil(t interface {
	Errorf(format string, args ...any)
	Helper()
}, value any, msgAndArgs ...any) bool

NotNil checks if the value is not nil and returns true if it is not. If the value is nil, it formats an error message and reports it through the test interface.

func True

func True(t interface {
	Errorf(format string, args ...any)
	Helper()
}, condition bool, msgAndArgs ...any) bool

True checks if the condition is true and returns true if it is.

Types

This section is empty.

Jump to

Keyboard shortcuts

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