testutils

package module
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Equal

func Equal[V comparable](tt TestingIface, want, got V, msgAndArgs ...any) bool

Equal asserts comparables.

testutils.Equal(t, "hello", "hello")

func EqualAny

func EqualAny(tt TestingIface, want, got any, msgAndArgs ...any) bool

func EqualAnyf

func EqualAnyf(tt TestingIface, want, got any, msg string, args ...any) bool

func Error

func Error(tt TestingIface, err error, msgAndArgs ...any) bool

Error assert that err != nil

func ErrorIs

func ErrorIs(tt TestingIface, err, target error, msgAndArgs ...any) bool

ErrorIs asserts errors.Is(err, target)

func False

func False(tt TestingIface, value bool, msgAndArgs ...any) bool

False asserts that the specified value is false.

testutils.False(t, myBool)

func HasPrefix added in v0.5.0

func HasPrefix(tt TestingIface, s, prefix string, msgAndArgs ...any) bool

func HasSuffix added in v0.5.0

func HasSuffix(tt TestingIface, s, suffix string, msgAndArgs ...any) bool

func KeyValErrorMsg

func KeyValErrorMsg(key string, val any) string

func Nil

func Nil(tt TestingIface, value any, msgAndArgs ...any) bool

Nil asserts that the specified value is nil.

func NoError

func NoError(ti TestingIface, err error, msgAndArgs ...any) bool

NoError asserts that a function returned no error (i.e. `nil`).

  actualObj, err := SomeFunction()
  if testutils.NoError(t, err) {
	   testutils.Equal(t, expectedObj, actualObj)
  }

func NotEqual

func NotEqual[V comparable](tt TestingIface, want, got V, msgAndArgs ...any) bool

func NotNil

func NotNil(tt TestingIface, value any, msgAndArgs ...any) bool

NotNil asserts that the specified value is not nil.

testutils.NotNil(t, &val)

func ObjectsAreEqual

func ObjectsAreEqual(expected, actual interface{}) bool

ObjectsAreEqual determines if two objects are considered equal.

This function does no assertion of any kind.

func True

func True(tt TestingIface, value bool, msgAndArgs ...any) bool

True asserts that the specified value is true.

testutils.True(t, myBool)

Types

type Data added in v0.6.0

type Data[IN, WANT any] []struct {
	Name string
	In   IN
	Want WANT
}

type Result added in v0.6.0

type Result[T comparable] struct {
	Title string
	Want  T
	Got   T
}

type Results added in v0.6.0

type Results[T comparable] []Result[T]

func NewResults added in v0.6.0

func NewResults[T comparable]() Results[T]

func (*Results[T]) Add added in v0.6.0

func (td *Results[T]) Add(name string, want, got T)

func (Results[T]) Test added in v0.6.0

func (td Results[T]) Test(ti TestingIface)

type TestingIface

type TestingIface interface {
	Errorf(format string, args ...any)
	Name() string
	Helper()
}

TestingIface is an interface wrapper for *testing.T, *testing.B, *testing.F

Jump to

Keyboard shortcuts

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