test: add regression test for #38

This commit is contained in:
Simon Cruanes 2023-04-19 21:17:00 -04:00
parent 29ece562e2
commit b48048891d
No known key found for this signature in database
GPG key ID: EBFFF6F283F3A2B4

View file

@ -328,6 +328,22 @@ let () =
OUnit.assert_bool "not empty" (not (is_empty s)); OUnit.assert_bool "not empty" (not (is_empty s));
() ()
let with_tmp_file f =
let path = Filename.temp_file "test_iter" "data" in
try
let x = f path in
(try Sys.remove path with _ -> ());
x
with e ->
(try Sys.remove path with _ -> ());
raise e
let () =
with_tmp_file @@ fun path ->
Iter.IO.write_lines path Iter.empty;
let l = Iter.IO.lines_of path |> Iter.to_list in
OUnit.assert_equal ~printer:Q.Print.(list @@ Printf.sprintf "%S") [] l
let () = let () =
let errcode = QCheck_base_runner.run_tests ~colors:false !qchecks in let errcode = QCheck_base_runner.run_tests ~colors:false !qchecks in
if errcode <> 0 then exit errcode if errcode <> 0 then exit errcode