lib/Parse/Win32Registry/Value.pm

filter: Statementstmt 95.9% 47 / 49 Branchbran 100% 14 / 14 Conditioncond 83.3% 5 / 6 MC/DCmcdc 75.0% 3 / 4 Subroutinesub 91.6% 11 / 12 Podpod 0.0% 0 / 7 totaltotal 86.9% 80 / 92 CC 10 SCAR 13.6
CC
10
Cov
96%
get_data_as_string
8.0
get_type_as_string
2.0
as_string
2.0
CRAP 3.9
« lib/Parse/Win32Registry/Win95/File.pm ↑ Summary lib/Parse/Win32Registry.pm »
1 package Parse::Win32Registry::Value;
2  
3 13 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 13 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 13 ▶use base qw(Parse::Win32Registry::Entry);
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 13 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 13 ▶use Parse::Win32Registry::Base qw(:all);
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 482 ▶sub get_name {
Subroutine get_name: called CC=1 SCAR=0.0
Pod undocumented
12 482 my $self = shift;
13  
14 482 return $self->{_name};
15 }
16  
17 1126 ▶sub get_type {
Subroutine get_type: called CC=1 SCAR=0.0
Pod undocumented
18 1126 my $self = shift;
19  
20 1126 return $self->{_type};
21 }
22  
23 13 our @Types = qw(
24 REG_NONE
25 REG_SZ
26 REG_EXPAND_SZ
27 REG_BINARY
28 REG_DWORD
29 REG_DWORD_BIG_ENDIAN
30 REG_LINK
31 REG_MULTI_SZ
32 REG_RESOURCE_LIST
33 REG_FULL_RESOURCE_DESCRIPTOR
34 REG_RESOURCE_REQUIREMENTS_LIST
35 REG_QWORD
36 );
37  
38 202 ▶sub get_type_as_string {
Subroutine get_type_as_string: called CC=2 SCAR=6.9
Pod undocumented
39 202 my $self = shift;
40  
41 202 my $type = $self->get_type;
42 202 ▶ if (exists $Types[$type]) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $Parse::Win32Registry::Value::Types[$type]) { } 196 6 202
43 196 return $Types[$type];
44 }
45 else {
46 # Return unrecognised types as REG_<number>
47 # REGEDIT displays them as formatted hex numbers, e.g. 0x1f4
48 6 return "REG_$type";
49 }
50 }
51  
52 202 ▶sub get_data_as_string {
Subroutine get_data_as_string: called CC=8 SCAR=20.8
Pod undocumented
53 202 my $self = shift;
54  
55 202 my $type = $self->get_type;
56 202 my $data = $self->get_data;
57 202 ▶ if (!defined($data)) {
Branch: 5 branches
BranchTrueFalseTotal
if (not defined $data) { } 36 166 202
elsif (length $data == 0) { } 30 136 166
elsif ($type == 1 or $type == 2) { } 14 122 136
elsif ($type == 7) { } 38 84 122
elsif ($type == 4 or $type == 5) { } 70 14 84
58 36 return '(invalid data)';
59 }
60 elsif (length($data) == 0) {
61 30 return '(no data)';
62 }
63 ▶ elsif ($type == REG_SZ || $type == REG_EXPAND_SZ) {
Condition66%2/3
$type == 1 or $type == 2
l!l&&r!l&&!r
140122
MC/DC50%1/2
$type == 1 or $type == 2
$type == 1 $type == 2
Truth table66%2/3
A or B
A= $type == 1B= $type == 2
ABresult
1X1
011
000
64 14 return $data;
65 }
66 elsif ($type == REG_MULTI_SZ) {
67 38 my @data = $self->get_data;
68 38 my $i = 0;
69 38 return join(' ', map { "[" . $i++ . "] $_" } @data);
70 }
71 ▶ elsif ($type == REG_DWORD || $type == REG_DWORD_BIG_ENDIAN) {
Condition100%3/3
$type == 4 or $type == 5
l!l&&r!l&&!r
482214
MC/DC100%2/2
$type == 4 or $type == 5
$type == 4 $type == 5
Truth table100%3/3
A or B
A= $type == 4B= $type == 5
ABresult
1X1
011
000
72 70 return sprintf '0x%08x (%u)', $data, $data;
73 }
74 else {
75 14 return join(' ', unpack('(H2)*', $data));
76 }
77 }
78  
79 92 ▶sub get_raw_data {
Subroutine get_raw_data: called CC=1 SCAR=0.0
Pod undocumented
80 92 my $self = shift;
81  
82 92 return $self->{_data};
83 }
84  
85 110 ▶sub as_string {
Subroutine as_string: called CC=2 SCAR=6.9
Pod undocumented
86 110 my $self = shift;
87  
88 110 my $name = $self->get_name;
89 110 ▶ $name = '(Default)' if $name eq '';
Branch: 1 branch
BranchTrueFalseTotal
if $name eq "" 2 108 110
90 110 my $type_as_string = $self->get_type_as_string;
91 110 my $data_as_string = $self->get_data_as_string;
92 110 return "$name ($type_as_string) = $data_as_string";
93 }
94  
95 0 ▶sub print_summary {
Subroutine print_summary: not called CC=1 SCAR=6.9
Pod undocumented
96 0 my $self = shift;
97  
98 0 print $self->as_string, "\n";
99 }
100  
101 13 1;
« lib/Parse/Win32Registry/Win95/File.pm ↑ Summary lib/Parse/Win32Registry.pm »