diff options
author | Ryan Kereliuk <ryker@ryker.org> | 2022-11-02 08:41:50 -0700 |
---|---|---|
committer | Olaf Alders <olaf@wundersolutions.com> | 2022-11-02 13:02:18 -0400 |
commit | 8c99f81cb5acd9923b7c71171d5050eb319b6262 (patch) | |
tree | 5cd2fc3fa7318c3f80d425fe5f3729bf8a673dcf /t | |
parent | 25bda781b2fe7f1e38c6bacf84c896428e06ecc2 (diff) | |
download | uri-8c99f81cb5acd9923b7c71171d5050eb319b6262.tar.gz |
Add missing unit test coverage and fix SIP URI to pass tests. Mainly
fixing the params() setter but make the code more readable in general.
Diffstat (limited to 't')
-rw-r--r-- | t/sip.t | 44 |
1 files changed, 29 insertions, 15 deletions
@@ -1,50 +1,64 @@ use strict; use warnings; -use Test::More tests => 11; +use Test::More tests => 13; use URI (); my $u = URI->new('sip:phone@domain.ext'); ok($u->user eq 'phone' && - $u->host eq 'domain.ext' && - $u->port eq '5060' && - $u eq 'sip:phone@domain.ext'); + $u->host eq 'domain.ext' && + $u->port eq '5060' && + $u->host_port eq 'domain.ext:5060' && + $u->authority eq 'phone@domain.ext' && + $u eq 'sip:phone@domain.ext'); $u->host_port('otherdomain.int:9999'); ok($u->host eq 'otherdomain.int' && $u->port eq '9999' && + $u->host_port eq 'otherdomain.int:9999' && + $u->authority eq 'phone@otherdomain.int:9999' && $u eq 'sip:phone@otherdomain.int:9999'); $u->port('5060'); $u = $u->canonical; -ok($u->host eq 'otherdomain.int' && - $u->port eq '5060' && +ok($u->port eq '5060' && + $u->host_port eq 'otherdomain.int:5060' && + $u->authority eq 'phone@otherdomain.int' && $u eq 'sip:phone@otherdomain.int'); $u->user('voicemail'); ok($u->user eq 'voicemail' && + $u->authority eq 'voicemail@otherdomain.int' && $u eq 'sip:voicemail@otherdomain.int'); +$u->authority('fax@gateway.ext'); +ok($u->user eq 'fax' && + $u->host eq 'gateway.ext' && + $u->host_port eq 'gateway.ext:5060' && + $u->authority eq 'fax@gateway.ext' && + $u eq 'sip:fax@gateway.ext'); + $u = URI->new('sip:phone@domain.ext?Subject=Meeting&Priority=Urgent'); -ok($u->host eq 'domain.ext' && - $u->query eq 'Subject=Meeting&Priority=Urgent'); +ok($u->query eq 'Subject=Meeting&Priority=Urgent'); $u->query_form(Subject => 'Lunch', Priority => 'Low'); my @q = $u->query_form; -ok($u->host eq 'domain.ext' && - $u->query eq 'Subject=Lunch&Priority=Low' && - @q == 4 && "@q" eq "Subject Lunch Priority Low"); +ok($u->query eq 'Subject=Lunch&Priority=Low' && + @q == 4 && "@q" eq 'Subject Lunch Priority Low' && + $u eq 'sip:phone@domain.ext?Subject=Lunch&Priority=Low'); $u = URI->new('sip:phone@domain.ext;maddr=127.0.0.1;ttl=16'); -ok($u->host eq 'domain.ext' && - $u->params eq 'maddr=127.0.0.1;ttl=16'); +ok($u->params eq 'maddr=127.0.0.1;ttl=16'); + +$u->params('maddr=127.0.0.1;ttl=16;x-addedparam=1'); +ok($u->params eq 'maddr=127.0.0.1;ttl=16;x-addedparam=1' && + $u eq 'sip:phone@domain.ext;maddr=127.0.0.1;ttl=16;x-addedparam=1'); $u = URI->new('sip:phone@domain.ext?Subject=Meeting&Priority=Urgent'); $u->params_form(maddr => '127.0.0.1', ttl => '16'); my @p = $u->params_form; -ok($u->host eq 'domain.ext' && - $u->query eq 'Subject=Meeting&Priority=Urgent' && +ok($u->query eq 'Subject=Meeting&Priority=Urgent' && $u->params eq 'maddr=127.0.0.1;ttl=16' && @p == 4 && "@p" eq "maddr 127.0.0.1 ttl 16"); |