Standard library / testing

testing.F

Fuzz test handle used to add seed inputs and register a target. Expected stdout: 'seed checked\nPASS\n'. Run as a _test.go file using the Go test harness.

Formal Syntax & Structure

go syntaxgo
type F struct {}

Working Example

Example Snippetgo
package main
import (  "fmt"  "strings"  "testing")
func FuzzReference(f *testing.F) {  f.Add("abc")  f.Fuzz(func(t *testing.T, s string) {    if strings.ToUpper(strings.ToUpper(s)) != strings.ToUpper(s) {      t.Fatal("not idempotent")    }    fmt.Println("seed checked")  })}
Go Reference