assert

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 4, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package assert provides the minimum assertion vocabulary the Tanasoft testing standard depends on. Argument order is always (got, want).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Equal

func Equal[T any](t TB, got, want T)

Equal reports a failure when got and want differ, printing a structural diff.

Equal uses go-cmp, which panics on types with unexported fields. Compare primitives, strings, slices of those, or structs whose fields are exported. For anything else, compare the specific fields you care about.

func ErrIs

func ErrIs(t TB, err, target error)

ErrIs fails when err does not match target under errors.Is.

func Len

func Len[S ~[]E, E any](t TB, s S, want int)

Len fails when the slice length differs from want.

func NoErr

func NoErr(t TB, err error)

NoErr fails the test immediately when err is non-nil.

func True

func True(t TB, cond bool, format string, args ...any)

True fails when cond is false, reporting the formatted message.

Types

type TB

type TB interface {
	Helper()
	Errorf(format string, args ...any)
	Fatalf(format string, args ...any)
}

TB is the subset of testing.TB these helpers need. Accepting an interface lets the helpers be tested without failing the enclosing test.

Jump to

Keyboard shortcuts

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