diff --git a/src/util/tests/sidekick_test_util.ml b/src/util/tests/sidekick_test_util.ml index 963f09a6..00faa3b9 100644 --- a/src/util/tests/sidekick_test_util.ml +++ b/src/util/tests/sidekick_test_util.ml @@ -1,5 +1,8 @@ -let tests = [Test_bitvec.tests] +let tests = [ + Test_bitvec.tests; + Test_chunk_stack.tests +] let props = [ ] diff --git a/src/util/tests/test_chunk_stack.ml b/src/util/tests/test_chunk_stack.ml new file mode 100644 index 00000000..391e7a4b --- /dev/null +++ b/src/util/tests/test_chunk_stack.ml @@ -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