use
5.008;
tests
=> 12;
use_ok(
'Net::IP::Identifier'
,
qw( Inktomi Google )
);
my
$identifier
= Net::IP::Identifier->new;
is (
ref
$identifier
,
'Net::IP::Identifier'
,
'instantiate Identifier'
);
is (
$identifier
->identify(
'1.1.1.1'
),
undef
,
'1.1.1.1 not identified'
);
is (
$identifier
->identify(
'8.8.4.4'
),
'Google'
,
'Google identified'
);
$identifier
->cidr(1);
is (
$identifier
->identify(
'8.8.4.4'
),
'Google:8.8.4.0/24'
,
'Google identified with cidr'
);
is (
$identifier
->identify(
'72.30.5.6'
),
'Inktomi:72.30.0.0/16'
,
'Inktomi identified with cidr'
);
$identifier
->entities([]);
is (
$identifier
->identify(
'72.30.5.6'
),
'Inktomi:72.30.0.0/16'
,
'Inktomi identified with cidr'
);
is (
$identifier
->identify(
'157.54.0.0/15'
),
'Microsoft:157.54.0.0/15'
,
'identifed netblock'
);
$identifier
->joiner(
'--'
);
is (
$identifier
->identify(
'72.30.5.6'
),
'Inktomi--72.30.0.0/16'
,
'custom joiner'
);
my
@parts
=
$identifier
->identify(
'72.30.5.6'
);
is_deeply(\
@parts
, [
qw(Inktomi 72.30.0.0/16)
],
'array context'
);
$identifier
->entities(
qw(
Net::IP::Identifier::Plugin::Inktomi
)
);
is (
$identifier
->identify(
'72.30.5.6'
),
'Inktomi--72.30.0.0/16'
,
'Inktomi loaded by itself 1'
);
is (
$identifier
->identify(
'8.8.4.4'
),
undef
,
'Inktomi loaded by itself 2'
);