Skip to content

Commit 519a4a0

Browse files
committed
http-lib: test invalid Accept header
Signed-off-by: Pau Ruiz Safont <[email protected]>
1 parent 8355506 commit 519a4a0

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

ocaml/libs/http-lib/http_test.ml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,15 @@ module Accept = struct
2424
let actual = Accept.of_string data in
2525
Alcotest.(check @@ list accept) data expected actual
2626

27+
let test_invalid () =
28+
let data = "text/html, image/gif, image/jpeg, ; q=.2, */; q=.2" in
29+
let expected = Accept.Parse_failure " " in
30+
let actual () =
31+
let _ = Accept.of_string data in
32+
()
33+
in
34+
Alcotest.check_raises "Raises Parse failure" expected actual
35+
2736
let test_accept_complex () =
2837
let data =
2938
"application/xml;q=0.9,text/html,application/xhtml+xml,*/*;q=0.8"
@@ -81,6 +90,7 @@ module Accept = struct
8190
[
8291
("Simple", `Quick, test_accept_simple)
8392
; ("Complex", `Quick, test_accept_complex)
93+
; ("Invalid", `Quick, test_invalid)
8494
]
8595
; preferred_tests
8696
]

0 commit comments

Comments
 (0)