better if-not-match
This commit is contained in:
parent
28eb9fae55
commit
059c5d796f
7 changed files with 107 additions and 106 deletions
55
test/test.ml
55
test/test.ml
|
|
@ -62,32 +62,39 @@ let () =
|
|||
()
|
||||
|
||||
let () =
|
||||
let open Headers_lib.Etag in
|
||||
let check input = assert (Result.is_ok (parse input)) in
|
||||
let open Headers_lib.If_none_match in
|
||||
let ok_l =
|
||||
[
|
||||
"*";
|
||||
"\"foo\"";
|
||||
"W/\"foo\"";
|
||||
"\"foo\", \"bar\"";
|
||||
" , W/\"x\" , W/\"y\" , \"z\"";
|
||||
", \"one\" , \"two\" , \"three\"";
|
||||
"W/\"a\" , ";
|
||||
"W/\"a\" , \"b\"";
|
||||
]
|
||||
in
|
||||
let bad_l =
|
||||
[
|
||||
"";
|
||||
"foo";
|
||||
"W/foo";
|
||||
"W/\"unterminated";
|
||||
"\"foo\", W/";
|
||||
"* , \"bar\"";
|
||||
"\"a\" \"b\"";
|
||||
"W/\"a\" W/\"b\"";
|
||||
"\"fo\x7Fo\"";
|
||||
" W/\"a\"";
|
||||
"W/\"a\" ";
|
||||
]
|
||||
in
|
||||
let check_ok input = assert (Result.is_ok (parse input)) in
|
||||
let check_bad input = assert (Result.is_error (parse input)) in
|
||||
List.iter check_ok ok_l;
|
||||
List.iter check_bad bad_l;
|
||||
|
||||
check "*";
|
||||
check "\"foo\"";
|
||||
check "W/\"foo\"";
|
||||
check "\"foo\", \"bar\"";
|
||||
check " W/\"x\" , W/\"y\" , \"z\" ";
|
||||
check " \"one\" , \"two\" , \"three\" ";
|
||||
check "W/\"a\"";
|
||||
check " W/\"a\" , \"b\"";
|
||||
|
||||
check_bad "";
|
||||
check_bad "foo";
|
||||
check_bad "W/foo";
|
||||
check_bad "W/\"unterminated";
|
||||
check_bad "\"foo\", W/";
|
||||
check_bad "* , \"bar\"";
|
||||
check_bad "\"a\" \"b\"";
|
||||
check_bad "W/\"a\" W/\"b\"";
|
||||
check_bad "\"fo\x7Fo\"";
|
||||
|
||||
(* TODO trailing comma are valid actually, I think *)
|
||||
check_bad "\"foo\" ,";
|
||||
check_bad ", \"foo\"";
|
||||
()
|
||||
|
||||
(*
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue