dirtytesting

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Dirtify

func Dirtify[T any](cleanJSON []byte, dcfg *DirtifyCfg, opts ...Opt) ([]byte, error)

Dirtify makes a dirty version of JSON.

func RandomConfig

func RandomConfig(coinArg ...*flipping.Coin) *config.Config

RandomConfig returns a randomly generated *Config.

func StructToMap

func StructToMap(s any) map[string]any

StructToMap converts any struct to a map[string]any via JSON round-trip.

func TransformToHybridCase

func TransformToHybridCase(s string, coinArg ...*flipping.Coin) string

TransformToHybridCase transforms the input string s into a hybrid case string. It uses randomness to decide, for each gap between words, whether to insert an underscore ("_"), a hyphen ("-"), or no separator at all. When no separator is chosen, if the last character of the previous word and the first character of the next word are both lowercase (which might merge the words indistinguishably), then the empty separator is overridden with either a hyphen or underscore. The forced choice uses hyphenRatio: with probability hyphenRatio a hyphen is used, otherwise an underscore. The function accepts an optional RNG argument (variadic); if none is provided, a default RNG is used.

Types

type Dirtifier

type Dirtifier struct {
	// contains filtered or unexported fields
}

Dirtifier makes dirty JSONs from clean ones.

func NewDirtifier

func NewDirtifier(threshold float64, cfg *config.Config, coinArg ...*flipping.Coin) *Dirtifier

NewDirtifier creates a new dirtifier.

func (*Dirtifier) Make

func (d *Dirtifier) Make(val any) any

Make makes dirty values applying random dirtify-transformations.

type DirtifyCfg

type DirtifyCfg struct {
	// contains filtered or unexported fields
}

func (*DirtifyCfg) Config

func (dcfg *DirtifyCfg) Config() *config.Config

type Opt

type Opt func(*DirtifyCfg)

func WithAllowedRed

func WithAllowedRed(b bool) Opt

func WithCoin

func WithCoin(coin *flipping.Coin) Opt

func WithConfig

func WithConfig(cfg *config.Config) Opt

func WithRatio

func WithRatio(r float64) Opt

Jump to

Keyboard shortcuts

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