test file for chunk stack

This commit is contained in:
Simon Cruanes 2021-10-14 23:17:55 -04:00
parent beda972def
commit 3a56fb0763
No known key found for this signature in database
GPG key ID: 4AC01D0849AA62B6
2 changed files with 30 additions and 1 deletions

View file

@ -1,5 +1,8 @@
let tests = [Test_bitvec.tests]
let tests = [
Test_bitvec.tests;
Test_chunk_stack.tests
]
let props = [
]

View file

@ -0,0 +1,26 @@
module A = Alcotest
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 "inbuf" @@ fun () ->
let buf = C.Buf.create() in
let writer = C.Writer.into_buf buf in
C.Writer.add_string writer "hello";
C.Writer.add_string writer "world";
C.Writer.add_string writer "!!\x00!";
let reader = C.Reader.from_buf buf in
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