package tezos-test-helpers

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type
val qcheck_wrap : ?verbose:bool -> ?long:bool -> ?rand:Stdlib.Random.State.t -> QCheck.Test.t list -> unit Alcotest.test_case list

Wrap QCheck tests into Alcotests.

val qcheck_eq : ?pp:(Stdlib.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 provided cmp
  • if neither eq nor cmp is provided, use Stdlib.compare

If pp is provided, use this to print x and y if they are not equal.

val qcheck_eq' : ?pp:(Stdlib.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 int64_range : int64 -> int64 -> int64 QCheck.arbitrary

int64_range 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.

val of_option_gen : 'a option QCheck.Gen.t -> 'a QCheck.Gen.t

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!

val of_option_arb : 'a option QCheck.arbitrary -> 'a QCheck.arbitrary

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 on None values until a Some is generated).
  • Shrinking uses the input shrinker but ignores None values.

Be careful: if None is always returned, this hangs forever!

val uint16 : int QCheck.arbitrary

uint16 is an arbitrary of unsigned int16 arbitrary

val int16 : int QCheck.arbitrary

int16 is an arbitrary of signed int16 arbitrary

val uint8 : int QCheck.arbitrary

uint8 is an arbitrary of unsigned int8 values

val int8 : int QCheck.arbitrary

int8 is an arbitrary of signed int8 values

val string_fixed : int -> string QCheck.arbitrary

string_fixed n is an arbitrary of string of length n.

val of_option_shrink : 'a QCheck.Shrink.t option -> 'a QCheck.Shrink.t

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.

val bytes_arb : bytes QCheck.arbitrary

bytes_arb is a QCheck.arbitrary for bytes.

val endpoint_arb : Uri.t QCheck.arbitrary

endpoint_arb is a QCheck.arbitrary for endpoints (such as tezos-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.

module MakeMapArb (Map : Stdlib.Map.S) : sig ... end

Map-related arbitraries/generators.

OCaml

Innovation. Community. Security.