assert

package
v0.0.0-...-bc49051 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 27, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Fatalf

func Fatalf(t *testing.T, format string, args, message []any)

Fatalf is a helper to fatal a test with optional message components.

func ItContains

func ItContains(t *testing.T, s string, substr any, message ...any)

ItContains a test helper to verify that a string contains a given string.

func ItHasPrefix

func ItHasPrefix(t *testing.T, corpus string, prefix any, message ...any)

ItContains a test helper to verify that a string contains a given string.

func ItHasSuffix

func ItHasSuffix(t *testing.T, corpus string, suffix any, message ...any)

ItContains a test helper to verify that a string contains a given string.

func ItMatches

func ItMatches(t *testing.T, expr string, actual any, message ...any)

ItMatches is a test helper to verify that an expression matches a given string.

func ItNotContains

func ItNotContains(t *testing.T, s string, substr any, message ...any)

ItContains a test helper to verify that a string does not contain a given string.

func ItNotHasPrefix

func ItNotHasPrefix(t *testing.T, corpus string, prefix any, message ...any)

ItContains a test helper to verify that a string does not contain a given string.

func ItNotHasSuffix

func ItNotHasSuffix(t *testing.T, corpus string, suffix any, message ...any)

ItContains a test helper to verify that a string does not contain a given string.

func ItNotMatches

func ItNotMatches(t *testing.T, expr string, actual any, message ...any)

ItNotMatches is a test helper to verify that an expression does not match a given string.

func ItNotPanics

func ItNotPanics[T any](t *testing.T, fn func() T, message ...any) (out T)

ItNotPanics is an assertion helper.

It will test that a given function panics using a recovery.

func ItPanics

func ItPanics(t *testing.T, fn func(), message ...any)

ItPanics is an assertion helper.

It will test that a given function panics using a recovery.

func ItsAll

func ItsAll[T any](t *testing.T, values []T, fn func(T) bool, message ...any)

ItsAll is an assertion helper.

It will test that all values in the slice match the filter.

func ItsAny

func ItsAny[T any](t *testing.T, values []T, fn func(T) bool, message ...any)

ItsAny is an assertion helper.

It will test that any value in the slice matches the filter.

func ItsEmpty

func ItsEmpty(t *testing.T, v any, message ...any)

ItsEmpty is an assertion helper.

It will test that the given value is empty, printing the value if the value has a string form.

func ItsEpsilon

func ItsEpsilon[T IEpsilon](t *testing.T, actual, expected, epsilon T, message ...any)

ItsEpsilon asserts that two numbers are within an epsilon of each other.

func ItsEqual

func ItsEqual(t *testing.T, expected, actual any, message ...any)

ItsEqual is a test helper to verify that two arguments are equal.

You can use it to build up other assertions, such as for length or not-nil.

func ItsFalse

func ItsFalse(t *testing.T, expectedFalse bool, message ...any)

ItsFalse is a helper that tests a value expected to be true.

func ItsInTimeDelta

func ItsInTimeDelta(t *testing.T, t0, t1 time.Time, d time.Duration, userMessage ...any)

ItsInTimeDelta is a test helper to verify that two times are within a given duration.

It works strictly in an absolute sense, that is if one time is before another, or vice versa the delta will always be positive.

func ItsLen

func ItsLen(t *testing.T, v interface{}, expected int, message ...any)

ItsLen is an assertion helper.

It will test that the given value has a given length.

func ItsNil

func ItsNil(t *testing.T, v any, message ...any)

ItsNil is an assertion helper.

It will test that the given value is nil, printing the value if the value has a string form.

func ItsNone

func ItsNone[T comparable](t *testing.T, values []T, fn func(T) bool, message ...any)

ItsNone is an assertion helper.

It will test that none of the values in the slice match the filter.

func ItsNotEmpty

func ItsNotEmpty(t *testing.T, v any, message ...any)

ItsNotEmpty is an assertion helper.

It will test that the given value is not empty.

func ItsNotEqual

func ItsNotEqual(t *testing.T, expected, actual any, message ...any)

ItsNotEqual is a test helper to verify that two arguments are not equal.

You can use it to build up other assertions, such as for length or not-nil.

func ItsNotInTimeDelta

func ItsNotInTimeDelta(t *testing.T, t0, t1 time.Time, d time.Duration, userMessage ...any)

ItsNotInTimeDelta is a test helper to verify that two times are within a given duration.

It works strictly in an absolute sense, that is if one time is before another, or vice versa the delta will always be positive.

func ItsNotNil

func ItsNotNil(t *testing.T, v any, message ...any)

ItsNotNil is an assertion helper.

It will test that the given value is not nil.

func ItsNotZero

func ItsNotZero(t *testing.T, actual any, message ...any)

ItsNotZero is a test helper to verify that an argument is not zero.

func ItsTrue

func ItsTrue(t *testing.T, expectedTrue bool, message ...any)

ItsTrue is a helper that tests a value expected to be true.

func ItsZero

func ItsZero(t *testing.T, actual any, message ...any)

ItsZero is a test helper to verify that an argument is zero.

func Len

func Len(object any) int

Len returns the length of a given reference if it is a slice, string, channel, or map.

func Nil

func Nil(object any) bool

Nil returns if a given reference is nil, but also returning true if the reference is a valid typed pointer to nil, which may not strictly be equal to nil.

Types

type IEpsilon

type IEpsilon interface {
	~int | ~float64
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL