is

package module
v0.0.0-...-15f7128 Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2024 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Contains

func Contains[V comparable, S ~[]V](t T, item V, slice S)

Contains checks if the input slice contains the input item, provided that they are of a comparable type.

func ElementsMatch

func ElementsMatch[V cmp.Ordered, S ~[]V](t T, expected, actual S)

ElementsMatch asserts that the elements in the expected slice match the elements in the actual slice, regardless of their order. If order is important, either slices.Equal or EqualElements should be preferable options.

Ex:

  • expected: [1, 2, 3]
  • actual: [3, 1, 2]
  • result: OK

func Empty

func Empty[V comparable](t T, item V)

Empty asserts that the input item is empty -- applicable for concrete types. For pointer types, see EmptyValue instead.

Note that this function does not check if the input is an interface that carries a nil input.

func EmptyValue

func EmptyValue[V comparable](t T, item *V)

EmptyValue asserts that the pointer to the input item is empty -- be it a zero input or nil, however applicable.

Note that this function does not check if the input is an interface that carries a nil input.

func Equal

func Equal[V comparable](t T, expected, actual V)

Equal asserts that two values are equal, provided that they are of a comparable type -- applicable for concrete types. For pointer types, see EqualValue instead.

func EqualElements

func EqualElements[V cmp.Ordered, S ~[]V](t T, expected, actual S)

EqualElements asserts that the elements match the ones in the actual slice, in both position and input. It is a shorthand for calling slices.Equal.

Ex:

  • expected: [1, 2, 3]
  • actual: [1, 2, 3]
  • result: OK

func EqualValue

func EqualValue[V comparable](t T, expected, actual *V)

EqualValue asserts that the values in the two input pointers are equal, provided that they are of a comparable type.

func False

func False(t T, value bool)

False is the same as calling Equal(t, false, input)

func NilError

func NilError(t T, err error)

NilError is the same as calling Empty(t, err).

func True

func True(t T, value bool)

True is the same as calling Equal(t, true, input)

Types

type T

type T interface {
	// Logf formats its arguments according to the format, analogous to Printf, and records the text in the error log.
	// A final newline is added if not provided.
	//
	// For tests, the text will be printed only if the test fails or the -test.v flag is set.
	//
	// For benchmarks, the text is always printed to avoid having performance depend on the input of the -test.v flag.
	Logf(format string, args ...any)
	// Fail marks the function as having failed but continues execution.
	Fail()
}

Jump to

Keyboard shortcuts

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