be

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package be provides a set of built-in assertions for use with ghost.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func All

func All(results ...ghost.Result) ghost.Result

All asserts that every one of the provided assertions is true.

func Any

func Any(results ...ghost.Result) ghost.Result

Any asserts that at least one of the provided assertions is true.

func Close

func Close[T constraints.Integer | constraints.Float](got, want, delta T) ghost.Result

Close asserts that a value is within a delta of another.

func DeepEqual

func DeepEqual[T any](got, want T) ghost.Result

DeepEqual asserts that two elements are deeply equal.

func Equal

func Equal[T comparable](got T, want T) ghost.Result

Equal asserts that two elements are equal.

func Error

func Error(err error) ghost.Result

Error asserts that an error is non-nil.

func ErrorAs

func ErrorAs(err error, target any) ghost.Result

ErrorAs asserts that an error matches another using errors.As.

func ErrorContaining

func ErrorContaining(err error, msg string) ghost.Result

ErrorContaining asserts that an error string contains a particular substring.

func ErrorEqual

func ErrorEqual(err error, msg string) ghost.Result

ErrorEqual asserts that an error string equals a particular message.

func ErrorIs

func ErrorIs(err error, target error) ghost.Result

ErrorIs asserts that an error matches another using errors.Is.

func Eventually

func Eventually(
	f func() ghost.Result,
	timeout time.Duration,
	interval time.Duration,
) ghost.Result

Eventually asserts that a function eventually returns an Ok ghost.Result.

func False

func False(b bool) ghost.Result

False asserts that a value is false.

func Greater

func Greater[T constraints.Ordered](a, b T) ghost.Result

Greater asserts that the first value provided is strictly greater than the second.

func GreaterOrEqual

func GreaterOrEqual[T constraints.Ordered](a, b T) ghost.Result

GreaterOrEqual asserts that the first value provided is greater than or equal to the second.

func JSONEqual

func JSONEqual[T ~string | ~[]byte](got, want T) ghost.Result

JSONEqual asserts that two sets of JSON-encoded data are equivalent.

func Less

func Less[T constraints.Ordered](a, b T) ghost.Result

Less asserts that the first value provided is strictly less than the second.

func LessOrEqual

func LessOrEqual[T constraints.Ordered](a, b T) ghost.Result

LessOrEqual asserts that the first value provided is less than or equal to the second.

func MapLen

func MapLen[K comparable, V any](got map[K]V, want int) ghost.Result

MapLen asserts that the length of a map is a particular size.

func Nil

func Nil(v any) ghost.Result

Nil asserts that the given value is nil.

func Not

func Not(result ghost.Result) ghost.Result

Not negates a ghost.Result.

func Panic

func Panic(f func()) (result ghost.Result)

Panic asserts that the given function panics when invoked.

func SliceContaining

func SliceContaining[T comparable](slice []T, element T) ghost.Result

SliceContaining asserts that an element exists in a given slice.

func SliceLen

func SliceLen[T any](got []T, want int) ghost.Result

SliceLen asserts that the length of a slice is a particular size.

func StringContaining

func StringContaining(str, substr string) ghost.Result

StringContaining asserts that a substring exists in a given string.

func True

func True(b bool) ghost.Result

True asserts that a value is true.

func Zero

func Zero[T comparable](v T) ghost.Result

Zero asserts that the given value equals its zero value.

Types

This section is empty.

Jump to

Keyboard shortcuts

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