quick
3 分钟阅读
Package quick implements utility functions to help with black box testing.
quick
包实现了一些实用的函数,以帮助黑盒测试。
The testing/quick package is frozen and is not accepting new features.
testing/quick
包已被冻结,不接受新特性。
常量
This section is empty.
变量
This section is empty.
函数
func Check
|
|
Check looks for an input to f, any function that returns bool, such that f returns false. It calls f repeatedly, with arbitrary values for each argument. If f returns false on a given input, Check returns that input as a *CheckError. For example:
Check
函数会查找一个f
的输入,即任何返回bool类型的函数,使得f
返回false。它会重复调用f
,对于每个参数都使用任意值。如果f
在给定的输入上返回false,则Check会将该输入作为*CheckError
返回。例如:
|
|
func CheckEqual
|
|
CheckEqual looks for an input on which f and g return different results. It calls f and g repeatedly with arbitrary values for each argument. If f and g return different answers, CheckEqual returns a *CheckEqualError describing the input and the outputs.
CheckEqual
函数会查找一个输入,使得f
和g
返回不同的结果。它会重复调用f
和g
,对于每个参数都使用任意值。如果f
和g
返回不同的答案,则CheckEqual函数会返回一个*CheckEqualError
,描述输入和输出。
func Value
|
|
Value returns an arbitrary value of the given type. If the type implements the Generator interface, that will be used. Note: To create arbitrary values for structs, all the fields must be exported.
Value
函数返回给定类型的任意值。如果类型实现了Generator接口,则会使用它。注意:要为结构体创建任意值,必须导出所有字段。
类型
type CheckEqualError
|
|
A CheckEqualError is the result CheckEqual finding an error.
CheckEqualError
结构体是CheckEqual函数发现错误的结果。
(*CheckEqualError) Error
|
|
type CheckError
|
|
A CheckError is the result of Check finding an error.
CheckError
结构体是Check函数发现错误的结果。
(*CheckError) Error
|
|
type Config
|
|
A Config structure contains options for running a test.
Config
结构包含运行测试的选项。
type Generator
|
|
A Generator can generate random values of its own type.
Generator接口可以生成其自身类型的随机值。
type SetupError
|
|
A SetupError is the result of an error in the way that check is being used, independent of the functions being tested.
SetupError
类型是check的使用方式中出现的错误结果,与被测试的函数无关。
(SetupError) Error
|
|