Test.TTesters.
A tester simply packs an equality function and a formatter to print values.
Important. We indicate when the printers respect the OCaml syntax. Only these testers are suitable for use with Test.snap.
val make : ?equal:('a -> 'a -> bool) -> ?pp:'a B0_std.Fmt.t -> unit -> 'a tmake ~equal ~pp () is a tester using equal to assert values and pp to inspect them. Note the following points:
M implement T it can directly be used as an equality tester value as (module M), you don't need to call this function.M with Test.snap note that it expects M.pp to output valid OCaml syntax. If that is not the case you can redefine it with with_tester.equal is the value to test and the second value is the reference value. This is somtimes used by the combinators.val equal : 'a t -> 'a -> 'a -> boolequal t is the equality function of t.
val pp : 'a t -> 'a B0_std.Fmt.tpp t is the formatting function of t.
val with' : ?equal:('a -> 'a -> bool) -> ?pp:'a B0_std.Fmt.t -> 'a t -> 'a twith' t is t with those arguments specified replaced.
val true' : 'a ttrue' equates all values and prints them with Test.Fmt.anon.
val false' : 'a tfalse' distinguishes all values and prints them with Test.Fmt.anon.
val any : 'a tany uses Stdlib.compare for testing equality (works Float.nan values) and prints them with Test.Fmt.anon.
val exn : exn texn uses Stdlib.compare for testing equality and prints with B0_std.Fmt.exn.
val invalid_arg : exn tinvalid_arg has an equality function that returns true iff the first argument is of the form Invalid_argument _.
val failure : exn tfailure has an equality function that returns true iff the first argument is of the form Failure _.
val unit : unit tunit tests units and prints them as OCaml syntax with B0_std.Fmt.Lit.unit.
val bool : bool tbool tests booleans and prints them as OCaml syntax with B0_std.Fmt.Lit.bool.
val int : int tint tests integers and prints them as OCaml syntax with B0_std.Fmt.Lit.int.
val int32 : int32 tint32 tests 32-bit integers and prints them as OCaml syntax with B0_std.Fmt.Lit.int32.
val uint32 : int32 tuint32 tests unsigned 32-bit integers and prints them with B0_std.Fmt.Lit.uint32
val int64 : int64 tint64 tests 64-bit integers and prints them as OCaml syntax with B0_std.Fmt.Lit.int64.
val uint64 : int64 tuint64 tests unsigned 64-bit integers and prints them as OCaml syntax with B0_std.Fmt.Lit.uint64.
val nativeint : nativeint tnativeint tests native integers and prints them as OCaml syntax with Fmt.Lit.nativeint.
val nativeuint : nativeint tnativeuint tests unsigned native integers and prints them as OCaml syntax with B0_std.Fmt.Lit.nativeuint.
val float : float tfloat tests float with Float.equal so it can be used to assert nan values and prints as OCaml syntax them with B0_std.Fmt.Lit.floatl.
Warning. Be aware of the limitations of testing floats for strict binary equality.
val hex_float : float thex_float is like float but uses the OCaml syntax B0_std.Fmt.Lit.hex_float for printing.
val char : char tchar tests characters (bytes) and prints them as OCaml syntax with B0_std.Fmt.Lit.char.
val ascii_string : string tascii_string tests strings and prints them as OCaml syntax with B0_std.Fmt.Lit.ascii_string.
val string : string tstring tests strings and prints them as OCaml syntax with B0_std.Fmt.Lit.string
val binary_string : string tbinary_string tests strings and prints them with as OCaml syntax with B0_std.Fmt.Lit.binary_string.
val styled_string : string tstyled_string tests strings and prints them with with B0_std.Fmt.styled_text_string.
val lines : string tlines tests strings and prints them by lines using B0_std.Fmt.lines.
val bytes : bytes tbytes tests bytes and prints them with B0_std.Fmt.bytes.
option v tests options of values tested with v and prints them as OCaml syntax with B0_std.Fmt.Lit.option.
either ~left ~right tests Either.t values and prints them as OCaml syntax with B0_std.Fmt.Lit.either.
result ok tests result values using ok for Ok and a string for Error and prints them as OCaml syntax with B0_std.Fmt.Lit.result.
result ok error tests result values using the given equalities for the values of each cas and prints them as OCaml syntax with B0_std.Fmt.Lit.result.
list elt tests list of elements tested with elt and prints them as OCaml syntax with B0_std.Fmt.Lit.list.
array elt test array of elements tested with elt and prints them as OCaml syntax with B0_std.Fmt.Lit.array.
pair fst snd tests pairs with fst and snd and prints them as OCaml syntax with B0_std.Fmt.Lit.pair.
t3 tests triplets and prints them as OCaml syntax with B0_std.Fmt.List.t3.
t4 tests quadruplets and prints them as OCaml syntax with B0_std.Fmt.List.t4.
t5 tests quintuplets and prints them as OCaml syntax with B0_std.Fmt.List.t5.