Lite/t/v4_new_cis.t

filter: Statementstmt 93.3% 28 / 30 Branchbran 50.0% 2 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 75.0% 3 / 4 Podpod n/a totaltotal 86.8% 33 / 38 CC 1 SCAR 0.0
CC
1
Cov
88%
BEGIN
1.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
« Lite/t/v4-new.t ↑ Summary Lite/t/v4-contains.t »
1 #use diagnostics;
2 1 ▶use NetAddr::IP::Lite;
Subroutine BEGIN: called CC=1 SCAR=0.0
3  
4 1 ▶use Test::More;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 1 my $binword;
7 {
8 1 ▶ local $SIG{__WARN__} = sub {};
Subroutine __ANON__: not called CC=1 SCAR=0.0
9 1 $binword = eval "0b11111111111111110000000000000000";
10 }
11 1 ▶if ($@) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 1 1
12 0 $binword = 0xffff0000;
13 0 print STDERR "\t\tskipped! 0b11111111111111110000000000000000\n\t\tbinary bit strings unsupported in Perl version $]\n";
14 }
15  
16 @a = (
17 1 [ 'localhost', '127.0.0.1' ],
18 [ 0x01010101, '1.1.1.1' ],
19 [ 1, '1.0.0.0' ], # Because it will have a mask. 0.0.0.1 ow
20 [ 'default', '0.0.0.0' ],
21 [ 'any', '0.0.0.0' ],
22 [-809041407, '207.199.2.1'],
23 [3485925889, '207.199.2.1'],
24 );
25  
26 1 @m = (
27 [ 0, '0.0.0.0' ],
28 [ 1, '128.0.0.0' ],
29 [ 2, '192.0.0.0' ],
30 [ 4, '240.0.0.0' ],
31 [ 8, '255.0.0.0' ],
32 [ 16, '255.255.0.0' ],
33 [ 17, '255.255.128.0' ],
34 [ 24, '255.255.255.0' ],
35 [ 'default', '0.0.0.0' ],
36 [ 32, '255.255.255.255' ],
37 [ 'host', '255.255.255.255' ],
38 [ 0xffffff00, '255.255.255.0' ],
39 [ '255.255.255.240', '255.255.255.240' ],
40 [ '255.255.128.0', '255.255.128.0' ],
41 [ $binword, '255.255.0.0' ],
42 );
43  
44 1 plan tests => (4 * scalar @a * scalar @m) + 4;
45  
46 1 foreach my $invalid (qw(
47 256.1.1.1
48 256.256.1.1
49 256.256.256.1
50 256.256.256.256
51 )) {
52 4 ok (! defined NetAddr::IP::Lite->new($invalid), "Invalid IP $invalid returns undef");
53 }
54  
55 1 for my $a (@a) {
56 7 for my $m (@m) {
57 105 my $ip = new_cis NetAddr::IP::Lite "$a->[0] $m->[0]";
58 SKIP:
59 {
60 105 ▶ skip "Failed to make an object for $a->[0]/$m->[0]", 4
Branch: 1 branch
BranchTrueFalseTotal
unless defined $ip 0 105 105
61 unless defined $ip;
62 105 is($ip->addr, $a->[1], "$a->[0] / $m->[0] is $a->[1]");
63 105 is($ip->mask, $m->[1], "$a->[0] / $m->[0] is $m->[1]");
64 105 is($ip->bits, 32, "$a->[0] / $m->[0] is 32 bits wide");
65 105 is($ip->version, 4, "$a->[0] / $m->[0] is version 4");
66 };
67 }
68 }
« Lite/t/v4-new.t ↑ Summary Lite/t/v4-contains.t »