Branch Coverage

lib/Net/Netmask.pm
Criterion Covered Total %
branch 296 336 88.1


line true false branch
51 62 1784 if (@params % 2)
53 38 24 unless defined $mask
64 410 1436 if ($net =~ m[^([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)/([0-9]+)$]) { }
4 1432 elsif ($net =~ m[^([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)[:/]([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)$]) { }
3 1429 elsif ($net =~ /^([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)[#]([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)$/) { }
5 1424 elsif ($net =~ /^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$/ and $mask =~ /[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$/) { }
4 1420 elsif ($net =~ /^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$/ and $mask =~ /0x[a-f0-9]+/i) { }
766 654 elsif ($net =~ /^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$/ and not $mask) { }
2 652 elsif ($net =~ /^[0-9]+\.[0-9]+\.[0-9]+$/ and not $mask and $shortnet) { }
2 650 elsif ($net =~ /^[0-9]+\.[0-9]+$/ and not $mask and $shortnet) { }
2 648 elsif ($net =~ /^[0-9]+$/ and not $mask and $shortnet) { }
2 646 elsif ($net =~ m[^([0-9]+\.[0-9]+\.[0-9]+)/([0-9]+)$] and $shortnet) { }
2 644 elsif ($net =~ m[^([0-9]+\.[0-9]+)/([0-9]+)$] and $shortnet) { }
2 642 elsif ($net =~ m[^([0-9]+)/([0-9]+)$] and $shortnet) { }
5 637 elsif ($net eq 'default' or $net eq 'any') { }
8 629 elsif ($net =~ /^([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)\s*-\s*([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)$/) { }
323 306 elsif ($net =~ m[^([0-9a-f]*:[0-9a-f]*:[0-9a-f:]*)/([0-9]+)$]) { }
272 34 elsif ($net =~ /^([0-9a-f]*:[0-9a-f]*:[0-9a-f:]*)$/) { }
4 30 elsif ($net eq 'default6' or $net eq 'any6') { }
69 3 1 if (exists $Net::Netmask::quadmask2bits{$quadmask}) { }
77 2 1 if (exists $Net::Netmask::quadhostmask2bits{$hostmask}) { }
86 4 1 if (exists $Net::Netmask::quadmask2bits{$mask}) { }
96 3 1 if (exists $imask2bits{$imask}) { }
122 2 6 unless defined $ibase and defined $end
126 2 4 if not defined $Net::Netmask::error and !defined($bits) || $ibase & ~$imask[$bits]
132 0 323 if ($mask ne '')
136 0 272 if ($mask ne '')
139 0 4 if ($mask ne '')
143 15 15 if $mask
146 0 38 if $Net::Netmask::error and $Net::Netmask::debug
148 49 1797 unless $bits
149 1 1845 if ($proto eq 'IPv4' and $bits > 32) { }
0 3091 elsif ($proto eq 'IPv6' and $bits > 128) { }
150 1 0 unless $Net::Netmask::error
154 0 0 unless $Net::Netmask::error
159 1839 7 unless defined $ibase
160 12 1834 unless (defined $ibase or defined $Net::Netmask::error)
162 2 10 if $mask
167 51 1795 $Net::Netmask::error ? :
178 43 17481 unless (defined $ibase)
180 3655 13826 if ($proto eq 'IPv4') { }
190 51 51 if $Net::Netmask::error
195 2 0 @_ ? :
204 392 308 if ($this->{'PROTOCOL'} eq 'IPv4') { }
214 1 2 if ($this->{'PROTOCOL'} eq 'IPv4') { }
246 15 6 if ($this->{'PROTOCOL'} eq 'IPv4') { }
256 1 3 if ($this->{'PROTOCOL'} eq 'IPv4') { }
266 265 263 $this->{'PROTOCOL'} eq 'IPv4' ? :
270 527 1 unless $bitstep
273 6 522 if $index < 0
274 2 526 if $index < 0
275 2 524 if $index >= $size
286 2 1 $proto eq 'IPv4' ? :
3 2 unless $bitstep
292 3 2 if ($proto eq 'IPv4') { }
301 1 1 if ($size / $increment > 1000000000)
329 4 4 if ($this->{'PROTOCOL'} eq 'IPv4') { }
341 3 1 if $blocks == 0
362 1 3 $remainder ? :
365 1 3 unless ($len)
371 2 1 unless ($remainder)
390 5 6 if @_
397 32 1318 unless @bytes == 4
398 14 1304 if grep {not /^(([0-9])|([1-9][0-9]*))$/ && $_ < 256;} @bytes
411 1561 700 if ($_[1] eq 'IPv4') { }
700 0 elsif ($_[1] eq 'IPv6') { }
414 691 9 ref $_[0] ne '' ? :
425 1334 632 if ($_[1] eq 'IPv4') { }
632 0 elsif ($_[1] eq 'IPv6') { }
449 700 907 unless ($addr =~ /:/)
450 36 664 if (length $addr < 32)
458 2 1605 if ($addr =~ /^[0-9a-f:]+[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$/i)
465 723 884 unless (defined $right)
475 885 722 if ($missing) { }
489 17 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(:?:|$)/::/) { }
521 9 35 unless $t
524 13 31 if ($this->{'PROTOCOL'} eq 'IPv6')
528 40 4 unless exists $t->{$base}
539 0 13 unless $t
542 1 12 if ($this->{'PROTOCOL'} eq 'IPv6')
550 0 13 unless defined $t->{$base}
555 3 43 if $x
562 7 47 unless $t
564 6 48 $ascii =~ /:/ ? :
567 1 53 unless defined $ip
570 6 47 $proto eq 'IPv6' ? :
573 439 650 if ($proto eq 'IPv6')
576 1045 44 unless exists $t->{$nb}
578 3 41 if $done{$mb}++
582 40 268 if defined $t->{$nb}[$i]
591 0 56 unless $t
598 28 28 if (ref $ipstr) { }
600 25 3 $proto eq 'IPv4' ? :
604 3 25 $ipstr =~ /:/ ? :
605 25 3 $proto eq 'IPv4' ? :
611 1382 646 $proto eq 'IPv4' ? :
612 646 1382 if ($proto eq 'IPv6')
615 1954 74 unless exists $t->{$nb}
618 0 74 if $i < 0
619 0 74 if $i > $maxbits
622 22 151 if defined $t->{$nb}[$i]
631 0 2 unless $t
633 1 1 $ipstr =~ /:/ ? :
634 1 1 $proto eq 'IPv4' ? :
641 33 129 $proto eq 'IPv4' ? :
642 129 33 if ($proto eq 'IPv6')
645 53 109 unless exists $t->{$nb}
647 106 3 if $done{$mb}++
649 0 3 if $i < 0
650 0 3 if $i > $maxbits
653 3 106 if defined $t->{$nb}[$i]
662 0 1 unless $t
668 6 13 if defined $x
678 0 0 unless $t
694 10 14 if ($ip =~ /:/) { }
695 0 10 if ($proto ne 'IPv6')
697 0 14 if ($proto ne 'IPv4')
703 14 10 if ($proto eq 'IPv4') { }
704 8 6 if ($ia == $this->{'IBASE'}) { }
710 6 4 if ($ia == $this->{'IBASE'}) { }
722 78 0 !defined($this->{'ERROR'}) ? :
727 2 6 unless defined $index
729 4 4 if ($this->{'PROTOCOL'} eq 'IPv4') { }
741 4 4 if ($this->{'PROTOCOL'} eq 'IPv4') { }
742 0 4 if $newblock->{'IBASE'} >= 4294967296
744 0 4 if $newblock->{'IBASE'} >= 'Math::BigInt'->new(2)->bpow(128)
747 0 8 if $newblock->{'IBASE'} < 0
753 0 425 unless defined $ibase
755 0 425 unless (defined $proto)
759 413 14152 if $ia != $ibase
769 2 3 if ($startip =~ /:/) { }
770 2 0 if ($endip =~ /:/)
772 3 0 unless ($endip =~ /:/)
774 0 5 unless (defined $proto)
779 1 4 if $start > $end
786 0 39 unless (defined $proto)
788 30 9 $proto eq 'IPv4' ? :
794 40 80 if ($proto eq 'IPv4') { }
799 33 87 if $maxsize < $maxdiff
808 40 80 if ($proto eq 'IPv4') { }
825 1 0 if $nm > $max
838 15 0 if (scalar @cidrs)
840 0 15 if (grep {$proto ne $_->{'PROTOCOL'};} @cidrs)
851 14 11 if $nm > $max
863 4 6 unless ref $outer
869 10 0 if (scalar @cidrs)
879 6 10 if ($first < $cidrs[0]{'IBASE'})
880 2 4 if ($last <= $cidrs[0]{'IBASE'} - 1)
885 0 14 if $cidrs[0]{'IBASE'} > $last
889 4 4 if ($first <= $last)
907 13 32 ref $_[0] ? :
914 64 2 ref $_[0] ? :
915 15 51 if $this->{'IBASE'} > $other->{'IBASE'}
916 5 46 if $this->{'BITS'} > $other->{'BITS'}
917 6 40 if $other->{'IBASE'} > $this->{'IBASE'} + $this->size - 1
922 7793 40 if ($_[0]{'PROTOCOL'} eq 'IPv4' and $_[1]{'PROTOCOL'} eq 'IPv4') { }
36 4 elsif ($_[0]{'PROTOCOL'} eq 'IPv6' and $_[1]{'PROTOCOL'} eq 'IPv6') { }
936 0 63 unless $Net::Netmask::a->[3] cmp $Net::Netmask::b->[3] or $Net::Netmask::a->[1] <=> $Net::Netmask::b->[1]
953 6 8 unless defined $parts and $parts > 0
956 2 6 unless $num_ips >= $parts
961 2 4 unless 2 ** $log2 == $parts