package octez-libs
Install
Dune Dependency
Authors
Maintainers
Sources
sha256=ddfb5076eeb0b32ac21c1eed44e8fc86a6743ef18ab23fff02d36e365bb73d61
sha512=d22a827df5146e0aa274df48bc2150b098177ff7e5eab52c6109e867eb0a1f0ec63e6bfbb0e3645a6c2112de3877c91a17df32ccbff301891ce4ba630c997a65
doc/octez-libs.test-helpers/Tezos_test_helpers/Qcheck_helpers/index.html
Module Tezos_test_helpers.Qcheck_helpers
Source
val qcheck_wrap :
?verbose:bool ->
?long:bool ->
?rand:Random.State.t ->
QCheck.Test.t list ->
unit Alcotest.test_case list
Wrap QCheck tests into Alcotests.
val qcheck_eq_tests :
eq:('a -> 'a -> bool) ->
arb:'a QCheck.arbitrary ->
eq_name:string ->
QCheck.Test.t list
qcheck_eq_tests ~eq ~arb ~eq_name
returns * three tests of eq
: reflexivity, symmetry, and transitivity. * * eq_name
should be the name of the function defining eq
. * For example, given an equality function defined as let mytype_eq = ...
, * call qcheck_eq_tests mytype_eq arb "mytype_eq"
. eq_name
is * only used for logging.
val qcheck_eq :
?pp:(Format.formatter -> 'a -> unit) ->
?cmp:('a -> 'a -> int) ->
?eq:('a -> 'a -> bool) ->
'a ->
'a ->
bool
qcheck_eq pp cmp eq a b
evaluates whether a
and b
are equal, and if they are not, raises a failure and prints an error message. Equality is evaluated as follows:
- use a provided
eq
- if no
eq
is provided, use a providedcmp
- if neither
eq
norcmp
is provided, useStdlib.compare
If pp
is provided, use this to print x
and y
if they are not equal.
val qcheck_eq' :
?pp:(Format.formatter -> 'a -> unit) ->
?cmp:('a -> 'a -> int) ->
?eq:('a -> 'a -> bool) ->
expected:'a ->
actual:'a ->
unit ->
bool
Labeled variant of qcheck_eq
. The unit
argument is necessary as OCaml requires at least one positional (non-labeled) argument in case of optional arguments.
val qcheck_neq :
?pp:(Format.formatter -> 'a -> unit) ->
?cmp:('a -> 'a -> int) ->
?eq:('a -> 'a -> bool) ->
'a ->
'a ->
bool
Similar to qcheck_eq
but tests that two values are not equal.
int64_range_gen a b
generates an int64
between a
inclusive and b
inclusive.
Poorman's implementation until https://github.com/c-cube/qcheck/issues/105 is done.
This probably spectacularly crashes if (b - a) > Int64.max_int
.
int_strictly_positive_gen x
generates an int
between 1
inclusive and x
inclusive.
This will fail if x
is not strictly positive.
int64_strictly_positive_gen x
generates an int64
between 1
inclusive and x
inclusive.
This will fail if x
is not strictly positive.
of_option_gen gen
converts a generator gen
of optional values into a generator of values by rerunning the generator if the generated value was a None
until a Some
is generated.
Be careful: if None
is always returned, this hangs forever!
of_option_arb arb
converts an arbitrary arb
of optional values into an arbitrary of values.
- Generation of values is delegated to
of_option_gen
(retries onNone
values until aSome
is generated). - Shrinking uses the input shrinker but ignores
None
values.
Be careful: if None
is always returned, this hangs forever!
uint16
is an arbitrary of unsigned int16
arbitrary
int16
is an arbitrary of signed int16 arbitrary
uint8
is an arbitrary of unsigned int8
values
int8
is an arbitrary of signed int8 values
string_fixed n
is an arbitrary of string of length n
.
of_option_shrink shrink_opt
returns a shrinker from an optional one. This is typically useful when extracting a shrinker from an arbitrary
to compose a bigger shrinker.
If shrink_opt
is None
then no shrinking happens.
bytes_arb
is a QCheck.arbitrary
for bytes
.
endpoint_arb
is a QCheck.arbitrary
for endpoints (such as octez-client
's --endpoint
flag). It returns URLs of the form: (http|https)://(string\.)+(:port)?
. It is by no means the most general Uri.t
generator. Generalize it if needed.
A generator that returns a sublist of the given list. Lists returned by this generator are not in the same order as the given list (they are shuffled). This generator can return a list equal to the input list (this generator does not guarantee to return strict sublists of the input list).
A generator that returns lists whose elements are from the given list, preserving the order. For example, given the input list 0, 1, 2
, this generator can produce , 0
, 0, 2
, 1, 2
, 1
, etc.
Map-related arbitraries/generators.