Standard library / testing/quick
testing/quick.Check()
Generate inputs and search for a false property; nil means no counterexample was found within the configured trials. Expected stdout: 'true\n'.
Formal Syntax & Structure
go syntaxgo
func Check(f any, config *Config) errorParameters & Attributes
| Name | Type | Description |
|---|---|---|
| f | any | Function under test or callback to run. |
| config | *Config | Optional property-test settings; nil uses defaults. |
Return Value
error
Result of the operation described above.
Working Example
Example Snippetgo
package main
import ( "fmt" "math/rand" "testing/quick")
func main() { err := quick.Check(func(x uint8) bool { return x^x == 0 }, &quick.Config{MaxCount: 20, Rand: rand.New(rand.NewSource(42))}) fmt.Println(err == nil)}