mirror of
https://github.com/c-cube/tiny_httpd.git
synced 2025-12-06 03:05:29 -05:00
add tests
This commit is contained in:
parent
199bcff68d
commit
b6cd59f084
2 changed files with 25 additions and 1 deletions
|
|
@ -1,5 +1,5 @@
|
|||
|
||||
(tests
|
||||
(names t_util t_buf t_server)
|
||||
(names t_util t_buf t_server t_io)
|
||||
(package tiny_httpd)
|
||||
(libraries tiny_httpd.core qcheck-core qcheck-core.runner test_util))
|
||||
|
|
|
|||
24
tests/unit/t_io.ml
Normal file
24
tests/unit/t_io.ml
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
open Test_util
|
||||
open Tiny_httpd_core.IO
|
||||
|
||||
let spf = Printf.sprintf
|
||||
|
||||
(* one chunk *)
|
||||
let () =
|
||||
let io = Input.of_string "5\r\nhello\r\n0\r\n\r\nARGH" 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") "hello" str
|
||||
|
||||
(* two chunks *)
|
||||
let () =
|
||||
let io = Input.of_string "5\r\nhello\r\n6\r\n world\r\n0\r\n\r\nARGH" 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") "hello world" str
|
||||
Loading…
Add table
Reference in a new issue