Lite/Util/t/leftshift.t

filter: Statementstmt 100% 25 / 25 Branchbran 75.0% 6 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 5 / 5 Podpod n/a totaltotal 94.7% 36 / 38 CC 2 SCAR 3.2
CC
2
Cov
94%
END
2.1
BEGIN
1.0
BEGIN
1.0
CRAP 1.4
« Lite/Util/t/comp128.t ↑ Summary Lite/Util/t/af_inet6.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  
8 1 ▶BEGIN { $| = 1; print "1..9\n"; }
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 ▶END {print "not ok 1\n" unless $loaded;}
Subroutine END: called CC=2 SCAR=7.6
Branch: 1 branch
BranchTrueFalseTotal
unless $loaded 0 1 1
10  
11 1 ▶use NetAddr::IP::Util qw(
Subroutine BEGIN: called CC=1 SCAR=0.0
12 ipv6_aton
13 ipv6_n2x
14 shiftleft
15 1 );
16  
17 1 $loaded = 1;
18 1 print "ok 1\n";
19 ######################### End of black magic.
20  
21 # Insert your test code below (better if it prints "ok 13"
22 # (correspondingly "not ok 13") depending on the success of chunk 13
23 # of the test code):
24  
25 1 $test = 2;
26  
27 8 ▶sub ok {
Subroutine ok: called CC=1 SCAR=0.0
28 8 print "ok $test\n";
29 8 ++$test;
30 }
31  
32 1 my @num = # input shift expected
33 qw(
34 1::1 none 1:0:0:0:0:0:0:1
35 1::1 0 1:0:0:0:0:0:0:1
36 1::1 1 2:0:0:0:0:0:0:2
37 1::1 2 4:0:0:0:0:0:0:4
38 1::1 3 8:0:0:0:0:0:0:8
39 1::1 15 8000:0:0:0:0:0:0:8000
40 1::1 16 0:0:0:0:0:0:1:0
41 1::1 128 0:0:0:0:0:0:0:0
42 );
43  
44 1 ▶for (my $i=0;$i < @num;$i+=3) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < @num) 8 1 9
45 8 my $bstr = ipv6_aton($num[$i]);
46 8 my $rv;
47 8 ▶ if ($num[$i +1] =~ /\D/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($num[$i + 1] =~ /\D/) { } 1 7 8
48 1 $rv = shiftleft($bstr);
49 }
50 else {
51 7 $rv = shiftleft($bstr,$num[$i +1]);
52 }
53 8 my $exp = $num[$i+2];
54 8 my $got = ipv6_n2x($rv);
55 8 ▶ print "got: $got, exp: $exp\nnot "
Branch: 1 branch
BranchTrueFalseTotal
unless $got eq $exp 0 8 8
56 unless $got eq $exp;
57 8 &ok;
58 }
« Lite/Util/t/comp128.t ↑ Summary Lite/Util/t/af_inet6.t »