Skip to content

Commit

Permalink
Test coverage is bit improved
Browse files Browse the repository at this point in the history
  • Loading branch information
poroh committed Jun 15, 2021
1 parent 94d68bf commit 9ee0720
Showing 1 changed file with 73 additions and 14 deletions.
87 changes: 73 additions & 14 deletions test/message/ersip_hnames_test.erl
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
%%
%% Copyright (c) 2018 Dmitry Poroh
%% All rights reserved.
%% Distributed under the terms of the MIT License. See the LICENSE file.
%%
%% Header names test
%%
%%%
%%% Copyright (c) 2018, 2021 Dmitry Poroh
%%% All rights reserved.
%%% Distributed under the terms of the MIT License. See the LICENSE file.
%%%
%%% Header names test
%%%


-module(ersip_hnames_test).

-include_lib("eunit/include/eunit.hrl").
-include("ersip_headers.hrl").

%%%===================================================================
%%% Cases
%%%===================================================================
%%===================================================================
%% Cases
%%===================================================================

compact_form_test() ->
IANAPageCopy =
Expand Down Expand Up @@ -67,13 +68,71 @@ print_form_test() ->
<<"Unsupported">>,
<<"Require">>,
<<"Proxy-Require">>,
<<"p-custom-header">>
<<"p-custom-header">>,
<<"Accept">>,
<<"Accept-Contact">>,
<<"Allow-Events">>,
<<"Content-Encoding">>,
<<"Identity">>,
<<"Referred-By">>,
<<"Reject-Contact">>,
<<"Request-Disposition">>,
<<"Session-Expires">>,
<<"Subject">>
],
[test_print_form(Name) || Name <- PrintForms].

%%%===================================================================
%%% Helpers
%%%===================================================================

known_headers_from_binary_test() ->
KnownHeaders = [{from, <<"From">>},
{cseq, <<"CSeq">>},
{callid, <<"Call-ID">>},
{maxforwards, <<"Max-Forwards">>},
{content_type, <<"Content-Type">>},
{route, <<"Route">>},
{record_route, <<"Record-route">>},
{allow, <<"Allow">>},
{supported, <<"Supported">>},
{unsupported, <<"Unsupported">>},
{require, <<"Require">>},
{proxy_require, <<"Proxy-Require">>},
{contact, <<"Contact">>},
{expires, <<"Expires">>},
{minexpires, <<"Min-Expires">>},
{date, <<"Date">>},
{www_authenticate, <<"WWW-Authenticate">>},
{authorization, <<"Authorization">>},
{proxy_authenticate, <<"Proxy-Authenticate">>},
{proxy_authorization, <<"Proxy-Authorization">>},
{subscription_state, <<"Subscription-State">>},
{event, <<"Event">>},
{refer_to, <<"Refer-To">>},
{replaces, <<"Replaces">>},
{rseq, <<"RSeq">>},
{rack, <<"RAck">>}],
[?assertMatch({ok, KnownHeader}, ersip_hnames:known_header_form(Name))
|| {KnownHeader, Name} <- KnownHeaders],
ok.

make_key_test() ->
KeysMap = [{ersip_hnames:make_key(<<"p-asserted-identity">>), <<"P-Asserted-Identity">>},
{?ERSIPH_SUBSCRIPTION_STATE, <<"subscription-state">>},
{?ERSIPH_AUTHORIZATION, <<"aUthorization">>},
{?ERSIPH_CONTENT_LENGTH, <<"cOntent-Length">>},
{?ERSIPH_EVENT, <<"event">>},
{?ERSIPH_EXPIRES, <<"eXpireS">>},
{?ERSIPH_PROXY_AUTHENTICATE, <<"proxy-Authenticate">>},
{?ERSIPH_PROXY_AUTHORIZATION, <<"proxy-Authorization">>},
{?ERSIPH_REPLACES, <<"replaceS">>},
{?ERSIPH_RSEQ, <<"rSeq">>},
{?ERSIPH_RACK, <<"raCk">>}],
[?assertEqual(Key, ersip_hnames:make_key(Name)) || {Key, Name} <- KeysMap],
ok.


%%===================================================================
%% Helpers
%%===================================================================

test_print_form(Bin) ->
?assertEqual(Bin, ersip_hnames:print_form(ersip_bin:to_lower(Bin))).

0 comments on commit 9ee0720

Please sign in to comment.