assert

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: May 2, 2024 License: MPL-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package assert implements assertions for the standard testing package.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AsErr

func AsErr[T Param](t TB, err error, target any, formatAndArgs ...any)

AsErr asserts that errors.As(err, target) is true.

func Equal

func Equal[T Param, V any](t TB, got, want V, formatAndArgs ...any)

Equal asserts that two values are equal.

func IsErr

func IsErr[T Param](t TB, err, target error, formatAndArgs ...any)

IsErr asserts that errors.Is(err, target) is true.

func NoErr

func NoErr[T Param](t TB, err error, formatAndArgs ...any)

NoErr asserts that the error is nil.

func Panics added in v0.10.0

func Panics[T Param](t TB, fn func(), v any, formatAndArgs ...any)

Panics asserts that the given function panics with the argument v. If v is nil, the panic argument is ignored.

Types

type E

type E struct{}

E is a Param that marks the test as failed but continues execution (similar to testing.T.Errorf).

type F

type F struct{}

F is a Param that marks the test as failed and stops execution (similar to testing.T.Fatalf).

type Param added in v0.10.0

type Param interface {
	// contains filtered or unexported methods
}

Param controls the behavior of an assertion if it fails. Either E or F must be specified as the type parameter.

type TB

type TB interface {
	Helper()
	Errorf(format string, args ...any)
	Fatalf(format string, args ...any)
}

TB is a tiny subset of testing.TB.

Directories

Path Synopsis
Package EF provides type aliases for the parent [assert] package.
Package EF provides type aliases for the parent [assert] package.

Jump to

Keyboard shortcuts

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