From a5c1a88378596b5efdd9ed40ebcc78f24844f1ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Hoguin?= Date: Tue, 16 Dec 2014 10:57:11 +0200 Subject: Add a property for cow_http_hd:parse_transfer_encoding/1 --- src/cow_http_hd.erl | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/cow_http_hd.erl b/src/cow_http_hd.erl index a66ba70..046b3e4 100644 --- a/src/cow_http_hd.erl +++ b/src/cow_http_hd.erl @@ -1037,7 +1037,7 @@ parse_max_forwards_error_test_() -> %% @doc Parse the Transfer-Encoding header. %% -%% @todo Extension parameters. +%% @todo This function does not support parsing of transfer-parameter. -spec parse_transfer_encoding(binary()) -> [binary()]. parse_transfer_encoding(<<"chunked">>) -> @@ -1046,6 +1046,16 @@ parse_transfer_encoding(TransferEncoding) -> nonempty(token_ci_list(TransferEncoding, [])). -ifdef(TEST). +prop_parse_transfer_encoding() -> + ?FORALL(L, + non_empty(list(token())), + begin + << _, TransferEncoding/binary >> = iolist_to_binary([[$,, C] || C <- L]), + ResL = parse_transfer_encoding(TransferEncoding), + CheckedL = [?INLINE_LOWERCASE_BC(Co) =:= ResC || {Co, ResC} <- lists:zip(L, ResL)], + [true] =:= lists:usort(CheckedL) + end). + parse_transfer_encoding_test_() -> Tests = [ {<<"a , , , ">>, [<<"a">>]}, -- cgit v1.2.3