testutil

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package testutil provides utilities for writing unit tests.

Index

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

func ErrorMatches(t *testing.T, e error, pattern string)

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 Ok

func Ok(t *testing.T, err error)

Ok ensures that an error is nil.

func PanicMatches

func PanicMatches(t *testing.T, fn func(), pattern string)

PanicMatches ensures that function panics with a message that matches the given regular expression.

func RequiresProgram

func RequiresProgram(t *testing.T, progs ...string)

RequiresProgram skips execution of the test if the given program is absent.

func SliceHasLen

func SliceHasLen[T any](t *testing.T, v []T, length int)

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

func WithOption(t *testing.T, cmd *exec.Cmd, option string)

WithOption checks that the given command has a given option.

func WithOptionValue

func WithOptionValue(t *testing.T, cmd *exec.Cmd, option, value string)

WithOptionValue checks that the given command has a given option and matching value.

func WithoutOption

func WithoutOption(t *testing.T, cmd *exec.Cmd, option string)

WithoutOption checks that the given command does not have the given option.

Types

This section is empty.

Jump to

Keyboard shortcuts

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