Documentation
¶
Overview ¶
Package assert provides assertion functions for tests. This is an internal package that was created to provide a simple way to write tests.
The idea was to do not add a dependency on a testing framework.
Index ¶
- func DeepEqual(tb miniTB, want, got any)
- func DeepEqualf(tb miniTB, want, got any, msgFormat string, args ...any)
- func Equal(tb miniTB, want, got any)
- func Equalf(tb miniTB, want, got any, msgFormat string, args ...any)
- func ErrorAs(tb miniTB, err error, target any)
- func ErrorIs(tb miniTB, got, want error)
- func ErrorMatches(tb miniTB, pattern string, err error)
- func ErrorMatchesf(tb miniTB, pattern string, err error, msgFormat string, args ...any)
- func False(tb miniTB, got bool)
- func Falsef(tb miniTB, got bool, msgFormat string, args ...any)
- func IsNil(tb miniTB, v any)
- func IsNilf(tb miniTB, v any, msgFormat string, args ...any)
- func NoError(tb miniTB, err error)
- func NoErrorf(tb miniTB, err error, msgFormat string, args ...any)
- func NotNil(tb miniTB, v any)
- func NotNilf(tb miniTB, v any, msgFormat string, args ...any)
- func PanicMatches(tb miniTB, pattern string, f func())
- func PanicMatchesf(tb miniTB, pattern string, f func(), msgFormat string, args ...any)
- func True(tb miniTB, got bool)
- func Truef(tb miniTB, got bool, msgFormat string, args ...any)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DeepEqual ¶
func DeepEqual(tb miniTB, want, got any)
DeepEqual asserts that two values are deeply equal.
It can be used with slices, maps, structs with slices...
Please consider Equal for other types.
func DeepEqualf ¶
DeepEqualf asserts that two values are deeply equal, and reports a message if they are not.
func Equal ¶
func Equal(tb miniTB, want, got any)
Equal asserts that two values are equal.
It can be used with comparable types: numbers, strings, pointers to the same object, etc.
For any other types, use DeepEqual.
func ErrorAs ¶
ErrorAs asserts that an error can be assigned to a target variable by using errors.As.
func ErrorIs ¶
func ErrorIs(tb miniTB, got, want error)
ErrorIs asserts that two errors are equal by using errors.Is.
func ErrorMatches ¶
ErrorMatches asserts that an error matches a regular expression.
func ErrorMatchesf ¶
ErrorMatchesf asserts that an error matches a regular expression, and reports a message if it does not.
func PanicMatches ¶
func PanicMatches(tb miniTB, pattern string, f func())
PanicMatches asserts that a function panics with a message matching the given pattern.
func PanicMatchesf ¶
PanicMatchesf asserts that a function panics with a message matching the given pattern, and reports a message if it does not.
Types ¶
This section is empty.