test

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2025 License: Apache-2.0 Imports: 7 Imported by: 0

README

Test Module

This module is used internally in go-generics for its own test suite. You may use it as well if desired. This design prevents any transitive dependencies on other test frameworks and keeps the go.mod file clean.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckComparableEqualIgnoreOrder

func CheckComparableEqualIgnoreOrder[T comparable](result []T, resultName string, expected []T, t TestT)

func CheckContains

func CheckContains[T any](list []T, item T, t TestT)

func CheckEqual

func CheckEqual(result interface{}, resultName string, expectedResult interface{}, t TestT)

func CheckEqualEquateEmpty

func CheckEqualEquateEmpty(result interface{}, resultName string, expectedResult interface{}, t TestT)

CheckEqualEquateEmpty will treat nil and empty values as equal for maps and slices

func CheckEqualEquateEmptyIgnoreOrder

func CheckEqualEquateEmptyIgnoreOrder(result interface{}, resultName string, expectedResult interface{}, t TestT)

CheckEqualEquateEmptyIgnoreOrder will treat nil and empty values as equal for maps and slices

func CheckEqualErrs

func CheckEqualErrs(result interface{}, resultName string, expectedResult interface{}, t TestT)

func CheckErr

func CheckErr(err error, message string, t TestT)

CheckErr will fail a test if an error is detected

func CheckErrs

func CheckErrs(errs []error, message string, t TestT)

CheckErrs will fail a test if an error is detected

func CheckNotOk

func CheckNotOk(ok bool, message string, t TestT)

func CheckOk

func CheckOk(ok bool, message string, t TestT)

func ExpectErr

func ExpectErr(err error, message string, t TestT)

ExpectErr will fail a test if an error is _not_ detected.

func ExpectNil

func ExpectNil(value interface{}, t TestT)

ExpectNil will fail a test if a value is not nil

func ExpectNotNil

func ExpectNotNil(varName string, value interface{}, t TestT)

ExpectNotNil will fail a test if a value is nil

func GenerateRandomLetterString

func GenerateRandomLetterString(n int) string

func Hash64

func Hash64(s string) uint64

Hash64 quickly converts a string to an int64

func MakeFooMaps

func MakeFooMaps(num int) map[int]*Foo

func RandomDurationBetween

func RandomDurationBetween(min time.Duration, max time.Duration) time.Duration

RandomDurationBetween returns a random duration between min/max duration. If min > max, then max is returned.

func RandomNumber

func RandomNumber(max int) int

func RandomNumberBetween

func RandomNumberBetween(min int, max int) int

RandomNumberBetween returns a random number between min and max. If Min > Max, then max is returned.

Types

type Bar

type Bar struct {
	Bing  string
	Order int
}

type Foo

type Foo struct {
	Bar   string
	Baz   string
	Order int
}

func MakeFoos

func MakeFoos(num int) []*Foo

func MakeFoosOrderly

func MakeFoosOrderly(num int) []*Foo

type TestT

type TestT interface {
	Fatalf(format string, args ...any)
	Fatal(args ...any)
	Errorf(format string, args ...any)
	Logf(format string, args ...any)
}

Jump to

Keyboard shortcuts

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