Documentation ¶
Overview ¶
Package testutil provides utilities for writing unit tests.
Index ¶
- func Equal[T comparable](t *testing.T, a, b T)
- func ErrorMatches(t *testing.T, e error, pattern string)
- func NotEqual[T comparable](t *testing.T, a, b T)
- func Ok(t *testing.T, err error)
- func PanicMatches(t *testing.T, fn func(), pattern string)
- func RequiresProgram(t *testing.T, progs ...string)
- func SliceHasLen[T any](t *testing.T, v []T, length int)
- func SlicesEqual[T comparable](t *testing.T, a, b []T)
- func WithOption(t *testing.T, cmd *exec.Cmd, option string)
- func WithOptionValue(t *testing.T, cmd *exec.Cmd, option, value string)
- func WithoutOption(t *testing.T, cmd *exec.Cmd, option string)
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 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 PanicMatches ¶
PanicMatches ensures that function panics with a message that matches the given regular expression.
func RequiresProgram ¶
RequiresProgram skips execution of the test if the given program is absent.
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.
func WithOption ¶
WithOption checks that the given command has a given option.
func WithOptionValue ¶
WithOptionValue checks that the given command has a given option and matching value.
Types ¶
This section is empty.