testing/quick

Guided tour · Testing · pkg.go.dev →

Quickcheck-style property tests. Largely superseded by native fuzzing (go test -fuzz).

Property check

Check

prop := func(xs []int) bool {
    return len(Reverse(Reverse(xs))) == len(xs)
}
if err := quick.Check(prop, nil); err != nil {
    t.Error(err)
}

CheckEqual

if err := quick.CheckEqual(fast, slow, nil); err != nil {
    t.Error(err)
}