Lite/Util/t/4to6.t

filter: Statementstmt 100% 34 / 34 Branchbran 50.0% 5 / 10 Conditioncond 33.3% 2 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 100% 5 / 5 Podpod n/a totaltotal 77.9% 46 / 59 CC 2 SCAR 3.2
CC
2
Cov
82%
END
2.1
BEGIN
1.0
BEGIN
1.0
CRAP 1.4
« Lite/Util/t/anyto6.t ↑ Summary Lite/Util/t/bipv6func.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..5\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 inet_aton
13 ipv6_n2d
14 ipv6_aton
15 ipv4to6
16 mask4to6
17 1 );
18  
19 1 $loaded = 1;
20 1 print "ok 1\n";
21 ######################### End of black magic.
22  
23 # Insert your test code below (better if it prints "ok 13"
24 # (correspondingly "not ok 13") depending on the success of chunk 13
25 # of the test code):
26  
27 1 $test = 2;
28  
29 4 ▶sub ok {
Subroutine ok: called CC=1 SCAR=0.0
30 4 print "ok $test\n";
31 4 ++$test;
32 }
33  
34 1 my $nip = inet_aton('1.2.3.4');
35 1 my $exp = '0:0:0:0:0:0:1.2.3.4';
36  
37 ## test 2 check 4->6 conversion
38 1 my $nipv6 = ipv4to6($nip);
39 1 my $ipv6 = ipv6_n2d($nipv6);
40 1 ▶print "got: $ipv6\nexp: $exp\nnot "
Branch: 1 branch
BranchTrueFalseTotal
unless $ipv6 eq $exp 0 1 1
41 unless $ipv6 eq $exp;
42 1 &ok;
43  
44  
45 ## test 3 check mask4->6 extension
46 1 $exp = 'FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:1.2.3.4';
47 1 $nipv6 = mask4to6($nip);
48 1 $ipv6 = ipv6_n2d($nipv6);
49 1 ▶print "got: $ipv6\nexp: $exp\nnot "
Branch: 1 branch
BranchTrueFalseTotal
unless $ipv6 eq $exp 0 1 1
50 unless $ipv6 eq $exp;
51 1 &ok;
52  
53 ## test 4 check bad length
54 1 $nip = pack("H9",0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09);
55 1 eval {
56 1 ipv4to6($nip);
57 };
58 1 ▶print "ipv4to6 accepted bad argument length\nnot "
Branch: 1 branch
BranchTrueFalseTotal
unless $@ and $@ =~ /Bad arg.+ipv4to6/ 0 1 1
Condition33%1/3
$@ and $@ =~ /Bad arg.+ipv4to6/
!ll&&!rl&&r
001
MC/DC0%0/2
$@ and $@ =~ /Bad arg.+ipv4to6/
$@ $@ =~ /Bad arg.+ipv4to6/
Truth table33%1/3
A and B
A= $@B= $@ =~ /Bad arg.+ipv4to6/
ABresult
0X0
100
111
59 unless $@ && $@ =~ /Bad arg.+ipv4to6/;
60 1 &ok;
61  
62 ## test 5 check bad length
63 1 eval {
64 1 mask4to6($nip);
65 };
66 1 ▶print "mask4to6 accepted bad argument length\nnot "
Branch: 1 branch
BranchTrueFalseTotal
unless $@ and $@ =~ /Bad arg.+mask4to6/ 0 1 1
Condition33%1/3
$@ and $@ =~ /Bad arg.+mask4to6/
!ll&&!rl&&r
001
MC/DC0%0/2
$@ and $@ =~ /Bad arg.+mask4to6/
$@ $@ =~ /Bad arg.+mask4to6/
Truth table33%1/3
A and B
A= $@B= $@ =~ /Bad arg.+mask4to6/
ABresult
0X0
100
111
67 unless $@ && $@ =~ /Bad arg.+mask4to6/;
68 1 &ok;
69  
« Lite/Util/t/anyto6.t ↑ Summary Lite/Util/t/bipv6func.t »