protocol matching new works and so do the tests for it
This commit is contained in:
parent
8217f86980
commit
bece6d6f1c
|
@ -76,7 +76,7 @@ sub new{
|
||||||
};
|
};
|
||||||
|
|
||||||
# run some basic checks to make sure we have the minimum stuff required to work
|
# 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');
|
die ('No states key specified in the argument hash');
|
||||||
}
|
}
|
||||||
if ( ref( \$args{protos} ) eq 'ARRAY' ){
|
if ( ref( \$args{protos} ) eq 'ARRAY' ){
|
||||||
|
|
|
@ -46,7 +46,7 @@ my $returned=1;
|
||||||
eval{
|
eval{
|
||||||
$returned=$checker->match;
|
$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
|
# make sure it will not accept a improper ref type
|
||||||
$returned=1;
|
$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');
|
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 );
|
my $conn=Net::Connection->new( $connection_args );
|
||||||
$returned=0;
|
$returned=0;
|
||||||
eval{
|
eval{
|
||||||
$returned=$checker->match( $conn );
|
$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';
|
$connection_args->{proto}='udp4';
|
||||||
$conn=Net::Connection->new( $connection_args );
|
$conn=Net::Connection->new( $connection_args );
|
||||||
$returned=1;
|
$returned=1;
|
||||||
eval{
|
eval{
|
||||||
$returned=$checker->match( $conn );
|
$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);
|
done_testing(7);
|
||||||
|
|
Loading…
Reference in New Issue