diff options
author | Loïc Hoguin <[email protected]> | 2014-12-16 08:52:41 +0200 |
---|---|---|
committer | Loïc Hoguin <[email protected]> | 2014-12-16 08:52:41 +0200 |
commit | e009aa2e31893e52c033049b7ae8ca5059474f3b (patch) | |
tree | 58120bdf7bfdc032b7c2bd69c6626c96fef5b13f /src/cow_http_hd.erl | |
parent | 96c69fb04eb55d627849c5120081462b6ca81893 (diff) | |
download | cowlib-e009aa2e31893e52c033049b7ae8ca5059474f3b.tar.gz cowlib-e009aa2e31893e52c033049b7ae8ca5059474f3b.tar.bz2 cowlib-e009aa2e31893e52c033049b7ae8ca5059474f3b.zip |
Add a property for cow_http_hd:parse_connection/1
Diffstat (limited to 'src/cow_http_hd.erl')
-rw-r--r-- | src/cow_http_hd.erl | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/cow_http_hd.erl b/src/cow_http_hd.erl index 23d627b..6e70185 100644 --- a/src/cow_http_hd.erl +++ b/src/cow_http_hd.erl @@ -701,6 +701,16 @@ parse_connection(Connection) -> nonempty(token_ci_list(Connection, [])). -ifdef(TEST). +prop_parse_connection() -> + ?FORALL(L, + non_empty(list(token())), + begin + << _, Connection/binary >> = iolist_to_binary([[$,, C] || C <- L]), + ResL = parse_connection(Connection), + CheckedL = [?INLINE_LOWERCASE_BC(Co) =:= ResC || {Co, ResC} <- lists:zip(L, ResL)], + [true] =:= lists:usort(CheckedL) + end). + parse_connection_test_() -> Tests = [ {<<"close">>, [<<"close">>]}, @@ -709,6 +719,12 @@ parse_connection_test_() -> {<<"keep-alive, Upgrade">>, [<<"keep-alive">>, <<"upgrade">>]} ], [{V, fun() -> R = parse_connection(V) end} || {V, R} <- Tests]. + +parse_connection_error_test_() -> + Tests = [ + <<>> + ], + [{V, fun() -> {'EXIT', _} = (catch parse_connection(V)) end} || V <- Tests]. -endif. -ifdef(PERF). |