Discover Packages
github.com/tanasoft1/testkit
assert
package
Version:
v0.1.0
Opens a new window with list of versions in this module.
Published: Aug 4, 2026
License: MIT
Opens a new window with license information.
Imports: 3
Opens a new window with list of imports.
Imported by: 0
Opens a new window with list of known importers.
Jump to ...
Documentation
Overview
Index
Constants
Variables
Functions
Equal(t, got, want)
ErrIs(t, err, target)
Len(t, s, want)
NoErr(t, err)
True(t, cond, format, args)
Types
Source Files
Documentation
Documentation
¶
Package assert provides the minimum assertion vocabulary the Tanasoft testing
standard depends on. Argument order is always (got, want).
func Equal[T any](t TB, got, want T)
func ErrIs(t TB, err, target error)
func Len[S ~[]E, E any](t TB, s S, want int)
func NoErr(t TB, err error)
func True(t TB, cond bool, format string, args ...any)
type TB
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(t TB , err, target error )
ErrIs fails when err does not match target under errors.Is.
func Len[S ~[]E, E any ](t TB , s S, want int )
Len fails when the slice length differs from want.
NoErr fails the test immediately when err is non-nil.
True fails when cond is false, reporting the formatted message.
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.
Source Files
¶
Click to show internal directories.
Click to hide internal directories.