From ac08882927f8dc22ae0bed60f3d9e706bbe69f12 Mon Sep 17 00:00:00 2001 From: djfiander Date: Sun, 30 Apr 2006 12:17:18 +0000 Subject: [PATCH] minor cleanups --- t/SIPtest.pm | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/t/SIPtest.pm b/t/SIPtest.pm index 4ef0939..61c142e 100644 --- a/t/SIPtest.pm +++ b/t/SIPtest.pm @@ -5,7 +5,7 @@ use Exporter; our @ISA = qw(Exporter); our @EXPORT_OK = qw(run_sip_tests no_tagged_fields - $datepat $text_field + $datepat $textpat $login_test $sc_status_test %field_specs); use strict; @@ -27,14 +27,14 @@ use Sip::Constants qw(:all); our $datepat = '\d{8} {4}\d{6}'; # Pattern for a random text field -our $text_field = qr/^[^|]+$/; +our $textpat = qr/^[^|]+$/; our %field_specs = ( (FID_SCREEN_MSG) => { field => FID_SCREEN_MSG, - pat => $text_field, + pat => $textpat, required => 0, }, (FID_PRINT_LINE) => { field => FID_PRINT_LINE, - pat => $text_field, + pat => $textpat, required => 0, }, (FID_INST_ID) => { field => FID_INST_ID, pat => qr/^UWOLS$/, @@ -76,13 +76,13 @@ our $sc_status_test = { id => 'SC status', $field_specs{(FID_PRINT_LINE)}, $field_specs{(FID_INST_ID)}, { field => 'AM', - pat => $text_field, + pat => $textpat, required => 0, }, { field => 'BX', pat => qr/^[YN]+$/, required => 1, }, { field => 'AN', - pat => $text_field, + pat => $textpat, required => 0, }, ], }; @@ -114,18 +114,20 @@ sub one_msg { # If there are no tagged fields, then 'fields' should be an # empty list which will automatically skip this loop foreach my $ftest (@{$test->{fields}}) { + my $field = $ftest->{field}; + if ($ftest->{required}) { - ok(exists($fields{$ftest->{field}}), - "$test->{id} required field '$ftest->{field}' exists in '$resp'"); + ok(exists($fields{$field}), + "$test->{id} required field '$field' exists in '$resp'"); } - if (exists($fields{$ftest->{field}})) { - like($fields{$ftest->{field}}, $ftest->{pat}, - "$test->{id} field test $ftest->{field} matches in '$resp'"); + if (exists($fields{$field})) { + like($fields{$field}, $ftest->{pat}, + "$test->{id} field test $field matches in '$resp'"); } else { # Don't skip the test, because there's nothing to test # but we need to get the number of tests right. - ok(1, "$test->{id} field test $ftest->{field} not received in '$resp'"); + ok(1, "$test->{id} field test $field not received in '$resp'"); } } } -- 2.11.0