Documentation
¶
Overview ¶
testing contains assertions for use in unit tests. I recommend aliasing the import to 'assert', so that you can call methods with `assert.Equal(t, a, b)` which makes it nicely readable. In addition, one would either use `assert` in production logic, or `std/testing` in unit tests.
Index ¶
- func AllKeysAbsent[K comparable, V any](t testing.TB, set map[K]V, keys []K)
- func AllKeysPresent[K comparable, V any](t testing.TB, set map[K]V, keys []K)
- func ElementAbsent[K comparable](t testing.TB, set map[K]struct{}, key K)
- func ElementPresent[K comparable](t testing.TB, set map[K]struct{}, key K)
- func Equal[T comparable](t testing.TB, a, b T)
- func EqualT[T types.Equaler[T]](t testing.TB, a, b T)
- func False(t testing.TB, v bool)
- func IsError(t testing.TB, cause, actual error)
- func KeyAbsent[K comparable, V any](t testing.TB, set map[K]V, key K)
- func KeyPresent[K comparable, V any](t testing.TB, set map[K]V, key K)
- func LogOnFailure(t testing.TB, message ...any)
- func Nil(t testing.TB, v interface{})
- func NotNil(t testing.TB, v interface{})
- func RequirePanic(t testing.TB)
- func RequireRecover(t testing.TB)
- func SliceContains[T comparable](t testing.TB, slice []T, elm T)
- func SlicesEqual[E comparable](t testing.TB, expected, actual []E)
- func StopOnFailure(t testing.TB, message ...any)
- func True(t testing.TB, v bool)
- func Unequal[T comparable](t testing.TB, a, b T)
- func UnequalT[T types.Equaler[T]](t testing.TB, a, b T)
- func ValueAbsent[K comparable, V comparable](t testing.TB, map_ map[K]V, value V)
- func ValuePresent[K comparable, V comparable](t testing.TB, map_ map[K]V, value V)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AllKeysAbsent ¶
func AllKeysAbsent[K comparable, V any](t testing.TB, set map[K]V, keys []K)
func AllKeysPresent ¶
func AllKeysPresent[K comparable, V any](t testing.TB, set map[K]V, keys []K)
TODO or call KeysAllPresent or something like that? Naming could probably improve here.
func ElementAbsent ¶
func ElementAbsent[K comparable](t testing.TB, set map[K]struct{}, key K)
func ElementPresent ¶
func ElementPresent[K comparable](t testing.TB, set map[K]struct{}, key K)
func Equal ¶
func Equal[T comparable](t testing.TB, a, b T)
func KeyPresent ¶
func KeyPresent[K comparable, V any](t testing.TB, set map[K]V, key K)
func LogOnFailure ¶
LogOnFailure logs a message if the test is registered as "failed".
func RequirePanic ¶
func RequireRecover ¶
func SliceContains ¶
func SliceContains[T comparable](t testing.TB, slice []T, elm T)
func SlicesEqual ¶
func SlicesEqual[E comparable](t testing.TB, expected, actual []E)
func StopOnFailure ¶
StopOnFailure halts the test immediately if it failed and logs provided message to provide context.
func Unequal ¶
func Unequal[T comparable](t testing.TB, a, b T)
func ValueAbsent ¶
func ValueAbsent[K comparable, V comparable](t testing.TB, map_ map[K]V, value V)
func ValuePresent ¶
func ValuePresent[K comparable, V comparable](t testing.TB, map_ map[K]V, value V)
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.