gen

package
v0.0.0-...-9b4ed5f Latest Latest
Warning

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

Go to latest
Published: Jan 12, 2023 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Generator

type Generator[T any] interface {
	GenerateOne() T
	GenerateN(n uint) []T
}
var ArbitraryFloat32 Generator[float32] = Between(float32(math.MinInt32)/2+1, float32(math.MaxInt32)/2-1)

------ float types ------

var ArbitraryFloat64 Generator[float64] = Between(float64(math.MinInt64)/2+1, float64(math.MaxInt64)/2-1)
var ArbitraryInt Generator[int] = Between((math.MinInt/2 + 1), (math.MaxInt/2 - 1))

------ int types ------

var ArbitraryInt32 Generator[int32] = Between(int32(math.MinInt32)/2+1, int32(math.MaxInt32)/2-1)
var ArbitraryInt64 Generator[int64] = Between(int64(math.MinInt64)/2+1, int64(math.MaxInt64)/2-1)
var ArbitraryRune Generator[rune] = ArbitraryInt32

------ rune ------

var ArbitraryUint Generator[uint] = Between(uint(0), uint(math.MaxUint))

------ uint types ------

var ArbitraryUint16 Generator[uint16] = Between(uint16(0), uint16(math.MaxUint16))
var ArbitraryUint32 Generator[uint32] = Between(uint32(0), uint32(math.MaxUint32))
var ArbitraryUint64 Generator[uint64] = Between(uint64(0), uint64(math.MaxUint64))
var ArbitraryUint8 Generator[uint8] = Between(uint8(0), uint8(math.MaxUint8))

func Between

func Between[T Numeric](min, max T) Generator[T]

check overflow possibilities

func OneOf

func OneOf[T any](values ...T) Generator[T]

func Only

func Only[T any](t T) Generator[T]

func StringGen

func StringGen(alphabet string, minLength uint, maxLength uint) Generator[string]

func TimeBetween

func TimeBetween(start time.Time, end time.Time) Generator[time.Time]

func Using

func Using[T any, K any](gen Generator[T], compositionAction func(T) K) Generator[K]

func UsingGen

func UsingGen[T any, K any](gen Generator[T], flatMapFunc func(T) Generator[K]) Generator[K]

type Numeric

type Numeric interface {
	uint8 | uint16 | uint32 | uint64 | uint | int8 | int16 | int32 | int64 | int | float32 | float64
}

todo, add support for complex numbers

Jump to

Keyboard shortcuts

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