From 4705278c3ba205cef58e55423649c19c60a3d7e7 Mon Sep 17 00:00:00 2001 From: Simon Cruanes Date: Tue, 18 Jun 2024 17:04:15 -0400 Subject: [PATCH] add more tests --- tests/unit/t_io.ml | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/tests/unit/t_io.ml b/tests/unit/t_io.ml index 61400b4d..815831d6 100644 --- a/tests/unit/t_io.ml +++ b/tests/unit/t_io.ml @@ -21,4 +21,22 @@ let () = |> Input.read_chunked ~bytes:(Bytes.create 4) ~fail:failwith |> Input.read_all_using ~buf:(Buf.create ()) in - assert_eq ~to_string:(spf "%S") "hello world" str + assert_eq ~to_string:(spf "%S") "hello world" str; + + let str_rest = io |> Input.read_all_using ~buf:(Buf.create ()) in + assert_eq ~to_string:(spf "%S") "ARGH" str_rest; + () + +(* two chunks *) +let () = + let io = Input.of_string "10\r\n{\"poCheck\":true}\r\n0\r\n\r\n" in + let str = + io + |> Input.read_chunked ~bytes:(Bytes.create 4) ~fail:failwith + |> Input.read_all_using ~buf:(Buf.create ()) + in + assert_eq ~to_string:(spf "%S") {|{"poCheck":true}|} str; + + let str_rest = io |> Input.read_all_using ~buf:(Buf.create ()) in + assert_eq ~to_string:(spf "%S") "" str_rest; + ()