is

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Mar 2, 2024 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Default

func Default[V comparable](c *config, v V)

Assert that the given value is the default value for the given type.

func Equal

func Equal[V comparable](c *config, a, b V)

Assert that the two given comparable values are equal.

Use SliceEqual to compare slices.

func Err

func Err(c *config, err error)

Assert that the given error is not nil.

func NewRelaxed

func NewRelaxed(t T) *config

NewRelaxed creates tinytest config that does not stop test execution on failed assertions.

A version of this function that does stop the execution will be provided in later releases.

func NilPointer

func NilPointer[V any](c *config, v *V)

Assert that the given pointer is nil.

func Not

func Not(c *config) *config

Not negates the assertion that uses the wrapped config.

func Panic

func Panic(c *config, f func())

Assert that the given function panics.

func SliceContains

func SliceContains[S ~[]I, I comparable](c *config, s S, v I)

Assert that the given slice contains the given element.

func SliceEmpty

func SliceEmpty[S ~[]I, I any](c *config, s S)

Assert that the given slice is empty

func SliceEqual

func SliceEqual[S1 ~[]I, S2 ~[]I, I comparable](c *config, s1 S1, s2 S2)

Assert that the given slices are equal (the smae length and the same elements).

func True

func True(c *config, ok bool)

Assert that the given condition is true.

Types

type T

type T interface {
	// Fail marks the test as failed but continues execution.
	Fail()

	// FailNow marks the test as failed and immediately interrupts execution.
	FailNow()

	// True if the test is already marked as failed.
	Failed() bool

	// Helper marks a function as a helper function.
	//
	// Helper functions are not included in tracebacks.
	Helper()

	// Logf is like [fmt.Sprintf] and used in tests for error messages and traces.
	Logf(format string, args ...any)
}

T is the current test state manager.

T is implemented by testing.T, testing.B, and testing.F.

Jump to

Keyboard shortcuts

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