assert

package module
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: May 4, 2022 License: MIT Imports: 5 Imported by: 0

README

assert

A unit test helper library


Documentation

https://pkg.go.dev/github.com/nomad-software/assert

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Approx

func Approx[T constraints.Float](t *testing.T, val T, expected T, epsilon T)

Approx is a helper function to test if the passed floating point numbers are approximately equal.

func Contains added in v1.0.3

func Contains[T comparable](t *testing.T, hatstack []T, needle T)

Contains is a helper fuction to test if the passed haystack array contains the needle value.

func Empty

func Empty[T any](t *testing.T, val []T)

Empty is a helper function to test if the passed array is empty.

func Eq

func Eq[T comparable](t *testing.T, val T, expected T)

Eq is a helper function to test the equality of two passed values.

func Error added in v1.0.2

func Error(t *testing.T, err error, expected string)

Error is a helper function to test if an error matches a string.

func False

func False(t *testing.T, val bool)

True is a helper function to test a boolean value is false.

func Gt

func Gt[T constraints.Ordered](t *testing.T, val T, threshold T)

Gt is a helper function to test if the passed value is greater than the threshold.

func Gte

func Gte[T constraints.Ordered](t *testing.T, val T, threshold T)

Gt is a helper function to test if the passed value is greater than or equal to the threshold.

func Len

func Len[T any](t *testing.T, val []T, count int)

Len is a helper function to test if the passed array is of a particular length.

func Lt

func Lt[T constraints.Ordered](t *testing.T, val T, threshold T)

Lt is a helper function to test if the passed value is less than the threshold.

func Lte

func Lte[T constraints.Ordered](t *testing.T, val T, threshold T)

Lte is a helper function to test if the passed value is less than or equal to the threshold.

func Match

func Match(t *testing.T, val string, pattern string)

Match is a helper function to test if the passed string matches a regex.

func Nil added in v1.0.3

func Nil(t *testing.T, val any)

Nil is a helper function to test if a value is nil.

func NotNil added in v1.0.3

func NotNil(t *testing.T, val any)

NotNil is a helper function to test if a value is not nil.

func Panic added in v1.0.4

func Panic(t *testing.T)

Panic is a helper function to test if a panic occurs. This function should usually be called as a deferred function to test after the panic has occurred.

func True

func True(t *testing.T, val bool)

True is a helper function to test a boolean value is true.

Types

This section is empty.

Jump to

Keyboard shortcuts

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