assert

package
v0.0.9 Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EqualComparable

func EqualComparable[T comparable](a, b T) bool

EqualComparable reports whether a and b are equal. Use for comparable types only; no reflection, inlineable.

func EqualValues added in v0.0.9

func EqualValues(t testing.TB, a, b any) bool

EqualValues reports whether a and b are equal. For use as a test helper (accepts testing.TB). For error values, uses errors.Is for wrapped error comparison; otherwise uses reflect.DeepEqual. Moved from matchers package; assert is the single source of truth for equality helpers.

func IsNilValue

func IsNilValue(value any) bool

IsNilValue reports whether value is nil or a nil pointer/slice/map/etc.

func MatchWithFastPath added in v0.0.9

func MatchWithFastPath(matcher Matcher, actual any) (matched bool, failureMsg string)

MatchWithFastPath runs the matcher with direct type dispatch for built-in matchers to avoid interface calls. Returns (matched, failureMsg). Custom matchers fall back to matcher.Match / matcher.FailureMessage.

func ValuesEqual

func ValuesEqual(expected, actual any) bool

ValuesEqual reports whether expected and actual are equal (for use by other packages).

Types

type Matcher

type Matcher interface {
	Match(actual any) bool
	FailureMessage(actual any) string
}

Matcher is the interface for assertion matchers used with Expect(...).To(m).

func BeFalse

func BeFalse() Matcher

BeFalse returns a matcher that expects actual to be the bool false. Returns singleton; zero alloc.

func BeNil

func BeNil() Matcher

BeNil returns a matcher that expects actual to be nil. Returns singleton; zero alloc.

func BeTrue

func BeTrue() Matcher

BeTrue returns a matcher that expects actual to be the bool true. Returns singleton; zero alloc.

func Contain

func Contain(expected any) Matcher

Contain returns a matcher that expects actual (string or slice) to contain expected. Struct-based; no closure.

func Equal

func Equal(expected any) Matcher

Equal returns a matcher that expects actual to equal expected. Struct-based; no closure.

func NotEqual

func NotEqual(expected any) Matcher

NotEqual returns a matcher that expects actual not to equal expected. Struct-based; no closure.

Jump to

Keyboard shortcuts

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