assert

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2026 License: Apache-2.0 Imports: 4 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package assert provides assertion functions for tests. This is an internal package that was created to provide a simple way to write tests.

The idea was to do not add a dependency on a testing framework.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DeepEqual

func DeepEqual(tb miniTB, want, got any)

DeepEqual asserts that two values are deeply equal.

It can be used with slices, maps, structs with slices...

Please consider Equal for other types.

func DeepEqualf

func DeepEqualf(tb miniTB, want, got any, msgFormat string, args ...any)

DeepEqualf asserts that two values are deeply equal, and reports a message if they are not.

func Equal

func Equal(tb miniTB, want, got any)

Equal asserts that two values are equal.

It can be used with comparable types: numbers, strings, pointers to the same object, etc.

For any other types, use DeepEqual.

func Equalf

func Equalf(tb miniTB, want, got any, msgFormat string, args ...any)

Equalf asserts that two values are equal, and reports a message if they are not.

func ErrorAs

func ErrorAs(tb miniTB, err error, target any)

ErrorAs asserts that an error can be assigned to a target variable by using errors.As.

func ErrorIs

func ErrorIs(tb miniTB, got, want error)

ErrorIs asserts that two errors are equal by using errors.Is.

func ErrorMatches

func ErrorMatches(tb miniTB, pattern string, err error)

ErrorMatches asserts that an error matches a regular expression.

func ErrorMatchesf

func ErrorMatchesf(tb miniTB, pattern string, err error, msgFormat string, args ...any)

ErrorMatchesf asserts that an error matches a regular expression, and reports a message if it does not.

func False

func False(tb miniTB, got bool)

False asserts that a value is false.

func Falsef

func Falsef(tb miniTB, got bool, msgFormat string, args ...any)

Falsef asserts that a value is false, and reports a message if it is not.

func IsNil

func IsNil(tb miniTB, v any)

IsNil asserts that a value is nil.

func IsNilf

func IsNilf(tb miniTB, v any, msgFormat string, args ...any)

IsNilf asserts that a value is nil, and reports a message if it is not.

func NoError

func NoError(tb miniTB, err error)

NoError asserts that an error is nil.

func NoErrorf

func NoErrorf(tb miniTB, err error, msgFormat string, args ...any)

NoErrorf asserts that an error is nil, and reports a message if it is not.

func NotNil

func NotNil(tb miniTB, v any)

NotNil asserts that a value is not nil.

func NotNilf

func NotNilf(tb miniTB, v any, msgFormat string, args ...any)

NotNilf asserts that a value is not nil, and reports a message if it is.

func PanicMatches

func PanicMatches(tb miniTB, pattern string, f func())

PanicMatches asserts that a function panics with a message matching the given pattern.

func PanicMatchesf

func PanicMatchesf(tb miniTB, pattern string, f func(), msgFormat string, args ...any)

PanicMatchesf asserts that a function panics with a message matching the given pattern, and reports a message if it does not.

func True

func True(tb miniTB, got bool)

True asserts that a value is true.

func Truef

func Truef(tb miniTB, got bool, msgFormat string, args ...any)

Truef asserts that a value is true, and reports a message if it is not.

Types

This section is empty.

Jump to

Keyboard shortcuts

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