better if-not-match

This commit is contained in:
swrup 2026-02-12 11:25:57 +01:00
parent c4475d6908
commit 7baba82a10
7 changed files with 107 additions and 106 deletions

View file

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