assert

package
v3.2.0-rc1 Latest Latest
Warning

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

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

Documentation

Overview

Package assert is a minimal assert package using reflection.

This prevents triple from needing additional dependencies.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Equal

func Equal(tb testing.TB, got, want interface{}, 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 interface{}, options ...Option) bool

Nil asserts that the value is nil.

func NotEqual

func NotEqual(tb testing.TB, got, want interface{}, options ...Option) bool

NotEqual asserts that two values are not equal.

func NotNil

func NotNil(tb testing.TB, got interface{}, options ...Option) bool

NotNil asserts that the value isn't nil.

func NotZero

func NotZero(tb testing.TB, got interface{}, 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(tb testing.TB, got interface{}, 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 ...interface{}) 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