...

Package assert

import "cdr.dev/slog/sloggers/slogtest/assert"
Overview
Index

Overview ▾

Package assert is a helper package for test assertions.

On failure, every assertion will fatal the test.

The name parameter is available in each assertion for easier debugging.

func Equal

func Equal(t testing.TB, name string, exp, act interface{}, opts ...cmp.Option)

Equal asserts exp == act.

If they are not equal, it will fatal the test with a diff of the two objects.

Errors will be compared with errors.Is.

func Error

func Error(t testing.TB, name string, err error)

Error asserts err != nil.

func ErrorContains

func ErrorContains(t testing.TB, name string, err error, sub string)

ErrorContains asserts err != nil and err.Error() contains sub.

The match will be case insensitive.

func False

func False(t testing.TB, name string, act bool)

False asserts act == false.

func Success

func Success(t testing.TB, name string, err error)

Success asserts err == nil.

func True

func True(t testing.TB, name string, act bool)

True asserts act == true.