fill

package module
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Dec 29, 2024 License: MIT Imports: 3 Imported by: 0

README

lesiw.io/fill

Go Reference

A utility for filling Go values.

Example

package main

import (
    "crypto/tls"
    "math/rand/v2"
    "testing"

    "github.com/google/go-cmp/cmp"
    "github.com/google/go-cmp/cmp/cmpopts"
    "lesiw.io/fill"
)

func FuzzTlsConfigClone(f *testing.F) {
    opts := cmp.Options{cmpopts.IgnoreUnexported(tls.Config{})}
    f.Fuzz(func(t *testing.T, seed1, seed2 uint64) {
        cfg1 := &tls.Config{}
        fill.Rand(&cfg1, rand.New(rand.NewPCG(seed1, seed2)))
        cfg2 := cfg1.Clone()
        if !cmp.Equal(cfg1, cfg2, opts) {
            t.Errorf("-original +cloned\n%s", cmp.Diff(cfg1, cfg2, opts))
        }
    })
}

▶️ Run this example on the Go Playground

To run locally, go test -fuzz=Fuzz -fuzztime=10s.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Rand added in v0.2.0

func Rand(a any, rng *rand.Rand)

Rand fills a value with random data.

Types

This section is empty.

Jump to

Keyboard shortcuts

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