Documentation ¶
Overview ¶
Package testutil provides utilities for writing unit tests.
Index ¶
- func Equal[T comparable](t *testing.T, a, b T)
- func ErrorAs[T error](t *testing.T, e error) (as T)
- func ErrorIs(t *testing.T, e, other error)
- func ErrorMatches(t *testing.T, e error, pattern string)
- func NotEqual[T comparable](t *testing.T, a, b T)
- func NotNil[X any, T nullable[X]](t *testing.T, v T)
- func NotOk(t *testing.T, err error)
- func ObjectEqual[T Equatable[T]](t *testing.T, a, b T)
- func ObjectSliceEqual[T Equatable[T]](t *testing.T, a, b []T)
- func Ok(t *testing.T, err error)
- func PanicMatches(t *testing.T, fn func(), pattern string)
- func SliceHasLen[T any](t *testing.T, v []T, length int)
- func SlicesEqual[T comparable](t *testing.T, a, b []T)
- type Equatable
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Equal ¶
func Equal[T comparable](t *testing.T, a, b T)
Equal ensures that arguments compare equal.
func ErrorAs ¶
ErrorAs ensures that an error of given type is stored in the given error according to errors.As.
func ErrorMatches ¶
ErrorMatches ensures that error message of the given error matches the given regular expression.
func NotEqual ¶
func NotEqual[T comparable](t *testing.T, a, b T)
NotEqual ensures that arguments are not equal.
func ObjectEqual ¶
ObjectEqual ensures that two objects compare equal with the Equal method.
func ObjectSliceEqual ¶
ObjectSliceEqual ensures that two slices have the same length and that their elements compare equal with the Equal method.
func PanicMatches ¶
PanicMatches ensures that function panics with a message that matches the given regular expression.
func SliceHasLen ¶
SliceHasLen ensures that the argument has given length.
func SlicesEqual ¶
func SlicesEqual[T comparable](t *testing.T, a, b []T)
SlicesEqual ensures that two slices have the same length and that their elements compare equal.