Test.T
Testers.
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 t
make ~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 -> bool
equal t
is the equality function of t
.
val pp : 'a t -> 'a B0_std.Fmt.t
pp t
is the formatting function of t
.
val with' : ?equal:('a -> 'a -> bool) -> ?pp:'a B0_std.Fmt.t -> 'a t -> 'a t
with' t
is t
with those arguments specified replaced.
val true' : 'a t
true'
equates all values and prints them with Test.Fmt.anon
.
val false' : 'a t
false'
distinguishes all values and prints them with Test.Fmt.anon
.
val any : 'a t
any
uses Stdlib.compare
for testing equality (works Float.nan
values) and prints them with Test.Fmt.anon
.
val exn : exn t
exn
uses Stdlib.compare
for testing equality and prints with B0_std.Fmt.exn
.
val invalid_arg : exn t
invalid_arg
has an equality function that returns true
iff the first argument is of the form Invalid_argument _
.
val failure : exn t
failure
has an equality function that returns true
iff the first argument is of the form Failure _
.
val unit : unit t
unit
tests units and prints them as OCaml syntax with B0_std.Fmt.Lit.unit
.
val bool : bool t
bool
tests booleans and prints them as OCaml syntax with B0_std.Fmt.Lit.bool
.
val int : int t
int
tests integers and prints them as OCaml syntax with B0_std.Fmt.Lit.int
.
val int32 : int32 t
int32
tests 32-bit integers and prints them as OCaml syntax with B0_std.Fmt.Lit.int32
.
val uint32 : int32 t
uint32
tests unsigned 32-bit integers and prints them with B0_std.Fmt.Lit.uint32
val int64 : int64 t
int64
tests 64-bit integers and prints them as OCaml syntax with B0_std.Fmt.Lit.int64
.
val uint64 : int64 t
uint64
tests unsigned 64-bit integers and prints them as OCaml syntax with B0_std.Fmt.Lit.uint64
.
val nativeint : nativeint t
nativeint
tests native integers and prints them as OCaml syntax with Fmt.Lit.nativeint
.
val nativeuint : nativeint t
nativeuint
tests unsigned native integers and prints them as OCaml syntax with B0_std.Fmt.Lit.nativeuint
.
val float : float t
float
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 t
hex_float
is like float
but uses the OCaml syntax B0_std.Fmt.Lit.hex_float
for printing.
val char : char t
char
tests characters (bytes) and prints them as OCaml syntax with B0_std.Fmt.Lit.char
.
val ascii_string : string t
ascii_string
tests strings and prints them as OCaml syntax with B0_std.Fmt.Lit.ascii_string
.
val string : string t
string
tests strings and prints them as OCaml syntax with B0_std.Fmt.Lit.string
val binary_string : string t
binary_string
tests strings and prints them with as OCaml syntax with B0_std.Fmt.Lit.binary_string
.
val styled_string : string t
styled_string
tests strings and prints them with with B0_std.Fmt.styled_text_string
.
val lines : string t
lines
tests strings and prints them by lines using B0_std.Fmt.lines
.
val bytes : bytes t
bytes
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
.