assertions

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Equal

func Equal[T any](tb testing.TB, expected, input T)

Equal asserts that 2 values of the same type are equal using reflect.DeepEqual

func Error

func Error(tb testing.TB, input error)

Error asserts that the input error is non-nil

func ErrorsMatch

func ErrorsMatch(tb testing.TB, expected, input error)

ErrorsMatch asserts that the input and expected error either are both nil or both have the same string returned by Error. This is to facilitate table driven test with a single expected error field.

func MapsMatch

func MapsMatch[K comparable, E any, T ~map[K]E](tb testing.TB, expected, input T)

MapsMatch asserts that both expected and input have the same members regardless of order elements in expected and input are compared using reflect.DeepEqual. Failing results will only print the non-matching elements

func NoError

func NoError(tb testing.TB, input error)

NoError asserts that the input error is nil

func NotPanics

func NotPanics(tb testing.TB, fn func())

NotPanics asserts that the provided function does not panic durion execution

func Panics

func Panics(tb testing.TB, fn func())

Panics asserts that the provided function panics during execution

func SlicesMatch

func SlicesMatch[E any, T ~[]E](tb testing.TB, expected, input T)

SlicesMatch asserts that both expected and input have the same members regardless of order elements in expected and input are compared using reflect.DeepEqual. Failing results will only print the non-matching elements

func Within

func Within[T cmp.Ordered](tb testing.TB, minT, maxT, input T)

Within asserts that input is within the range [minT, maxT] The assertion will pass while input is >= minT and input is <= maxT

Types

This section is empty.

Jump to

Keyboard shortcuts

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