testing

package
v0.0.0-...-c1b4e3e Latest Latest
Warning

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

Go to latest
Published: Jan 30, 2025 License: GPL-3.0, LGPL-3.0 Imports: 4 Imported by: 0

Documentation

Overview

testing contains assertions for use in unit tests. I recommend aliasing the import to 'assert', so that you can call methods with `assert.Equal(t, a, b)` which makes it nicely readable. In addition, one would either use `assert` in production logic, or `std/testing` in unit tests.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AllKeysAbsent

func AllKeysAbsent[K comparable, V any](t testing.TB, set map[K]V, keys []K)

func AllKeysPresent

func AllKeysPresent[K comparable, V any](t testing.TB, set map[K]V, keys []K)

TODO or call KeysAllPresent or something like that? Naming could probably improve here.

func ElementAbsent

func ElementAbsent[K comparable](t testing.TB, set map[K]struct{}, key K)

func ElementPresent

func ElementPresent[K comparable](t testing.TB, set map[K]struct{}, key K)

func Equal

func Equal[T comparable](t testing.TB, a, b T)

func EqualT

func EqualT[T types.Equaler[T]](t testing.TB, a, b T)

func False

func False(t testing.TB, v bool)

func IsError

func IsError(t testing.TB, cause, actual error)

func KeyAbsent

func KeyAbsent[K comparable, V any](t testing.TB, set map[K]V, key K)

func KeyPresent

func KeyPresent[K comparable, V any](t testing.TB, set map[K]V, key K)

func LogOnFailure

func LogOnFailure(t testing.TB, message ...any)

LogOnFailure logs a message if the test is registered as "failed".

func Nil

func Nil(t testing.TB, v interface{})

func NotNil

func NotNil(t testing.TB, v interface{})

func RequirePanic

func RequirePanic(t testing.TB)

func RequireRecover

func RequireRecover(t testing.TB)

func SliceContains

func SliceContains[T comparable](t testing.TB, slice []T, elm T)

func SlicesEqual

func SlicesEqual[E comparable](t testing.TB, expected, actual []E)

func StopOnFailure

func StopOnFailure(t testing.TB, message ...any)

StopOnFailure halts the test immediately if it failed and logs provided message to provide context.

func True

func True(t testing.TB, v bool)

func Unequal

func Unequal[T comparable](t testing.TB, a, b T)

func UnequalT

func UnequalT[T types.Equaler[T]](t testing.TB, a, b T)

func ValueAbsent

func ValueAbsent[K comparable, V comparable](t testing.TB, map_ map[K]V, value V)

func ValuePresent

func ValuePresent[K comparable, V comparable](t testing.TB, map_ map[K]V, value V)

Types

This section is empty.

Jump to

Keyboard shortcuts

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