Lite/t/over_copy.t

filter: Statementstmt 100% 51 / 51 Branchbran 50.0% 8 / 16 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 4 / 4 Podpod n/a totaltotal 88.7% 63 / 71 CC 1 SCAR 0.0
CC
1
Cov
88%
BEGIN
1.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
« Lite/t/v4-old-first.t ↑ Summary Lite/t/lemasklen.t »
1  
2 #use diagnostics;
3 1 ▶use NetAddr::IP::Lite 0.10;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 *Ones = \&NetAddr::IP::Lite::Ones;
5 1 ▶use NetAddr::IP::Util qw(
Subroutine BEGIN: called CC=1 SCAR=0.0
6 ipv6_aton
7 shiftleft
8 1 );
9 1 $| = 1;
10  
11 1 print "1..8\n";
12  
13 1 my $test = 1;
14 8 ▶sub ok() {
Subroutine ok: called CC=1 SCAR=0.0
15 8 print 'ok ',$test++,"\n";
16 }
17  
18 1 my $ip24 = '1.2.3.4/24';
19 1 my $o = new NetAddr::IP::Lite($ip24);
20 1 my $c = $o;
21  
22 ## test 1 validate original
23 1 my $txto = sprintf("%s",$o);
24 1 my $txtc = sprintf("%s",$c);
25 1 ▶print "orig... got: $txto, exp: $ip24\nnot "
Branch: 1 branch
BranchTrueFalseTotal
unless $txto eq $ip24 0 1 1
26 unless $txto eq $ip24;
27 1 &ok;
28  
29 ## test 2
30 1 ▶print "copy... got: $txtc, exp: $ip24\nnot "
Branch: 1 branch
BranchTrueFalseTotal
unless $txtc eq $ip24 0 1 1
31 unless $txtc eq $ip24;
32 1 &ok;
33  
34 1 my $ip28 = '1.2.3.4/28';
35 1 my $mask = shiftleft(Ones(),32 - 28);
36  
37 1 $c->{mask} = $mask;
38 1 $txto = sprintf("%s",$o);
39 1 $txtc = sprintf("%s",$c);
40  
41 ## overload does not unlink originals in this case
42 ## test 3 validate original
43 1 $txto = sprintf("%s",$o);
44 1 $txtc = sprintf("%s",$c);
45 1 ▶print "orig... got: $txto, exp: $ip28\nnot "
Branch: 1 branch
BranchTrueFalseTotal
unless $txto eq $ip28 0 1 1
46 unless $txto eq $ip28;
47 1 &ok;
48  
49 ## test 4
50 1 ▶print "copy... got: $txtc, exp: $ip28\nnot "
Branch: 1 branch
BranchTrueFalseTotal
unless $txtc eq $ip28 0 1 1
51 unless $txtc eq $ip28;
52 1 &ok;
53  
54 1 my $ip265 = '1.2.3.5/26';
55 1 my $ip285 = '1.2.3.5/28';
56 1 $mask = shiftleft(Ones(),32 - 26);
57  
58 ## test 5 overload seperates variables
59 1 $c++;
60 ## validate original
61 1 $txto = sprintf("%s",$o);
62 1 $txtc = sprintf("%s",$c);
63 1 ▶print "orig... got: $txto, exp: $ip28\nnot "
Branch: 1 branch
BranchTrueFalseTotal
unless $txto eq $ip28 0 1 1
64 unless $txto eq $ip28;
65 1 &ok;
66  
67 ## test 6 check mutated copy
68 1 ▶print "copy... got: $txtc, exp: $ip285\nnot "
Branch: 1 branch
BranchTrueFalseTotal
unless $txtc eq $ip285 0 1 1
69 unless $txtc eq $ip285;
70 1 &ok;
71  
72 ## test 7 check seperation
73 1 $c->{mask} = $mask;
74 ## validate original
75 1 $txto = sprintf("%s",$o);
76 1 $txtc = sprintf("%s",$c);
77 1 ▶print "orig... got: $txto, exp: $ip28\nnot "
Branch: 1 branch
BranchTrueFalseTotal
unless $txto eq $ip28 0 1 1
78 unless $txto eq $ip28;
79 1 &ok;
80  
81 ## test 8 check mutated copy
82 1 ▶print "copy... got: $txtc, exp: $ip265\nnot "
Branch: 1 branch
BranchTrueFalseTotal
unless $txtc eq $ip265 0 1 1
83 unless $txtc eq $ip265;
84 1 &ok;
85  
« Lite/t/v4-old-first.t ↑ Summary Lite/t/lemasklen.t »