Skip to content

Commit 4705278

Browse files
committed
add more tests
1 parent b6cd59f commit 4705278

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

tests/unit/t_io.ml

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,22 @@ let () =
2121
|> Input.read_chunked ~bytes:(Bytes.create 4) ~fail:failwith
2222
|> Input.read_all_using ~buf:(Buf.create ())
2323
in
24-
assert_eq ~to_string:(spf "%S") "hello world" str
24+
assert_eq ~to_string:(spf "%S") "hello world" str;
25+
26+
let str_rest = io |> Input.read_all_using ~buf:(Buf.create ()) in
27+
assert_eq ~to_string:(spf "%S") "ARGH" str_rest;
28+
()
29+
30+
(* two chunks *)
31+
let () =
32+
let io = Input.of_string "10\r\n{\"poCheck\":true}\r\n0\r\n\r\n" in
33+
let str =
34+
io
35+
|> Input.read_chunked ~bytes:(Bytes.create 4) ~fail:failwith
36+
|> Input.read_all_using ~buf:(Buf.create ())
37+
in
38+
assert_eq ~to_string:(spf "%S") {|{"poCheck":true}|} str;
39+
40+
let str_rest = io |> Input.read_all_using ~buf:(Buf.create ()) in
41+
assert_eq ~to_string:(spf "%S") "" str_rest;
42+
()

0 commit comments

Comments
 (0)