Browse Source

protocol matching new works and so do the tests for it

tags/0.0.0
Zane C. B-H 5 months ago
parent
commit
bece6d6f1c
2 changed files with 6 additions and 6 deletions
  1. +1
    -1
      Net-Connection-Match/lib/Net/Connection/Match/Protos.pm
  2. +5
    -5
      Net-Connection-Match/t/Protos.t

+ 1
- 1
Net-Connection-Match/lib/Net/Connection/Match/Protos.pm View File

@@ -76,7 +76,7 @@ sub new{
};

# run some basic checks to make sure we have the minimum stuff required to work
if ( ! defined( $args{states} ) ){
if ( ! defined( $args{protos} ) ){
die ('No states key specified in the argument hash');
}
if ( ref( \$args{protos} ) eq 'ARRAY' ){

+ 5
- 5
Net-Connection-Match/t/Protos.t View File

@@ -46,7 +46,7 @@ my $returned=1;
eval{
$returned=$checker->match;
};
ok( $returned eq '0', 'match undef check') or diag('match accepted undefined input');
ok( $returned eq '0', 'proto undef check') or diag('match accepted undefined input');

# make sure it will not accept a improper ref type
$returned=1;
@@ -55,21 +55,21 @@ eval{
};
ok( $returned eq '0', 'match improper ref check') or diag('match accepted a ref other than Net::Connection');

# Create a connection with a matching state and see if it matches
# Create a connection with a matching protocol and see if it matches
my $conn=Net::Connection->new( $connection_args );
$returned=0;
eval{
$returned=$checker->match( $conn );
};
ok( $returned eq '1', 'state match check') or diag('Failed to match a matching good state');
ok( $returned eq '1', 'proto match check') or diag('Failed to match a matching good protocol');

# Create a connection with a non-matching state and make sure it does not match
# Create a connection with a non-matching protocol and make sure it does not match
$connection_args->{proto}='udp4';
$conn=Net::Connection->new( $connection_args );
$returned=1;
eval{
$returned=$checker->match( $conn );
};
ok( $returned eq '0', 'state non-match check') or diag('Matched a state that it should not of');
ok( $returned eq '0', 'proto non-match check') or diag('Matched a protocol that it should not of');

done_testing(7);

Loading…
Cancel
Save