Lite/t/v4-contains.t

filter: Statementstmt 100% 21 / 21 Branchbran 50.0% 4 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 2 / 2 Podpod n/a totaltotal 87.1% 27 / 31 CC 1 SCAR 0.0
CC
1
Cov
86%
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
« Lite/t/v4_new_cis.t ↑ Summary Lite/t/bin_ips.t »
1 1 ▶use NetAddr::IP::Lite;
Subroutine BEGIN: called CC=1 SCAR=0.0
2  
3 1 my @yes_pairs = (
4 [ [ '127.0.0.0', '255.0.0.0' ],
5 [ '127.0.0.1', '255.255.255.255'] ],
6 [ [ '10.0.0.0', '255.255.255.0' ],
7 [ '10.0.0.128', '255.255.255.128' ] ],
8 [ [ '10.0.0.0', '255.0.0.0' ],
9 [ '10.0.0.0', '255.0.0.0' ]],
10 [ [ '10.0.0.0', '255.0.0.0' ],
11 [ '10.0.0.1', '255.0.0.0' ]],
12 [ [ '10.0.0.0', '255.255.255.254' ],
13 [ '10.0.0.1', '255.255.255.254' ]],
14 [ [ '10.0.0.0', '255.255.255.254' ],
15 [ '10.0.0.1', '255.255.255.255' ]],
16 [ [ '10.0.0.1', '255.0.0.0' ],
17 [ '10.0.0.1', '255.255.255.255' ]],
18 [ [ 'default', 'default' ],
19 [ '10.0.0.1', '255.255.255.254' ]],
20 [ [ 'default', 'default' ],
21 [ 'broadcast', undef ]],
22 [ [ 'loopback', '255.0.0.0' ],
23 [ '127.0.0.0', '255.0.0.0' ] ],
24 );
25  
26 1 my @no_pairs = (
27 [ [ '127.0.0.1', '255.255.255.255' ],
28 [ '127.0.0.0', '255.0.0.0' ] ],
29 [ [ '10.0.0.0', '255.0.0.0' ],
30 [ '11.0.0.0', '255.0.0.0' ] ],
31 [ [ '10.0.1.0', '255.255.255.0' ],
32 [ '10.0.2.0', '255.255.255.0' ] ],
33 [ [ '10.0.0.1', '255.255.255.254' ],
34 [ 'default', '0' ] ],
35 );
36  
37 1 $| = 1;
38 1 print "1..", 2 * (scalar @yes_pairs + scalar @no_pairs), "\n";
39  
40 1 my $count = 1;
41  
42 1 for my $p (@yes_pairs) {
43 10 my $ip_a = new NetAddr::IP::Lite $p->[0]->[0], $p->[0]->[1];
44 10 my $ip_b = new NetAddr::IP::Lite $p->[1]->[0], $p->[1]->[1];
45 10 ▶ print (($ip_a->contains($ip_b) ? '' : 'not '), 'ok ', $count++, "\n");
Branch: 1 branch
BranchTrueFalseTotal
$ip_a->contains($ip_b) ? : 10 0 10
46 10 ▶ print (($ip_b->within($ip_a) ? '' : 'not '), 'ok ', $count++, "\n");
Branch: 1 branch
BranchTrueFalseTotal
$ip_b->within($ip_a) ? : 10 0 10
47  
48 # print "a = ", $ip_a->addr, "/", $ip_a->mask, "\n";
49 # print "b = ", $ip_b->addr, "/", $ip_b->mask, "\n";
50  
51 }
52  
53 1 for my $p (@no_pairs) {
54 4 my $ip_a = new NetAddr::IP::Lite $p->[0]->[0], $p->[0]->[1];
55 4 my $ip_b = new NetAddr::IP::Lite $p->[1]->[0], $p->[1]->[1];
56 4 ▶ print (($ip_a->contains($ip_b) ? 'not ' : ''), 'ok ', $count++, "\n");
Branch: 1 branch
BranchTrueFalseTotal
$ip_a->contains($ip_b) ? : 0 4 4
57 4 ▶ print (($ip_b->within($ip_a) ? 'not ' : ''), 'ok ', $count++, "\n");
Branch: 1 branch
BranchTrueFalseTotal
$ip_b->within($ip_a) ? : 0 4 4
58 }
59  
60  
« Lite/t/v4_new_cis.t ↑ Summary Lite/t/bin_ips.t »