aboutsummaryrefslogtreecommitdiffstats
path: root/src/cow_http_hd.erl
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2014-12-16 10:35:24 +0200
committerLoïc Hoguin <[email protected]>2014-12-16 10:35:24 +0200
commit9eab785657546e68cab835f5856c0f74656a0576 (patch)
treed64341ad1017797d669df15fd95754f967283c2e /src/cow_http_hd.erl
parent037225bbcf727479c88d1a18127fe169b66b7e12 (diff)
downloadcowlib-9eab785657546e68cab835f5856c0f74656a0576.tar.gz
cowlib-9eab785657546e68cab835f5856c0f74656a0576.tar.bz2
cowlib-9eab785657546e68cab835f5856c0f74656a0576.zip
Add property for cow_http_hd:parse_max_forwards/1
Diffstat (limited to 'src/cow_http_hd.erl')
-rw-r--r--src/cow_http_hd.erl15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/cow_http_hd.erl b/src/cow_http_hd.erl
index a597811..4577857 100644
--- a/src/cow_http_hd.erl
+++ b/src/cow_http_hd.erl
@@ -1009,6 +1009,13 @@ parse_max_forwards(<< $8, R/bits >>) -> number(R, 8);
parse_max_forwards(<< $9, R/bits >>) -> number(R, 9).
-ifdef(TEST).
+prop_parse_max_forwards() ->
+ ?FORALL(
+ X,
+ non_neg_integer(),
+ X =:= parse_max_forwards(integer_to_binary(X))
+ ).
+
parse_max_forwards_test_() ->
Tests = [
{<<"0">>, 0},
@@ -1019,6 +1026,14 @@ parse_max_forwards_test_() ->
{<<"1234567890 ">>, 1234567890}
],
[{V, fun() -> R = parse_max_forwards(V) end} || {V, R} <- Tests].
+
+parse_max_forwards_error_test_() ->
+ Tests = [
+ <<>>,
+ <<"123, 123">>,
+ <<"4.17">>
+ ],
+ [{V, fun() -> {'EXIT', _} = (catch parse_content_length(V)) end} || V <- Tests].
-endif.
%% @doc Parse the Transfer-Encoding header.