mirror of
https://github.com/c-cube/sidekick.git
synced 2025-12-06 03:05:31 -05:00
test: add a test using a file backend
This commit is contained in:
parent
73cca4ca18
commit
7df124f94c
1 changed files with 19 additions and 2 deletions
|
|
@ -5,8 +5,8 @@ module C = Chunk_stack
|
|||
let l : unit Alcotest.test_case list ref = ref []
|
||||
|
||||
let (~!) = Printf.sprintf "at line %d"
|
||||
let mk_test name f =
|
||||
l := (name, `Quick, f) :: !l
|
||||
let mk_test ?(speed=`Quick) name f =
|
||||
l := (name, speed, f) :: !l
|
||||
|
||||
let () = mk_test "inbuf" @@ fun () ->
|
||||
let buf = C.Buf.create() in
|
||||
|
|
@ -23,4 +23,21 @@ let () = mk_test "inbuf" @@ fun () ->
|
|||
A.check A.(option string) ~!__LINE__ None (C.Reader.next_string reader);
|
||||
()
|
||||
|
||||
let () = mk_test ~speed:`Slow "infile" @@ fun () ->
|
||||
CCIO.File.with_temp ~prefix:"sidekick-test" ~suffix:"dat"
|
||||
(fun file ->
|
||||
CCIO.with_out file (fun oc ->
|
||||
let writer = C.Writer.into_channel oc in
|
||||
C.Writer.add_string writer "hello";
|
||||
C.Writer.add_string writer "world";
|
||||
C.Writer.add_string writer "!!\x00!");
|
||||
|
||||
C.Reader.with_file_backward file (fun reader ->
|
||||
A.check A.(option string) ~!__LINE__ (Some "!!\x00!") (C.Reader.next_string reader);
|
||||
A.check A.(option string) ~!__LINE__ (Some "world") (C.Reader.next_string reader);
|
||||
A.check A.(option string) ~!__LINE__ (Some "hello") (C.Reader.next_string reader);
|
||||
A.check A.(option string) ~!__LINE__ None (C.Reader.next_string reader));
|
||||
()
|
||||
)
|
||||
|
||||
let tests = "chunk_stack", !l
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue