mirror of
https://github.com/c-cube/sidekick.git
synced 2025-12-09 20:55:39 -05:00
test file for chunk stack
This commit is contained in:
parent
beda972def
commit
3a56fb0763
2 changed files with 30 additions and 1 deletions
|
|
@ -1,5 +1,8 @@
|
||||||
|
|
||||||
let tests = [Test_bitvec.tests]
|
let tests = [
|
||||||
|
Test_bitvec.tests;
|
||||||
|
Test_chunk_stack.tests
|
||||||
|
]
|
||||||
|
|
||||||
let props = [
|
let props = [
|
||||||
]
|
]
|
||||||
|
|
|
||||||
26
src/util/tests/test_chunk_stack.ml
Normal file
26
src/util/tests/test_chunk_stack.ml
Normal 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
|
||||||
Loading…
Add table
Reference in a new issue