DBus/Signature.pm

filter: Statementstmt 100% 30 / 30 Branchbran 92.8% 13 / 14 Conditioncond 100% 3 / 3 MC/DCmcdc 100% 2 / 2 Subroutinesub 100% 4 / 4 Podpod 0.0% 0 / 2 totaltotal 94.5% 52 / 55 CC 9 SCAR 17.6
CC
9
Cov
98%
get_sct_length
8.0
split
2.0
BEGIN
1.0
CRAP 5.8
« DBus/Message/Header.pm ↑ Summary DBus/Parser/UnixFDs.pm »
1 package Protocol::DBus::Signature;
2  
3 9 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 9 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 # Returns a list of single complete types (SCTs).
7  
8 231 ▶sub split {
Subroutine split: called CC=2 SCAR=6.9
Pod undocumented
9 231 my ($sig) = @_;
10  
11 231 my @scts;
12  
13 231 ▶ while (length($sig)) {
Branch: 1 branch
BranchTrueFalseTotal
if (length $sig) 296 231 527
14 296 my $next_sct_len = Protocol::DBus::Signature::get_sct_length($sig, 0);
15 296 push @scts, substr( $sig, 0, $next_sct_len, q<> );
16 }
17  
18 231 return @scts;
19 }
20  
21 # Returns the length of the single complete type at $sct_offset.
22  
23 831 ▶sub get_sct_length {
Subroutine get_sct_length: called CC=8 SCAR=20.8
Pod undocumented
24 831 my ($sig, $sct_offset) = @_;
25  
26 831 my $start = $sct_offset;
27  
28 831 my $next = substr($sig, $sct_offset, 1);
29  
30 831 ▶ if ($next eq 'a') {
Branch: 1 branch
BranchTrueFalseTotal
if ($next eq "a") 111 720 831
31  
32 # “{ }” only happens after “a”
33 111 my $next_2nd = substr($sig, 1 + $sct_offset, 1);
34 111 ▶ if ($next_2nd eq '{') {
Branch: 1 branch
BranchTrueFalseTotal
if ($next_2nd eq "{") 43 68 111
35  
36 # 4 for the “a”, “{”, key type, and “}”.
37 # We assume that the signature is well-formed.
38 43 return 4 + get_sct_length($sig, 3 + $sct_offset);
39 }
40  
41 68 return 1 + get_sct_length($sig, 1 + $sct_offset);
42 }
43  
44 720 ▶ if ($next eq '(') {
Branch: 1 branch
BranchTrueFalseTotal
if ($next eq "(") 39 681 720
45 39 while (1) {
46 121 $sct_offset++;
47  
48 121 ▶ last if $sct_offset >= length($sig);
Branch: 1 branch
BranchTrueFalseTotal
if $sct_offset >= length $sig 0 121 121
49  
50 121 my $next_in_struct = substr($sig, $sct_offset, 1);
51  
52 121 ▶ if ($next_in_struct eq '(' || $next_in_struct eq 'a') {
Branch: 2 branches
BranchTrueFalseTotal
if ($next_in_struct eq '(' or $next_in_struct eq 'a') { } 15 106 121
elsif ($next_in_struct eq ')') { } 39 67 106
Condition100%3/3
$next_in_struct eq "(" or $next_in_struct eq "a"
l!l&&r!l&&!r
78106
MC/DC100%2/2
$next_in_struct eq "(" or $next_in_struct eq "a"
$next_in_struct eq "(" $next_in_struct eq "a"
Truth table100%3/3
A or B
A= $next_in_struct eq "("B= $next_in_struct eq "a"
ABresult
1X1
011
000
53 15 $sct_offset += get_sct_length($sig, $sct_offset) - 1;
54 }
55 elsif ($next_in_struct eq ')') {
56 39 last;
57 }
58 }
59 }
60  
61 720 return 1 + ($sct_offset - $start);
62 }
63  
64 9 1;
« DBus/Message/Header.pm ↑ Summary DBus/Parser/UnixFDs.pm »