ocaml-containers/tests/core/t_byte_slice.ml
Simon Cruanes e42caf3b6a more tests
2026-04-09 00:58:25 +00:00

37 lines
543 B
OCaml

module T = (val Containers_testlib.make ~__FILE__ ())
include T
open CCByte_slice;;
(* --- of_string --- *)
t @@ fun () ->
let sl = of_string "hello" in
len sl = 5
;;
t @@ fun () ->
let sl = of_string "hello" in
contents sl = "hello"
;;
t @@ fun () ->
let sl = of_string "" in
len sl = 0
;;
(* --- clear --- *)
t @@ fun () ->
let sl = of_string "hello" in
clear sl;
len sl = 0
;;
t @@ fun () ->
(* after clear, get raises *)
let sl = of_string "hello" in
clear sl;
(try
let _ = get sl 0 in
false
with Invalid_argument _ -> true)