V1.TestThe following combinators represent types that can be used with the check functions below.
module type TESTABLE = sig ... endTESTABLE provides an abstract description for testable values.
testable pp eq is a new testable with the pretty-printer pp and equality eq.
val equal : 'a testable -> 'a -> 'a -> boolequal t is t's equality.
val bool : bool testablebool tests booleans.
val int : int testableint tests integers.
val int32 : int32 testableint32 tests 32-bit integers.
val int64 : int64 testableint64 tests 64-bit integers.
val float : float -> float testablefloat tests floats with specified absolute error.
val char : char testablechar tests characters.
val string : string testablestring tests OCaml strings.
val bytes : bytes testablebytes tests OCaml bytes.
val unit : unit testableunit tests unit values (useful for functions with side-effects).
slist t comp tests sorted lists of ts. The list are sorted using comp.
result t e tests ts on success and es on failure.
triple a b c tests triples of as, bs and cs.
of_pp pp tests values which can be printed using pp and compared using Stdlib.compare
val pass : 'a testablepass tests values of any type and always succeeds.
val reject : 'a testablereject tests values of any type and always fails.
neg t is t's negation: it is true when t is false and it is false when t is true.
map f t lift a 'a testable to a 'b testable, converting 'b to 'a.
Functions for asserting various properties within unit-tests. A failing assertion will cause the testcase to fail immediately.
module Source_code_position : sig ... endtype 'a extra_info =
?here:Source_code_position.here ->
?pos:Source_code_position.pos ->
'aThe assertion functions optionally take information about the location at which they are called in the source code. This is used for giving more descriptive error messages in the case of failure.
val check : ('a testable -> string -> 'a -> 'a -> unit) extra_infocheck testable msg expected actual checks that two values are equal.
msg is printed if the check fails.
If check isn't in a tail-call position, Alcotest may guess the location of the check. Otherwise, use extra_info to report the location.
val check' :
('a testable -> msg:string -> expected:'a -> actual:'a -> unit) extra_infoCheck that two values are equal (labeled variant of check).
val fail : (string -> 'a) extra_infoSimply fail.
val failf : (('a, Format.formatter, unit, 'b) format4 -> 'a) extra_infoSimply fail with a formatted message.
val check_raises : (string -> exn -> (unit -> unit) -> unit) extra_infoCheck that an exception is raised.
val match_raises :
(string -> (exn -> bool) -> (unit -> unit) -> unit) extra_infomatch_raises msg exception_is_expected f Runs f (), and passes the raised exception to exception_is_expected. The check fails when no exception is raised, or exception_is_expected returns false.