assert

package
v0.7.4 Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2023 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Contains

func Contains(t testing.TB, body, substr string, opts ...Option) bool

Contains asserts that one string contains another

func Equal

func Equal(t testing.TB, got, want interface{}, opts ...Option) bool

Equal asserts two objects are equal

func ErrorIs

func ErrorIs(t testing.TB, got, expected error)

ErrorIs asserts that error is not nil and it matches the expected error

func Fail

func Fail(t testing.TB, fmt string, args ...interface{})

Fail marks the test as failed, but continues execution

func False

func False(t testing.TB, got bool, opts ...Option) bool

False is a shortcut for Equals(false)

func IsNil

func IsNil(t testing.TB, got interface{}, opts ...Option) bool

IsNil is a shortcut for Equals(nil)

func NoErr

func NoErr(t testing.TB, err error)

NoErr is a shortcut for Nil(..., assert.Must())

func NotEqual

func NotEqual(t testing.TB, got, want interface{}, opts ...Option) bool

NotEqual asserts two objects are not equal

func NotNil

func NotNil(t testing.TB, got interface{}, opts ...Option) bool

NotNil is a shortcut for !Equals(nil)

func True

func True(t testing.TB, got bool, opts ...Option) bool

True is a shortcut for Equals(true)

Types

type Option

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

Option defines a way to modify assert behavior

func CmpOpt

func CmpOpt(o cmp.Option) Option

CmpOpt adds a cmp.Option from the underlying lib Useful for things like .IgnoreUnexported

func Diff

func Diff() Option

Diff prints a diff between got & want on failure

func Errorf

func Errorf(msg string, args ...interface{}) Option

Errorf adds a more specific message to the failure

func Must

func Must() Option

Must stops the test if this assert fails Useful if you're just going to run into eg. a nil pointer deref next

Jump to

Keyboard shortcuts

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