assert

package
v1.8.0 Latest Latest
Warning

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

Go to latest
Published: May 31, 2023 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package assert is a minimal assert package using generics.

This prevents connect from needing additional dependencies.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Equal

func Equal[T any](tb testing.TB, got, want T, options ...Option) bool

Equal asserts that two values are equal.

func ErrorIs

func ErrorIs(tb testing.TB, got, want error, options ...Option) bool

ErrorIs asserts that "want" is in "got's" error chain. See the standard library's errors package for details on error chains. On failure, output is identical to Equal.

func False

func False(tb testing.TB, got bool, options ...Option) bool

False asserts that "got" is false.

func Match

func Match(tb testing.TB, got, want string, options ...Option) bool

Match asserts that the value matches a regexp.

func Nil

func Nil(tb testing.TB, got any, options ...Option) bool

Nil asserts that the value is nil.

func NotEqual

func NotEqual[T any](tb testing.TB, got, want T, options ...Option) bool

NotEqual asserts that two values aren't equal.

func NotNil

func NotNil(tb testing.TB, got any, options ...Option) bool

NotNil asserts that the value isn't nil.

func NotZero

func NotZero[T any](tb testing.TB, got T, options ...Option) bool

NotZero asserts that the value is non-zero.

func Panics

func Panics(tb testing.TB, panicker func(), options ...Option)

Panics asserts that the function called panics.

func True

func True(tb testing.TB, got bool, options ...Option) bool

True asserts that "got" is true.

func Zero

func Zero[T any](tb testing.TB, got T, options ...Option) bool

Zero asserts that the value is its type's zero value.

Types

type Option

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

An Option configures an assertion.

func Sprintf

func Sprintf(template string, args ...any) Option

Sprintf adds a user-defined message to the assertion's output. The arguments are passed directly to fmt.Sprintf for formatting.

If Sprintf is passed multiple times, only the last message is used.

Jump to

Keyboard shortcuts

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