testvalue

package
v0.0.0-...-550751b Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2023 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IfElse

func IfElse[T comparable](cond bool, valTrue, valFalse T) T

IfElse returns the value of the valTrue if the condition is true and returns valFalse otherwise.

func MustReadFile

func MustReadFile(filePath string) []byte

MustReadFile reads the file and returns the content byte slice. nolint:gosec

func MustTime

func MustTime(in string) time.Time

MustTime parses a time string of format RFC3339 and returns a time. Panics if fails.

func MustTimeFn

func MustTimeFn(in string) func() time.Time

MustTimeFn creates a time function with mocked (time.RFC3339 formatted string)time value to be returned. Panics if fails.

func MustTimePtr

func MustTimePtr(in string) *time.Time

MustTimePtr parses a time string of format RFC3339 and returns a pointer to a time. Panics if fails.

func MustUUID

func MustUUID(in string) uuid.UUID

MustUUID parses uuid's string representation and returns a uuid.UUID. Panics if fails.

func MustUUIDFn

func MustUUIDFn(in string) func() uuid.UUID

MustUUIDFn create uuid function with mocked uuid. Panics if fails.

func Neg

func Neg[T NumberPosNeg](n T) T

Neg returns -abs(n) of the number !=0 or -1 otherwise.

func NilOrBool

func NilOrBool(nilPercent int) *bool

func NilOrDecimalBig

func NilOrDecimalBig(nilPercent int, allowNegative bool, beforeCommaDigits int, afterCommaDigits int) *decimal.Big

func NilOrFloat32

func NilOrFloat32(nilPercent int, maxValBeforeComma uint) *float32

func NilOrInt8

func NilOrInt8(allowNegative bool, nilPercent int, maxValue int) *int8

func NilOrInt8Flag

func NilOrInt8Flag(nilPercent int) *int8

func NilOrIntn

func NilOrIntn(nilPercent int, maxValue int) *int

func NilOrRandStrItem

func NilOrRandStrItem(nilPercent int, items ...string) *string

func NilOrStr

func NilOrStr(nilPercent int, str string) *string

NilOrStr returns a nil or pointer to a given string value. Used to construct nilPercent of invalid null.String values using FromStringPtr() method. e.g.: null.StringFromPtr(testvalue.NilOrStr(10, randomstring.UTF8Printable(20, rnd))) will return 10% of NULL DB values and 90% of random UTF strings of length 1-20

null.StringFromPtr(testvalue.NilOrStr(10, testvalue.RandItemStr("ABC", "DEF"))) will fill out a NULLABLE DB field of enum: ["ABC", "DEF"]

func NilOrTime

func NilOrTime(nilPercent int, isPast bool) *time.Time

func NilOrUInt8

func NilOrUInt8(allowNegative bool, nilPercent int, maxValue int) *uint8

func NonEmptyNaturalIntSlice

func NonEmptyNaturalIntSlice(nums []int) []int

func NonNeg

func NonNeg[T NumberPosNeg](n T) T

NonNeg returns abs(n) or zero.

func NonPos

func NonPos[T NumberPosNeg](n T) T

NonPos returns -abs(n) or zero.

func NotNilRnd

func NotNilRnd(rnd *rand.Rand) *rand.Rand

NotNilRnd returns a not nil random generator: the source or creates a new.

func Pos

func Pos[T NumberPosNeg](n T) T

Pos returns abs(n) of the number !=0 or 1 otherwise.

func Ptr

func Ptr[T any](in T) *T

Ptr returns a pointer to an object given.

func RandDecimalBig

func RandDecimalBig(allowNegative bool, beforeCommaDigits int, afterCommaDigits int) decimal.Big

func RandInt8Flag

func RandInt8Flag() int8

func RandItemInt

func RandItemInt(items ...int) int

func RandItemStr

func RandItemStr(items ...string) string

Types

type NumberPosNeg

type NumberPosNeg interface {
	int | int32 | int64 | float32 | float64
}

Jump to

Keyboard shortcuts

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