assert

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package assert provides minimal test assertion helpers. All functions stop the test immediately on failure (t.Fatalf).

Design: keep this package small — avoid adding new functions unless there is a clear need that cannot be covered by the existing ones. Prefer: Equal for comparable types, BytesEqual for []byte, DeepEqual for structs/maps/slices, True for boolean conditions, and Nil for nil checks.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BytesEqual

func BytesEqual(t testing.TB, expected, actual []byte, a ...any)

BytesEqual asserts that two byte slices are equal. On failure it reports the length mismatch or the first differing byte, avoiding logging raw byte slices which can be large and unreadable.

func DeepEqual

func DeepEqual(t testing.TB, expected, actual any, a ...any)

DeepEqual asserts that two values are deeply equal using reflect.DeepEqual. Use for structs, maps, and non-byte slices. Use BytesEqual for []byte.

func Equal

func Equal[T comparable](t testing.TB, expected, actual T, a ...any)

Equal asserts that two comparable values are equal using ==.

func Nil

func Nil(t testing.TB, v any, a ...any)

Nil asserts that v is nil. Uses reflect to handle typed nils (e.g. (*T)(nil)).

func True

func True(t testing.TB, cond bool, a ...any)

True asserts that cond is true.

Types

This section is empty.

Jump to

Keyboard shortcuts

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