Lite/Util/t/bcd2bin.t

filter: Statementstmt 100% 21 / 21 Branchbran 66.6% 4 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 5 / 5 Podpod n/a totaltotal 93.7% 30 / 32 CC 2 SCAR 3.2
CC
2
Cov
93%
END
2.1
BEGIN
1.0
BEGIN
1.0
CRAP 1.4
« Lite/t/bug75976.t ↑ Summary Lite/Util/t/bpackzeros.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..25\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 ipv6_n2x
14 1 );
15  
16 1 $loaded = 1;
17 1 print "ok 1\n";
18 ######################### End of black magic.
19  
20 # Insert your test code below (better if it prints "ok 13"
21 # (correspondingly "not ok 13") depending on the success of chunk 13
22 # of the test code):
23  
24 1 $test = 2;
25  
26 24 ▶sub ok {
Subroutine ok: called CC=1 SCAR=0.0
27 24 print "ok $test\n";
28 24 ++$test;
29 }
30  
31 1 my @num = # input expected
32 qw(
33 0 0:0:0:0:0:0:0:0
34 2147483648 0:0:0:0:0:0:8000:0
35 4294967296 0:0:0:0:0:1:0:0
36 8589934592 0:0:0:0:0:2:0:0
37 10000000000 0:0:0:0:0:2:540B:E400
38 17179869184 0:0:0:0:0:4:0:0
39 34359738368 0:0:0:0:0:8:0:0
40 68719476736 0:0:0:0:0:10:0:0
41 137438953472 0:0:0:0:0:20:0:0
42 274877906944 0:0:0:0:0:40:0:0
43 549755813888 0:0:0:0:0:80:0:0
44 1099511627776 0:0:0:0:0:100:0:0
45 2199023255552 0:0:0:0:0:200:0:0
46 4398046511104 0:0:0:0:0:400:0:0
47 8796093022208 0:0:0:0:0:800:0:0
48 17592186044416 0:0:0:0:0:1000:0:0
49 35184372088832 0:0:0:0:0:2000:0:0
50 70368744177664 0:0:0:0:0:4000:0:0
51 140737488355328 0:0:0:0:0:8000:0:0
52 9223372036854775808 0:0:0:0:8000:0:0:0
53 604462909807314587353088 0:0:0:8000:0:0:0:0
54 39614081257132168796771975168 0:0:8000:0:0:0:0:0
55 2596148429267413814265248164610048 0:8000:0:0:0:0:0:0
56 170141183460469231731687303715884105728 8000:0:0:0:0:0:0:0
57 );
58  
59 ## tests 2 - 9 check pack correct
60  
61 1 ▶for (my $i=0;$i<@num;$i+=2) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < @num) 24 1 25
62 24 print $num[$i],"\n";
63 24 my $bits = bcd2bin($num[$i]);
64 24 my $ip = ipv6_n2x($bits);
65 24 ▶ print "got: $ip\nexp: $num[$i +1]\nnot "
Branch: 1 branch
BranchTrueFalseTotal
unless $ip eq $num[$i + 1] 0 24 24
66 unless $ip eq $num[$i +1];
67 24 &ok;
68 }
« Lite/t/bug75976.t ↑ Summary Lite/Util/t/bpackzeros.t »