Documentation
¶
Overview ¶
Package is contains a simple assertion library for the fun/ensure testing framework. The package name is simple and chosen mostly to namespace a collection of operations for readability effects.
Index ¶
- type That
- func All(ops ...That) That
- func And(ops ...That) That
- func Contained[T comparable](item T, sl []T) That
- func EqualTo[T comparable](a, b T) That
- func Error(e error) That
- func ErrorIs(er, tr error) That
- func False(c bool) That
- func Nil(val any) That
- func NilPtr[T any](val *T) That
- func NotContained[T comparable](item T, sl []T) That
- func NotEqualTo[T comparable](a, b T) That
- func NotError(e error) That
- func NotErrorIs(er, tr error) That
- func NotNil(val any) That
- func NotNilPtr[T any](val *T) That
- func NotPanic(op func()) That
- func NotSubstring(s, substr string) That
- func NotType[T any](v any) That
- func NotZero[T comparable](val T) That
- func Panic(op func()) That
- func Substring(s, substr string) That
- func True(c bool) That
- func Type[T any](v any) That
- func Zero[T comparable](val T) That
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type That ¶
That is the root type for the assertion helpers in this package. Implementations return nil for no-errors, and one or more error messages for failing assertions..
func All ¶ added in v0.10.4
All combines a collection of that expressions. All expressions are run in order, and the error are aggregated. Nil is.That expressions are reported as errors.
func And ¶ added in v0.10.4
And combines a collection of That expression. All constituent expressions are run in order until one fails, at which point the operation aborts.
func Contained ¶
func Contained[T comparable](item T, sl []T) That
Contained asserts that the slice (sl) has at least one element equal to the item.
func EqualTo ¶
func EqualTo[T comparable](a, b T) That
EqualTo asserts that two comparable values are equal to eachother.
func NotContained ¶
func NotContained[T comparable](item T, sl []T) That
NotContained asserts that the slice (sl) has no elements that are equal to the item.
func NotEqualTo ¶
func NotEqualTo[T comparable](a, b T) That
NotEqualTo asserts that two comparable values are not equal to eachother.
func NotErrorIs ¶
NotErrorIs asserts that the error (er) is not, and does not unwrap to, the target (tr) error.
func NotPanic ¶
func NotPanic(op func()) That
NotPanic asserts that the function (op) does not panic when executed.
func NotSubstring ¶
NotSubstring asserts that the string (s) does not contain the substring (substr.)
func NotZero ¶
func NotZero[T comparable](val T) That
NotZero asserts that the comparable value is not equal to the zero value for the type T.
func Zero ¶
func Zero[T comparable](val T) That
Zero asserts that the comparable value is equal to the zero value for the type T.