Branch Coverage

lib/Net/Netmask.pm
Criterion Covered Total %
branch 299 338 88.4


line true false branch
51 81 1819 if (@params % 2)
53 38 43 unless defined $mask
64 417 1483 if ($net =~ m[^([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)/([0-9]+)$]) { }
6 1477 elsif ($net =~ m[^([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)[:/]([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)$]) { }
4 1473 elsif ($net =~ /^([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)[#]([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)$/) { }
7 1466 elsif ($net =~ /^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$/ and $mask =~ /[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$/) { }
6 1460 elsif ($net =~ /^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$/ and $mask =~ /0x[a-f0-9]+/i) { }
770 690 elsif ($net =~ /^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$/ and not $mask) { }
2 688 elsif ($net =~ /^[0-9]+\.[0-9]+\.[0-9]+$/ and not $mask and $shortnet) { }
2 686 elsif ($net =~ /^[0-9]+\.[0-9]+$/ and not $mask and $shortnet) { }
2 684 elsif ($net =~ /^[0-9]+$/ and not $mask and $shortnet) { }
2 682 elsif ($net =~ m[^([0-9]+\.[0-9]+\.[0-9]+)/([0-9]+)$] and $shortnet) { }
2 680 elsif ($net =~ m[^([0-9]+\.[0-9]+)/([0-9]+)$] and $shortnet) { }
2 678 elsif ($net =~ m[^([0-9]+)/([0-9]+)$] and $shortnet) { }
5 673 elsif ($net eq 'default' or $net eq 'any') { }
12 661 elsif ($net =~ /^([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)\s*-\s*([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)$/) { }
326 335 elsif ($net =~ m[^([0-9a-f]*:[0-9a-f]*:[0-9a-f:]*)/([0-9]+)$]) { }
272 63 elsif ($net =~ /^([0-9a-f]*:[0-9a-f]*:[0-9a-f:]*)$/) { }
4 59 elsif ($net eq 'default6' or $net eq 'any6') { }
69 4 2 if (exists $Net::Netmask::quadmask2bits{$quadmask}) { }
77 2 2 if (exists $Net::Netmask::quadhostmask2bits{$hostmask}) { }
86 5 2 if (exists $Net::Netmask::quadmask2bits{$mask}) { }
96 4 2 if (exists $imask2bits{$imask}) { }
122 4 8 unless defined $ibase and defined $end
126 4 4 if not defined $Net::Netmask::error and !defined($bits) || $ibase & ~$imask[$bits]
132 0 326 if ($mask ne '')
136 0 272 if ($mask ne '')
139 0 4 if ($mask ne '')
143 30 29 if $mask
146 0 75 if $Net::Netmask::error and $Net::Netmask::debug
148 85 1815 unless $bits
149 2 1898 if ($proto eq 'IPv4' and $bits > 32) { }
2 3192 elsif ($proto eq 'IPv6' and $bits > 128) { }
150 2 0 unless $Net::Netmask::error
154 2 0 unless $Net::Netmask::error
159 1817 73 unless defined $ibase or $Net::Netmask::error
160 24 1876 unless (defined $ibase or defined $Net::Netmask::error)
162 4 20 if $mask
165 103 1797 if ($Net::Netmask::error)
172 103 1797 $Net::Netmask::error ? :
183 0 17743 unless (defined $ibase)
185 3784 13959 if ($proto eq 'IPv4') { }
199 52 53 if $Net::Netmask::error
204 2 0 @_ ? :
213 392 308 if ($this->{'PROTOCOL'} eq 'IPv4') { }
223 1 2 if ($this->{'PROTOCOL'} eq 'IPv4') { }
255 15 6 if ($this->{'PROTOCOL'} eq 'IPv4') { }
265 1 3 if ($this->{'PROTOCOL'} eq 'IPv4') { }
275 265 263 $this->{'PROTOCOL'} eq 'IPv4' ? :
279 527 1 unless $bitstep
282 6 522 if $index < 0
283 2 526 if $index < 0
284 2 524 if $index >= $size
295 2 1 $proto eq 'IPv4' ? :
3 2 unless $bitstep
301 3 2 if ($proto eq 'IPv4') { }
310 1 1 if ($size / $increment > 1000000000)
338 4 4 if ($this->{'PROTOCOL'} eq 'IPv4') { }
350 3 1 if $blocks == 0
371 1 3 $remainder ? :
374 1 3 unless ($len)
380 2 1 unless ($remainder)
399 5 6 if @_
406 1 1335 unless @bytes == 4
407 28 1307 if grep {not /^(([0-9])|([1-9][0-9]*))$/ && $_ < 256;} @bytes
420 1611 701 if ($_[1] eq 'IPv4') { }
701 0 elsif ($_[1] eq 'IPv6') { }
423 692 9 ref $_[0] ne '' ? :
434 1312 634 if ($_[1] eq 'IPv4') { }
634 0 elsif ($_[1] eq 'IPv6') { }
458 701 909 unless ($addr =~ /:/)
459 37 664 if (length $addr < 32)
467 2 1608 if ($addr =~ /^[0-9a-f:]+[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$/i)
474 724 886 unless (defined $right)
484 887 723 if ($missing) { }
498 18 958 if ($addr =~ s/^0:0:0:0:0:0:0:0$/::/) { }
2 956 elsif ($addr =~ s/(:?^|:)0:0:0:0:0:0:0(:?:|$)/::/) { }
11 945 elsif ($addr =~ s/(:?^|:)0:0:0:0:0:0(:?:|$)/::/) { }
285 660 elsif ($addr =~ s/(:?^|:)0:0:0:0:0(:?:|$)/::/) { }
567 93 elsif ($addr =~ s/(:?^|:)0:0:0:0(:?:|$)/::/) { }
39 54 elsif ($addr =~ s/(:?^|:)0:0:0(:?:|$)/::/) { }
29 25 elsif ($addr =~ s/(:?^|:)0:0(:?:|$)/::/) { }
16 9 elsif ($addr =~ s/(:?^|:)0(:?:|$)/::/) { }
530 11 35 unless $t
533 14 32 if ($this->{'PROTOCOL'} eq 'IPv6')
537 40 6 unless exists $t->{$base}
548 0 13 unless $t
551 1 12 if ($this->{'PROTOCOL'} eq 'IPv6')
559 0 13 unless defined $t->{$base}
564 3 43 if $x
571 7 49 unless $t
573 7 49 $ascii =~ /:/ ? :
576 1 55 unless defined $ip
579 7 48 $proto eq 'IPv6' ? :
582 568 683 if ($proto eq 'IPv6')
585 1207 44 unless exists $t->{$nb}
587 3 41 if $done{$mb}++
591 40 268 if defined $t->{$nb}[$i]
600 0 56 unless $t
607 28 28 if (ref $ipstr) { }
609 25 3 $proto eq 'IPv4' ? :
613 3 25 $ipstr =~ /:/ ? :
614 25 3 $proto eq 'IPv4' ? :
620 1382 646 $proto eq 'IPv4' ? :
621 646 1382 if ($proto eq 'IPv6')
624 1954 74 unless exists $t->{$nb}
627 0 74 if $i < 0
628 0 74 if $i > $maxbits
631 22 151 if defined $t->{$nb}[$i]
640 0 2 unless $t
642 1 1 $ipstr =~ /:/ ? :
643 1 1 $proto eq 'IPv4' ? :
650 33 129 $proto eq 'IPv4' ? :
651 129 33 if ($proto eq 'IPv6')
654 53 109 unless exists $t->{$nb}
656 106 3 if $done{$mb}++
658 0 3 if $i < 0
659 0 3 if $i > $maxbits
662 3 106 if defined $t->{$nb}[$i]
671 0 1 unless $t
677 6 13 if defined $x
687 0 0 unless $t
703 10 14 if ($ip =~ /:/) { }
704 0 10 if ($proto ne 'IPv6')
706 0 14 if ($proto ne 'IPv4')
712 14 10 if ($proto eq 'IPv4') { }
713 8 6 if ($ia == $this->{'IBASE'}) { }
719 6 4 if ($ia == $this->{'IBASE'}) { }
731 80 0 !defined($this->{'ERROR'}) ? :
736 2 6 unless defined $index
738 4 4 if ($this->{'PROTOCOL'} eq 'IPv4') { }
750 4 4 if ($this->{'PROTOCOL'} eq 'IPv4') { }
751 0 4 if $newblock->{'IBASE'} >= 4294967296
753 0 4 if $newblock->{'IBASE'} >= 'Math::BigInt'->new(2)->bpow(128)
756 0 8 if $newblock->{'IBASE'} < 0
762 0 427 unless defined $ibase
764 0 427 unless (defined $proto)
768 415 14153 if $ia != $ibase
778 2 3 if ($startip =~ /:/) { }
779 2 0 if ($endip =~ /:/)
781 3 0 unless ($endip =~ /:/)
783 0 5 unless (defined $proto)
788 1 4 if $start > $end
795 0 39 unless (defined $proto)
797 30 9 $proto eq 'IPv4' ? :
803 40 80 if ($proto eq 'IPv4') { }
808 33 87 if $maxsize < $maxdiff
817 40 80 if ($proto eq 'IPv4') { }
834 1 0 if $nm > $max
847 15 0 if (scalar @cidrs)
849 0 15 if (grep {$proto ne $_->{'PROTOCOL'};} @cidrs)
860 14 11 if $nm > $max
872 4 6 unless ref $outer
878 10 0 if (scalar @cidrs)
888 6 10 if ($first < $cidrs[0]{'IBASE'})
889 2 4 if ($last <= $cidrs[0]{'IBASE'} - 1)
894 0 14 if $cidrs[0]{'IBASE'} > $last
898 4 4 if ($first <= $last)
916 13 32 ref $_[0] ? :
923 64 2 ref $_[0] ? :
924 15 51 if $this->{'IBASE'} > $other->{'IBASE'}
925 5 46 if $this->{'BITS'} > $other->{'BITS'}
926 6 40 if $other->{'IBASE'} > $this->{'IBASE'} + $this->size - 1
931 7793 40 if ($_[0]{'PROTOCOL'} eq 'IPv4' and $_[1]{'PROTOCOL'} eq 'IPv4') { }
36 4 elsif ($_[0]{'PROTOCOL'} eq 'IPv6' and $_[1]{'PROTOCOL'} eq 'IPv6') { }
945 0 63 unless $Net::Netmask::a->[3] cmp $Net::Netmask::b->[3] or $Net::Netmask::a->[1] <=> $Net::Netmask::b->[1]
962 6 8 unless defined $parts and $parts > 0
965 2 6 unless $num_ips >= $parts
970 2 4 unless 2 ** $log2 == $parts