Standard library / testing/quick
testing/quick.Value()
Generate a reflected value for a supported type; the boolean indicates whether generation succeeded. Struct fields must be exported. Expected stdout: 'uint8 true\n'.
Formal Syntax & Structure
go syntaxgo
func Value(t reflect.Type, rand *rand.Rand) (value reflect.Value, ok bool)Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| t | reflect.Type | Requested reflected type. |
| rand | *rand.Rand | Pseudo-random source for value generation. |
Return Value
(value reflect.Value, ok bool)
Result of the operation described above.
Working Example
Example Snippetgo
package main
import ( "fmt" "math/rand" "reflect" "testing/quick")
func main() { v, ok := quick.Value(reflect.TypeOf(uint8(0)), rand.New(rand.NewSource(42))) fmt.Println(v.Kind(), ok)}