test

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2025 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EqualDecimals

func EqualDecimals(d1, d2 string) bool

EqualDecimals returns true if d1 and d2 are equal decimal strings. Allows for the strings to have a leading + and any number of leading zeros, or trailing zeros after a decimal point.

func NewSeed

func NewSeed() int64

NewSeed returns a new random seed for the random number generator.

func RandomDecimal

func RandomDecimal(precision int, scale int) string

func RandomEnum

func RandomEnum[T ~int](valueList []T) T

func RandomEnumArray

func RandomEnumArray[T ~int](valueList []T) *maps.OrderedSet[T]

func RandomNum

func RandomNum[T constraints.Integer | constraints.Float](low int, high int) T

RandomNum provides a random number in the given range.

func RandomNumberString

func RandomNumberString() string

func RandomValue

func RandomValue[T any](size int) T

RandomValue provides to the generated tests random values for types corresponding to ReceiverType Go types. For strings and []byte types, if size is 0, a size of 10 will be used as a reasonable limit. size will indicate the number of bytes or characters generated. times do not generate fractional seconds, since the value might be truncated depending on the sql dialect and data type.

func UseSeed

func UseSeed(seed int64)

UseSeed uses the given seed to recreate the results from the random number generator.

Types

type GobDecoder

type GobDecoder struct {
	*gob.Decoder
	Count int
}

GobDecoder is a mock decoder that will emit an error after Count number of decodings. Before Count is reached, it will pass the decode on to the provided Decoder.

func (*GobDecoder) Decode

func (r *GobDecoder) Decode(v any) error

type GobEncoder

type GobEncoder struct {
	Count int
}

GobEncoder is a mock writer that will emit an error after Count number of encodings.

func (*GobEncoder) Encode

func (w *GobEncoder) Encode(v interface{}) error

Jump to

Keyboard shortcuts

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