Lite/Util/t/inet_4map6.t

filter: Statementstmt 96.8% 31 / 32 Branchbran 75.0% 12 / 16 Conditioncond 66.6% 2 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 100% 4 / 4 Podpod n/a totaltotal 85.9% 49 / 57 CC 2 SCAR 3.8
CC
2
Cov
88%
END
2.1
BEGIN
1.0
BEGIN
1.0
CRAP 1.5
« Lite/Util/t/badd.t ↑ Summary Lite/t/v4-aton.t »
1 # Before `make install' is performed this script should be runnable with
2 # `make test'. After `make install' it should work as `perl test.pl'
3  
4 ######################### We start with some black magic to print on failure.
5 # Change 1..1 below to 1..last_test_to_print .
6 # (It may become useful if the test is moved to ./t subdirectory.)
7 1 $| = 1;
8 1 ▶END {print "1..1\nnot ok 1\n" unless $test;}
Subroutine END: called CC=2 SCAR=7.6
Branch: 1 branch
BranchTrueFalseTotal
unless $test 0 1 1
9  
10 #use diagnostics;
11 1 ▶use NetAddr::IP::Util qw(
Subroutine BEGIN: called CC=1 SCAR=0.0
12 ipv6_n2d
13 inet_aton
14 ipv6_aton
15 inet_4map6
16 1 );
17  
18 1 $test = 1;
19  
20 6 ▶sub ok {
Subroutine ok: called CC=1 SCAR=0.0
21 6 print "ok $test\n";
22 6 ++$test;
23 }
24  
25 # Insert your test code below (better if it prints "ok 13"
26 # (correspondingly "not ok 13") depending on the success of chunk 13
27 # of the test code):
28 1 print "1..6\n";
29  
30 1 my @stuff = qw(
31 192.168.1.1
32 1.2.3.4
33 ::3.4.5.6
34 ::FFFF:4.5.6.7
35 ::1:5.4.3.2
36 ::FEFF:4.3.2.1
37 );
38  
39 1 my $p4 = '0:0:0:0:0:FFFF:';
40 1 my $p6 = '0:0:0:0:0:';
41  
42 1 foreach(0..$#stuff) {
43 6 my $pass = 1;
44 6 my $result;
45 my $bstr;
46 6 ▶ $pass = 0 if $_ > 3;
Branch: 1 branch
BranchTrueFalseTotal
if $_ > 3 2 4 6
47 6 ▶ if ($stuff[$_] =~ /\:/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($stuff[$_] =~ /\:/) { } 4 2 6
48 4 $bstr = ipv6_aton($stuff[$_]);
49 4 ▶ my $prefix = ($stuff[$_] =~ /^\:\:F/)
Branch: 1 branch
BranchTrueFalseTotal
$stuff[$_] =~ /^\:\:F/ ? : 2 2 4
50 ? $p6 : $p4;
51 4 ($result = $stuff[$_]) =~ s/\:\:/$prefix/;
52 }
53 else {
54 2 $bstr = inet_aton($stuff[$_]);
55 2 $result = $p4 . $stuff[$_];
56 }
57 6 my $rv = inet_4map6($bstr);
58 6 ▶ if ($pass && ! $rv) {
Branch: 2 branches
BranchTrueFalseTotal
if ($pass and not $rv) { } 0 6 6
elsif ($pass) { } 4 2 6
Condition66%2/3
$pass and not $rv
!ll&&!rl&&r
240
MC/DC0%0/2
$pass and not $rv
$pass not $rv
Truth table66%2/3
A and not(B)
A= $passB= not $rv
ABresult
0X0
100
111
59 0 print "failed to return valid address\nnot ";
60 }
61 elsif ($pass) {
62 4 $rv = ipv6_n2d($rv);
63 4 ▶ print "got: $rv, exp: $result\nnot " unless $rv eq $result;
Branch: 1 branch
BranchTrueFalseTotal
unless $rv eq $result 0 4 4
64 }
65 else {
66 2 ▶ print 'unknown return ', ipv6_n2d($rv), "\nnot " if $rv;
Branch: 1 branch
BranchTrueFalseTotal
if $rv 0 2 2
67 }
68 6 &ok;
69 }
70  
« Lite/Util/t/badd.t ↑ Summary Lite/t/v4-aton.t »