Lite/Util/t/anyto6.t

filter: Statementstmt 100% 45 / 45 Branchbran 50.0% 7 / 14 Conditioncond 33.3% 3 / 9 MC/DCmcdc 0.0% 0 / 6 Subroutinesub 100% 5 / 5 Podpod n/a totaltotal 75.9% 60 / 79 CC 2 SCAR 3.2
CC
2
Cov
81%
END
2.1
BEGIN
1.0
BEGIN
1.0
CRAP 1.4
« Lite/Util/t/naip_gethostbyname.t ↑ Summary Lite/Util/t/4to6.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..7\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 ipanyto6
16 maskanyto6
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 6 ▶sub ok {
Subroutine ok: called CC=1 SCAR=0.0
30 6 print "ok $test\n";
31 6 ++$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 = ipanyto6($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 = maskanyto6($nip);
48 1 $ipv6 = ipv6_n2d($nipv6);
49 1 ▶print "got: $ipv6\nexp: $exp\nnot "
Branch: 1 branch
BranchTrueFalseTotal
unless $ipv6 eq $exp and &ok 0 1 1
Condition33%1/3
$ipv6 eq $exp and &ok
!ll&&!rl&&r
001
MC/DC0%0/2
$ipv6 eq $exp and &ok
$ipv6 eq $exp &ok
Truth table33%1/3
A and B
A= $ipv6 eq $expB= &ok
ABresult
0X0
100
111
50 unless $ipv6 eq $exp &&
51 &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 ipanyto6($nip);
57 };
58 1 ▶print "ipanyto6 accepted bad argument length\nnot "
Branch: 1 branch
BranchTrueFalseTotal
unless $@ and $@ =~ /Bad arg.+ipanyto6/ 0 1 1
Condition33%1/3
$@ and $@ =~ /Bad arg.+ipanyto6/
!ll&&!rl&&r
001
MC/DC0%0/2
$@ and $@ =~ /Bad arg.+ipanyto6/
$@ $@ =~ /Bad arg.+ipanyto6/
Truth table33%1/3
A and B
A= $@B= $@ =~ /Bad arg.+ipanyto6/
ABresult
0X0
100
111
59 unless $@ && $@ =~ /Bad arg.+ipanyto6/;
60 1 &ok;
61  
62 ## test 5 check bad length
63 1 eval {
64 1 maskanyto6($nip);
65 };
66 1 ▶print "maskanyto6 accepted bad argument length\nnot "
Branch: 1 branch
BranchTrueFalseTotal
unless $@ and $@ =~ /Bad arg.+maskanyto6/ 0 1 1
Condition33%1/3
$@ and $@ =~ /Bad arg.+maskanyto6/
!ll&&!rl&&r
001
MC/DC0%0/2
$@ and $@ =~ /Bad arg.+maskanyto6/
$@ $@ =~ /Bad arg.+maskanyto6/
Truth table33%1/3
A and B
A= $@B= $@ =~ /Bad arg.+maskanyto6/
ABresult
0X0
100
111
67 unless $@ && $@ =~ /Bad arg.+maskanyto6/;
68 1 &ok;
69  
70 ## test 6 check pass of ipv6 addrs
71 1 $nip = ipv6_aton('::1:2.3.4.5');
72 1 $exp = '0:0:0:0:0:1:2.3.4.5';
73 1 $nipv6 = ipanyto6($nip);
74 1 $ipv6 = ipv6_n2d($nipv6);
75 1 ▶print "got: $ipv6\nexp: $exp\nnot "
Branch: 1 branch
BranchTrueFalseTotal
unless $ipv6 eq $exp 0 1 1
76 unless $ipv6 eq $exp;
77 1 &ok;
78  
79 ## test 7 check pass of ipv6 addrs
80 1 $nip = ipv6_aton('FFF::1:2.3.4.5');
81 1 $exp = 'FFF:0:0:0:0:1:2.3.4.5';
82 1 $nipv6 = maskanyto6($nip);
83 1 $ipv6 = ipv6_n2d($nipv6);
84 1 ▶print "got: $ipv6\nexp: $exp\nnot "
Branch: 1 branch
BranchTrueFalseTotal
unless $ipv6 eq $exp 0 1 1
85 unless $ipv6 eq $exp;
86 1 &ok;
« Lite/Util/t/naip_gethostbyname.t ↑ Summary Lite/Util/t/4to6.t »