Lite/Util/t/croak.t

filter: Statementstmt 95.6% 87 / 91 Branchbran 50.0% 19 / 38 Conditioncond 33.3% 15 / 45 MC/DCmcdc 0.0% 0 / 30 Subroutinesub 100% 5 / 5 Podpod n/a totaltotal 60.2% 126 / 209 CC 2 SCAR 3.2
CC
2
Cov
70%
END
2.1
BEGIN
1.0
BEGIN
1.0
CRAP 1.4
« Lite/Util/t/mode.t ↑ Summary Lite/Util/t/no6_naip_gethostbyname.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..31\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 bcd2bin
13 bin2bcd
14 hasbits
15 isIPv4
16 add128
17 sub128
18 shiftleft
19 comp128
20 bcdn2txt
21 bin2bcdn
22 bcdn2bin
23 simple_pack
24 1 );
25  
26 1 $loaded = 1;
27 1 print "ok 1\n";
28 ######################### End of black magic.
29  
30 # Insert your test code below (better if it prints "ok 13"
31 # (correspondingly "not ok 13") depending on the success of chunk 13
32 # of the test code):
33  
34 1 $test = 2;
35  
36 30 ▶sub ok {
Subroutine ok: called CC=1 SCAR=0.0
37 30 print "ok $test\n";
38 30 ++$test;
39 }
40  
41 ## tests 2 - 9 simple_pack
42  
43 1 foreach(
44 '1234/',
45 '1234:',
46 'a1234',
47 '&1234',
48 ) {
49 4 my $rv;
50 4 eval { $rv = simple_pack($_) };
51 4 ▶ if (defined $rv) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $rv) 0 4 4
52 0 $rv = unpack("H40",$rv);
53 0 print "got: $rv, exp: 'die'\nnot ";
54 }
55 4 &ok;
56  
57 4 ▶ print "expected a die from bad character input\nnot "
Branch: 1 branch
BranchTrueFalseTotal
unless $@ and $@ =~ /Bad/ 0 4 4
Condition33%1/3
$@ and $@ =~ /Bad/
!ll&&!rl&&r
004
MC/DC0%0/2
$@ and $@ =~ /Bad/
$@ $@ =~ /Bad/
Truth table33%1/3
A and B
A= $@B= $@ =~ /Bad/
ABresult
0X0
100
111
58 unless $@ && $@ =~ /Bad/;
59 4 &ok;
60 }
61  
62 ## tests 10 - 17 bcd2bin
63  
64 1 foreach(
65 '1234/',
66 '1234:',
67 'a1234',
68 '&1234',
69 ) {
70 4 my $rv;
71 4 eval { $rv = bcd2bin($_) };
72 4 ▶ if (defined $rv) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $rv) 0 4 4
73 0 $rv = unpack("H40",$rv);
74 0 print "got: $rv, exp: 'die'\nnot ";
75 }
76 4 &ok;
77  
78 4 ▶ print "expected a die from bad character input\nnot "
Branch: 1 branch
BranchTrueFalseTotal
unless $@ and $@ =~ /Bad/ 0 4 4
Condition33%1/3
$@ and $@ =~ /Bad/
!ll&&!rl&&r
004
MC/DC0%0/2
$@ and $@ =~ /Bad/
$@ $@ =~ /Bad/
Truth table33%1/3
A and B
A= $@B= $@ =~ /Bad/
ABresult
0X0
100
111
79 unless $@ && $@ =~ /Bad/;
80 4 &ok;
81 }
82  
83 ## test 18 bcdn2bin
84 1 eval { bcdn2bin('123456789012345678901') };
85 1 ▶print "expected a die from bad vector string length\nnot "
Branch: 1 branch
BranchTrueFalseTotal
unless $@ and $@ =~ /Bad/ 0 1 1
Condition33%1/3
$@ and $@ =~ /Bad/
!ll&&!rl&&r
001
MC/DC0%0/2
$@ and $@ =~ /Bad/
$@ $@ =~ /Bad/
Truth table33%1/3
A and B
A= $@B= $@ =~ /Bad/
ABresult
0X0
100
111
86 unless $@ && $@ =~ /Bad/;
87 1 &ok;
88  
89 ## test 19 bcdn2bin
90 1 eval { bcdn2bin('12345678901234567890') };
91 1 ▶print "expected a die from missing length specifier\nnot "
Branch: 1 branch
BranchTrueFalseTotal
unless $@ and $@ =~ /Bad/ 0 1 1
Condition33%1/3
$@ and $@ =~ /Bad/
!ll&&!rl&&r
001
MC/DC0%0/2
$@ and $@ =~ /Bad/
$@ $@ =~ /Bad/
Truth table33%1/3
A and B
A= $@B= $@ =~ /Bad/
ABresult
0X0
100
111
92 unless $@ && $@ =~ /Bad/;
93 1 &ok;
94  
95 ## test 20 bin2bcd
96 1 eval { bin2bcd('123') };
97 1 ▶print "expected a die from bad vector string length\nnot "
Branch: 1 branch
BranchTrueFalseTotal
unless $@ and $@ =~ /Bad/ 0 1 1
Condition33%1/3
$@ and $@ =~ /Bad/
!ll&&!rl&&r
001
MC/DC0%0/2
$@ and $@ =~ /Bad/
$@ $@ =~ /Bad/
Truth table33%1/3
A and B
A= $@B= $@ =~ /Bad/
ABresult
0X0
100
111
98 unless $@ && $@ =~ /Bad/;
99 1 &ok;
100  
101 ## test 21 bin2bcdn
102 1 eval { bin2bcdn('123') };
103 1 ▶print "expected a die from bad vector string length\nnot "
Branch: 1 branch
BranchTrueFalseTotal
unless $@ and $@ =~ /Bad/ 0 1 1
Condition33%1/3
$@ and $@ =~ /Bad/
!ll&&!rl&&r
001
MC/DC0%0/2
$@ and $@ =~ /Bad/
$@ $@ =~ /Bad/
Truth table33%1/3
A and B
A= $@B= $@ =~ /Bad/
ABresult
0X0
100
111
104 unless $@ && $@ =~ /Bad/;
105 1 &ok;
106  
107 ## test 22 bcdn2txt
108 1 eval { bcdn2txt('123456789012345678901') };
109 1 ▶print "expected a die from bad vector string length\nnot "
Branch: 1 branch
BranchTrueFalseTotal
unless $@ and $@ =~ /Bad/ 0 1 1
Condition33%1/3
$@ and $@ =~ /Bad/
!ll&&!rl&&r
001
MC/DC0%0/2
$@ and $@ =~ /Bad/
$@ $@ =~ /Bad/
Truth table33%1/3
A and B
A= $@B= $@ =~ /Bad/
ABresult
0X0
100
111
110 unless $@ && $@ =~ /Bad/;
111 1 &ok;
112  
113 ## test 23 bcdn2txt
114 1 my $rv;
115 1 my $exp = '3132333435363738393031323334353637383930';
116 1 $rv = bcdn2txt('12345678901234567890');
117 1 ▶print "got: $rv\nexp: $exp\nnot "
Branch: 1 branch
BranchTrueFalseTotal
unless $rv eq $exp 0 1 1
118 unless $rv eq $exp;
119 1 &ok;
120  
121 ## test 24 hasbits
122 1 eval { hasbits('123') };
123 1 ▶print "expected a die from bad vector string length\nnot "
Branch: 1 branch
BranchTrueFalseTotal
unless $@ and $@ =~ /Bad/ 0 1 1
Condition33%1/3
$@ and $@ =~ /Bad/
!ll&&!rl&&r
001
MC/DC0%0/2
$@ and $@ =~ /Bad/
$@ $@ =~ /Bad/
Truth table33%1/3
A and B
A= $@B= $@ =~ /Bad/
ABresult
0X0
100
111
124 unless $@ && $@ =~ /Bad/;
125 1 &ok;
126  
127 ## test 25 isIPv4
128 1 eval { isIPv4('12345678901234567') };
129 1 ▶print "expected a die from bad vector string length\nnot "
Branch: 1 branch
BranchTrueFalseTotal
unless $@ and $@ =~ /Bad/ 0 1 1
Condition33%1/3
$@ and $@ =~ /Bad/
!ll&&!rl&&r
001
MC/DC0%0/2
$@ and $@ =~ /Bad/
$@ $@ =~ /Bad/
Truth table33%1/3
A and B
A= $@B= $@ =~ /Bad/
ABresult
0X0
100
111
130 unless $@ && $@ =~ /Bad/;
131 1 &ok;
132  
133 ## test 26 add128
134 1 eval { add128('123','1234567890123456') };
135 1 ▶print "expected a die from bad vector string length\nnot "
Branch: 1 branch
BranchTrueFalseTotal
unless $@ and $@ =~ /Bad/ 0 1 1
Condition33%1/3
$@ and $@ =~ /Bad/
!ll&&!rl&&r
001
MC/DC0%0/2
$@ and $@ =~ /Bad/
$@ $@ =~ /Bad/
Truth table33%1/3
A and B
A= $@B= $@ =~ /Bad/
ABresult
0X0
100
111
136 unless $@ && $@ =~ /Bad/;
137 1 &ok;
138  
139 ## test 27 sub128
140 1 eval { sub128('1234567890123456','12345678901234567') };
141 1 ▶print "expected a die from bad vector string length\nnot "
Branch: 1 branch
BranchTrueFalseTotal
unless $@ and $@ =~ /Bad/ 0 1 1
Condition33%1/3
$@ and $@ =~ /Bad/
!ll&&!rl&&r
001
MC/DC0%0/2
$@ and $@ =~ /Bad/
$@ $@ =~ /Bad/
Truth table33%1/3
A and B
A= $@B= $@ =~ /Bad/
ABresult
0X0
100
111
142 unless $@ && $@ =~ /Bad/;
143 1 &ok;
144  
145 ## test 28 comp128
146 1 eval { comp128('123') };
147 1 ▶print "expected a die from bad vector string length\nnot "
Branch: 1 branch
BranchTrueFalseTotal
unless $@ and $@ =~ /Bad/ 0 1 1
Condition33%1/3
$@ and $@ =~ /Bad/
!ll&&!rl&&r
001
MC/DC0%0/2
$@ and $@ =~ /Bad/
$@ $@ =~ /Bad/
Truth table33%1/3
A and B
A= $@B= $@ =~ /Bad/
ABresult
0X0
100
111
148 unless $@ && $@ =~ /Bad/;
149 1 &ok;
150  
151 ## test 29 shiftleft
152 1 eval { shiftleft ('12345678901234567') };
153 1 ▶print "expected a die from bad vector string length\nnot "
Branch: 1 branch
BranchTrueFalseTotal
unless $@ and $@ =~ /Bad/ 0 1 1
Condition33%1/3
$@ and $@ =~ /Bad/
!ll&&!rl&&r
001
MC/DC0%0/2
$@ and $@ =~ /Bad/
$@ $@ =~ /Bad/
Truth table33%1/3
A and B
A= $@B= $@ =~ /Bad/
ABresult
0X0
100
111
154 unless $@ && $@ =~ /Bad/;
155 1 &ok;
156  
157 ## test 30 shiftleft
158 1 eval { shiftleft ('1234567890123456',-1) };
159 1 ▶print "expected a die from bad shift count specifier\nnot "
Branch: 1 branch
BranchTrueFalseTotal
unless $@ and $@ =~ /Bad/ 0 1 1
Condition33%1/3
$@ and $@ =~ /Bad/
!ll&&!rl&&r
001
MC/DC0%0/2
$@ and $@ =~ /Bad/
$@ $@ =~ /Bad/
Truth table33%1/3
A and B
A= $@B= $@ =~ /Bad/
ABresult
0X0
100
111
160 unless $@ && $@ =~ /Bad/;
161 1 &ok;
162  
163 ## test 31 shiftleft
164 1 eval { shiftleft ('1234567890123456',129) };
165 1 ▶print "expected a die from bad shift count specifier\nnot "
Branch: 1 branch
BranchTrueFalseTotal
unless $@ and $@ =~ /Bad/ 0 1 1
Condition33%1/3
$@ and $@ =~ /Bad/
!ll&&!rl&&r
001
MC/DC0%0/2
$@ and $@ =~ /Bad/
$@ $@ =~ /Bad/
Truth table33%1/3
A and B
A= $@B= $@ =~ /Bad/
ABresult
0X0
100
111
166 unless $@ && $@ =~ /Bad/;
167 1 &ok;
168  
« Lite/Util/t/mode.t ↑ Summary Lite/Util/t/no6_naip_gethostbyname.t »