testutils

package module
v0.0.0-...-cf743e4 Latest Latest
Warning

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

Go to latest
Published: Jan 20, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

README

testutils

A minimalistic, zero-dependency testing helper for Go.

testutils is a lightweight alternative to heavy assertion libraries like testify/assert. It provides a single "Swiss Army knife" function—Equal—that intelligently handles assertions for all kinds of data types, reducing boilerplate without bloating your go.mod.

Key Features

  • The "Switch Knife" Function: One function (Equal) capable of comparing scalars, errors, structs, slices, and maps. You don't need AssertNil, AssertMapEqual, or AssertString.
  • Zero Dependencies: Keeps your project's dependency graph clean.
  • Reflect-Based: Automatically handles deep equality checks for complex structures, making it a powerful drop-in for standard Go testing.
  • Readable Output: formatted error messages when assertions fail, making debugging easier.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ApproximatelyEqual

func ApproximatelyEqual(a, b float64) bool

ApproximatelyEqual function to test if two real numbers are (almost) equal

func Equal

func Equal(t testing.TB, received, expected interface{})

Equal checks if two variables are equal

func EqualError

func EqualError(v, e error) bool

EqualError return true if two errors are equal

func EqualJSON

func EqualJSON(t testing.TB, received, expected []byte)

EqualJSON compare JSONs

func IsEqual

func IsEqual(received, expected interface{}) bool

IsEqual check if two interface equal

func NotEqual

func NotEqual(t testing.TB, received, expected interface{})

NotEqual checks if two variables are not equal

func NotEqualJSON

func NotEqualJSON(t testing.TB, received, expected []byte)

NotEqualJSON compare JSONs

Types

This section is empty.

Jump to

Keyboard shortcuts

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