add more tests

This commit is contained in:
Simon Cruanes 2024-06-18 17:04:15 -04:00
parent b6cd59f084
commit 4705278c3b
No known key found for this signature in database
GPG key ID: EBFFF6F283F3A2B4

View file

@ -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;
()