check package - code.pfad.fr/check

Package check is a minimalist Go assertion package.

Although [assert libraries are frowned upon] by the Go team, this package aims at reducing the boilerplate while not getting in the way of your tests. Importantly:

assert libraries are frowned upon

keep going

identify the function and input

print diffs

Dedicated to the public domain.

Example

Types

type Failure

Failure allows logging more information in case of failure. All method calls will be no-op on nil (when the check succeeded).

func Equal

Equal calls t.Error if want != got.

func EqualDeep

EqualDeep calls t.Error if ![reflect.DeepEqual](want, got).

reflect.DeepEqual

func EqualSlice

EqualSlice is the slice version of [Equal]. Calls t.Error if want != got with an unified diff.

func True

True calls t.Error with the given args as message if got is not true.

func (*Failure) Fatal

Fatal stops the test execution if the Failure is not nil (no-op otherwise), see [testing.T.FailNow].

testing.T.FailNow

func (*Failure) Log

Log formats its arguments using default formatting, analogous to Println, and records the text in the error log if the Failure is not nil (no-op otherwise).

func (*Failure) Logf

Logf formats its arguments according to the format, analogous to Printf, and records the text in the error log if the Failure is not nil (no-op otherwise)

Files

check.go

diff.go

Forge

https://codeberg.org/pfad.fr/check

git clone