Documentation
¶
Overview ¶
assert provides various assertion functions that can be used to confirm certain conditions such that these conditions are guaranteed true afterwards. These functions are particularly useful to catch unexpected and unsupported use cases, without having to litter the code with if-statements. Assertions may be placeholders for use cases that will later be supported, or they may indicate failure conditions that will not or cannot ever be supported, or cannot even occur. Some use cases or possible error conditions are illusions created by the type-system, for example when a function implements an interface but will never fail the operation. Regardless, assertions allow you to (subtly) handle cases and failure conditions that you do not handle otherwise.
For use in testing, check `/std/testing` for assertions that accept `t` following Go's testing/benchmarking practices.
Index ¶
- func Any[T comparable](actual T, values ...T) T
- func AtLeast[C types.Ordered](least C, value C) C
- func AtMost[C types.Ordered](most C, value C) C
- func EmptyMap[K comparable, V any](collection map[K]V)
- func EmptySlice[E any](collection []E)
- func EmptyString(s string)
- func Equal[T comparable](v1, v2 T)
- func EqualMaps[M1, M2 ~map[K]V, K, V comparable](m1 M1, m2 M2)
- func EqualSlices[S ~[]E, E comparable](s1, s2 S)
- func Failure(err error, message string)
- func False(v bool)
- func Negative[T types.SignedInteger](v T) T
- func NonEmptyMap[K comparable, V any](collection map[K]V)
- func NonEmptySlice[E any](collection []E)
- func NonEmptyString(s string)
- func NonNegative[T types.SignedInteger](v T) T
- func NonPositive[T types.Integer](v T) T
- func NonZero[T types.Integer](v T) T
- func NonZeroSlice[E types.Integer](s []E) []E
- func None[T comparable](actual T, values ...T) T
- func Positive[T types.Integer](v T) T
- func Require(condition bool, message string)
- func Required(val any, message string)
- func Success(err error, message string)
- func True(v bool)
- func Type[T any](unknown any, message string) T
- func Unequal[T comparable](v1, v2 T)
- func UnequalMaps[M1, M2 ~map[K]V, K, V comparable](m1 M1, m2 M2)
- func UnequalSlices[S ~[]E, E comparable](s1, s2 S)
- func Zero[T types.Integer](v T) T
- func ZeroSlice[E types.Integer](s []E) []E
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Any ¶
func Any[T comparable](actual T, values ...T) T
func EmptyMap ¶
func EmptyMap[K comparable, V any](collection map[K]V)
func EmptySlice ¶
func EmptySlice[E any](collection []E)
func EmptyString ¶
func EmptyString(s string)
func Equal ¶
func Equal[T comparable](v1, v2 T)
func EqualMaps ¶
func EqualMaps[M1, M2 ~map[K]V, K, V comparable](m1 M1, m2 M2)
func EqualSlices ¶
func EqualSlices[S ~[]E, E comparable](s1, s2 S)
func Negative ¶
func Negative[T types.SignedInteger](v T) T
func NonEmptyMap ¶
func NonEmptyMap[K comparable, V any](collection map[K]V)
func NonEmptySlice ¶
func NonEmptySlice[E any](collection []E)
func NonEmptyString ¶
func NonEmptyString(s string)
func NonNegative ¶
func NonNegative[T types.SignedInteger](v T) T
func NonPositive ¶
func NonZeroSlice ¶
func None ¶
func None[T comparable](actual T, values ...T) T
func Unequal ¶
func Unequal[T comparable](v1, v2 T)
func UnequalMaps ¶
func UnequalMaps[M1, M2 ~map[K]V, K, V comparable](m1 M1, m2 M2)
func UnequalSlices ¶
func UnequalSlices[S ~[]E, E comparable](s1, s2 S)
Types ¶
This section is empty.