assert

package
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Equal

func Equal[Type any](t common.T, want Type, got Type, opts ...gocmp.Option)

Equal passes if want == got.

Otherwise, the test is immediately failed and stopped with t.FailNow().

This is a typesafe check for equality using go-cmp, allowing arguments only of the same type to be compared.

You can change the behavior of the equality checking using the go-cmp/cmp Options system. For more information, see [the go-cmp documentation](https://pkg.go.dev/github.com/google/go-cmp/cmp#Equal).

func Error

func Error(t common.T, err error)

Error passes if err != nil.

Otherwise, the test is immediately failed and stopped with t.FailNow().

func False

func False(t common.T, x bool)

False passes if x == false.

Otherwise, the test is immediately failed and stopped with t.FailNow().

func GreaterThan

func GreaterThan[Type cmp.Ordered](t common.T, big Type, small Type)

GreaterThan passes if big > small.

Otherwise, the test is immediately failed and stopped with t.FailNow().

func GreaterThanOrEqual

func GreaterThanOrEqual[Type cmp.Ordered](t common.T, big Type, small Type)

GreaterThanOrEqual passes if big >= small.

Otherwise, the test is immediately failed and stopped with t.FailNow().

func In

func In[Type any](t common.T, want Type, slice []Type, opts ...gocmp.Option)

In passes if want is an element of slice.

Otherwise, the test is immediately failed and stopped with t.FailNow().

You can change the behavior of the equality checking using the go-cmp/cmp Options system. For more information, see [the go-cmp documentation](https://pkg.go.dev/github.com/google/go-cmp/cmp#Equal).

func LessThan

func LessThan[Type cmp.Ordered](t common.T, small Type, big Type)

LessThan passes if small < big.

Otherwise, the test is immediately failed and stopped with t.FailNow().

func LessThanOrEqual

func LessThanOrEqual[Type cmp.Ordered](t common.T, small Type, big Type)

LessThanOrEqual passes if small <= big.

Otherwise, the test is immediately failed and stopped with t.FailNow().

func Nil

func Nil(t common.T, val any)

Nil passes if val == nil.

Otherwise, the test is immediately failed and stopped with t.FailNow().

Uses reflection because Go doesn't have a type constraint for "nilable". Can return false for the following types:

  • error
  • pointer
  • interface
  • map
  • slice
  • channel
  • function
  • unsafe.Pointer

func NoError added in v0.0.4

func NoError(t common.T, err error)

NoError passes if err == nil

Otherwise, the test is immediately failed and stopped with t.FailNow().

func NoErrors

func NoErrors(t common.T, thunks ...(func() error))

NoErrors will exit the test immediately if any checks have previously failed. Then, if supplied, thunks will be called. If the code in the thunk resulted in a non-fatal test error, the test is immediately failed. If the thunk returns an error value, the test is immediately failed.

func NoFailures

func NoFailures(t common.T, thunks ...(func()))

NoFailures will exit the test immediately if any checks have previously failed. Then, if supplied, thunks will be called. If the code in the thunk resulted in a non-fatal test error, the test is immediately failed.

func NotEqual

func NotEqual[Type any](t common.T, want Type, got Type, opts ...gocmp.Option)

NotEqual passes if want != got.

Otherwise, the test is immediately failed and stopped with t.FailNow().

This is a typesafe check for inequality using go-cmp, allowing arguments only of the same type to be compared.

You can change the behavior of the inequality checking using the go-cmp/cmp Options system. For more information, see [the go-cmp documentation](https://pkg.go.dev/github.com/google/go-cmp/cmp#Equal).

func NotIn

func NotIn[Type any](t common.T, want Type, slice []Type, opts ...gocmp.Option)

NotIn passes if want is not an element of slice.

Otherwise, the test is immediately failed and stopped with t.FailNow().

You can change the behavior of the inequality checking using the go-cmp/cmp Options system. For more information, see [the go-cmp documentation](https://pkg.go.dev/github.com/google/go-cmp/cmp#Equal).

func NotNil added in v0.0.6

func NotNil(t common.T, val any)

NotNil passes if val != nil.

Otherwise, the test is immediately failed and stopped with t.FailNow().

Uses reflection because Go doesn't have a type constraint for "nilable". Can return false for the following types:

  • error
  • pointer
  • interface
  • map
  • slice
  • channel
  • function
  • unsafe.Pointer

func True

func True(t common.T, x bool)

True passes if x == true.

Otherwise, the test is immediately failed and stopped with t.FailNow().

Types

This section is empty.

Jump to

Keyboard shortcuts

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