Lite/Util/t/bisIPv4.t

filter: Statementstmt 100% 42 / 42 Branchbran 72.2% 13 / 18 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 5 / 5 Podpod n/a totaltotal 92.3% 60 / 65 CC 2 SCAR 3.2
CC
2
Cov
92%
END
2.1
BEGIN
1.0
BEGIN
1.0
CRAP 1.4
« Lite/Util/t/sub128.t ↑ Summary Lite/Util/t/isIPv4.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..421\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::InetBase qw(
Subroutine BEGIN: called CC=1 SCAR=0.0
12 :upper
13 ipv6_aton
14 ipv6_n2x
15 isIPv4
16 isNewIPv4
17 isAnyIPv4
18 1 );
19  
20 1 $loaded = 1;
21 1 print "ok 1\n";
22 ######################### End of black magic.
23  
24 # Insert your test code below (better if it prints "ok 13"
25 # (correspondingly "not ok 13") depending on the success of chunk 13
26 # of the test code):
27  
28 1 $test = 2;
29  
30 420 ▶sub ok {
Subroutine ok: called CC=1 SCAR=0.0
31 420 print "ok $test\n";
32 420 ++$test;
33 }
34  
35 1 my @num = qw # input
36 (
37 ::
38 8000::
39 4000::
40 2000::
41 1000::
42 800::
43 400::
44 200::
45 100::
46 80::
47 40::
48 20::
49 10::
50 1::
51 0:8000::
52 0:4000::
53 0:2000::
54 0:1000::
55 0:800::
56 0:400::
57 0:200::
58 0:100::
59 0:80::
60 0:40::
61 0:20::
62 0:10::
63 0:1::
64 0:0:8000::
65 0:0:4000::
66 0:0:2000::
67 0:0:1000::
68 0:0:800::
69 0:0:400::
70 0:0:200::
71 0:0:100::
72 0:0:80::
73 0:0:40::
74 0:0:20::
75 0:0:10::
76 0:0:1::
77 0:0:0:8000::
78 0:0:0:4000::
79 0:0:0:2000::
80 0:0:0:1000::
81 0:0:0:800::
82 0:0:0:400::
83 0:0:0:200::
84 0:0:0:100::
85 0:0:0:80::
86 0:0:0:40::
87 0:0:0:20::
88 0:0:0:10::
89 0:0:0:1::
90 0:0:0:0:8000::
91 0:0:0:0:4000::
92 0:0:0:0:2000::
93 0:0:0:0:1000::
94 0:0:0:0:800::
95 0:0:0:0:400::
96 0:0:0:0:200::
97 0:0:0:0:100::
98 0:0:0:0:80::
99 0:0:0:0:40::
100 0:0:0:0:20::
101 0:0:0:0:10::
102 0:0:0:0:1::
103 0:0:0:0:0:8000::
104 0:0:0:0:0:4000::
105 0:0:0:0:0:2000::
106 0:0:0:0:0:1000::
107 0:0:0:0:0:800::
108 0:0:0:0:0:400::
109 0:0:0:0:0:200::
110 0:0:0:0:0:100::
111 0:0:0:0:0:80::
112 0:0:0:0:0:40::
113 0:0:0:0:0:20::
114 0:0:0:0:0:10::
115 0:0:0:0:0:1::
116 ::8000:0
117 ::4000:0
118 ::2000:0
119 ::1000:0
120 ::800:0
121 ::400:0
122 ::200:0
123 ::100:0
124 ::80:0
125 ::40:0
126 ::20:0
127 ::10:0
128 ::1:0
129 ::8000
130 ::4000
131 ::2000
132 ::1000
133 ::800
134 ::400
135 ::200
136 ::100
137 ::80
138 ::40
139 ::20
140 ::10
141 ::1
142 );
143  
144 # check isIPv4
145  
146 1 foreach (@num) {
147 105 my $bstr = ipv6_aton($_);
148 105 my $rv = isIPv4($bstr);
149 105 ▶ my $exp = ($_ =~ /\d::$/) ? 0:1;
Branch: 1 branch
BranchTrueFalseTotal
$_ =~ /\d::$/ ? : 78 27 105
150 105 ▶ print "got: $rv, exp: $exp for ", ipv6_n2x($bstr), "\nnot "
Branch: 1 branch
BranchTrueFalseTotal
unless $rv eq $exp 0 105 105
151 unless $rv eq $exp;
152 105 &ok;
153 }
154  
155 # check isAnyIPv4
156 1 foreach (@num) {
157 105 my $bstr = ipv6_aton($_);
158 105 my $rv = isAnyIPv4($bstr);
159 105 ▶ my $exp = ($_ =~ /\d::$/) ? 0:1;
Branch: 1 branch
BranchTrueFalseTotal
$_ =~ /\d::$/ ? : 78 27 105
160 105 ▶ print "got: $rv, exp: $exp for ", ipv6_n2x($bstr), "\nnot "
Branch: 1 branch
BranchTrueFalseTotal
unless $rv eq $exp 0 105 105
161 unless $rv eq $exp;
162 105 &ok;
163 }
164  
165 1 my $compat = ipv6_aton('::FFFF:0:0');
166  
167 # check isAnyIPv4 with compatible high bits
168 1 foreach (@num) {
169 105 my $bstr = ipv6_aton($_);
170 105 $bstr ^= $compat;
171 105 my $rv = isAnyIPv4($bstr);
172 105 ▶ my $exp = ($_ =~ /\d::$/) ? 0:1;
Branch: 1 branch
BranchTrueFalseTotal
$_ =~ /\d::$/ ? : 78 27 105
173 105 ▶ print "got: $rv, exp: $exp for ", ipv6_n2x($bstr), "\nnot "
Branch: 1 branch
BranchTrueFalseTotal
unless $rv eq $exp 0 105 105
174 unless $rv eq $exp;
175 105 &ok;
176 }
177 # check isNewIPv4 with compatible high bits
178 1 foreach (@num) {
179 105 my $bstr = ipv6_aton($_);
180 105 $bstr ^= $compat;
181 105 my $rv = isNewIPv4($bstr);
182 105 ▶ my $exp = ($_ =~ /\d::$/) ? 0:1;
Branch: 1 branch
BranchTrueFalseTotal
$_ =~ /\d::$/ ? : 78 27 105
183 105 ▶ print "got: $rv, exp: $exp for ", ipv6_n2x($bstr), "\nnot "
Branch: 1 branch
BranchTrueFalseTotal
unless $rv eq $exp 0 105 105
184 unless $rv eq $exp;
185 105 &ok;
186 }
« Lite/Util/t/sub128.t ↑ Summary Lite/Util/t/isIPv4.t »