xtesting

package
v0.22.0 Latest Latest
Warning

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

Go to latest
Published: Jun 21, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Expect

func Expect(
	t TestingT,
	failMessage string,
	got, want any,
	options ...cmp.Option,
)

Expect compares two values and fails the test if they are different.

func ExpectContains

func ExpectContains[T any](
	t TestingT,
	failMessage string,
	slice []T,
	want T,
	options ...cmp.Option,
)

ExpectContains asserts that slice contains an element equal to want.

func ExpectLocation added in v0.22.0

func ExpectLocation(
	t TestingT,
	loc location.Location,
	fileSuffix string,
)

ExpectLocation asserts that loc has a non-empty Func, a non-zero Line, and that its File ends with the given suffix.

func ExpectPanic

func ExpectPanic(
	t TestingT,
	want string,
	fn func(),
)

ExpectPanic asserts that a function panics with a specific value.

func ExpectPanicMatching added in v0.22.0

func ExpectPanicMatching[T any](
	t TestingT,
	fn func(),
	match func(T),
)

ExpectPanicMatching asserts that fn panics with a value of type T, then calls match to make further assertions about the panic value.

func ExpectSet added in v0.22.0

func ExpectSet[T any](
	t TestingT,
	failMessage string,
	got, want []T,
	less func(T, T) bool,
	options ...cmp.Option,
)

ExpectSet compares two slices as unordered sets, failing the test if they differ. The less function determines sort order for comparison.

Types

type TestingT

type TestingT interface {
	Helper()
	Fatal(args ...any)
	Log(args ...any)
	Failed() bool
}

TestingT is the subset of testing.TB needed by these helpers.

Jump to

Keyboard shortcuts

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