Compress/Adapter/Zstd.pm

filter: Statementstmt 70.1% 47 / 67 Branchbran 37.5% 3 / 8 Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 76.9% 10 / 13 Podpod 0.0% 0 / 7 totaltotal 61.0% 61 / 100 CC 6 SCAR 8.4
CC
6
Cov
65%
reset
6.0
compr
3.4
flush
2.1
CRAP 2.3
↑ Summary Uncompress/Adapter/UnZstd.pm »
1 package IO::Compress::Adapter::Zstd ;
2  
3 11 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 11 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 11 ▶use bytes;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 11 ▶use IO::Compress::Base::Common 2.217 qw(:Status);
Subroutine BEGIN: called CC=1 SCAR=0.0
8 11 ▶use Compress::Stream::Zstd qw(ZSTD_MAX_CLEVEL);
Subroutine BEGIN: called CC=1 SCAR=0.0
9 11 ▶use Compress::Stream::Zstd::Compressor qw(ZSTD_CSTREAM_IN_SIZE);
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 11 our ($VERSION);
12 11 $VERSION = '2.217';
13  
14 sub mkCompObject
15 {
16 225 ▶ my $level = shift ;
Subroutine mkCompObject: called CC=1 SCAR=0.0
Pod undocumented
17  
18 # TODO - parameterise level
19 225 my $compressor = Compress::Stream::Zstd::Compressor->new($level);
20  
21 225 return bless {
22 'Def' => $compressor,
23 'Buffer' => '',
24 'Error' => '',
25 'ErrorNo' => 0,
26 'CompBytes' => 0,
27 'UnCompBytes'=> 0,
28 } ;
29 }
30  
31 sub compr
32 {
33 231 ▶ my $self = shift ;
Subroutine compr: called CC=3 SCAR=12.2
Pod undocumented
34 231 my $buffer = shift ;
35  
36 231 my $def = $self->{Def};
37  
38 231 eval { $_[0] .= $def->compress($$buffer) ; };
39  
40 231 ▶ if ($@ || $def->isError())
Branch: 1 branch
BranchTrueFalseTotal
if ($@ or $def->isError) 0 231 231
Condition33%1/3
$@ or $def->isError
l!l&&r!l&&!r
00231
MC/DC0%0/2
$@ or $def->isError
$@ $def->isError
Truth table33%1/3
A or B
A= $@B= $def->isError
ABresult
1X1
011
000
41 {
42 0 $self->{Error} = $def->getErrorName();
43 0 $self->{ErrorNo} = $def->status() ;
44 0 return STATUS_ERROR ;
45 }
46  
47 231 $self->{Error} = '';
48 231 $self->{ErrorNo} = 0;
49  
50 231 return STATUS_OK;
51 }
52  
53 sub flush
54 {
55 4 ▶ my $self = shift ;
Subroutine flush: called CC=2 SCAR=7.3
Pod undocumented
56  
57 4 my $def = $self->{Def};
58  
59 4 eval { $_[0] .= $def->flush() } ;
60  
61 4 ▶ if ($@)
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 4 4
62 {
63 0 $self->{ErrorNo} = $def->status() ;
64 0 return STATUS_ERROR ;
65 }
66  
67 4 $self->{ErrorNo} = 0;
68  
69 4 return STATUS_OK;
70 }
71  
72 sub close
73 {
74 224 ▶ my $self = shift ;
Subroutine close: called CC=2 SCAR=7.3
Pod undocumented
75  
76 224 my $def = $self->{Def};
77  
78 224 eval { $_[0] .= $def->end() } ;
79  
80 224 ▶ if ($@)
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 224 224
81 {
82 0 $self->{ErrorNo} = $def->status() ;
83 0 return STATUS_ERROR ;
84 }
85 224 $self->{ErrorNo} = 0;
86  
87 224 return STATUS_OK;
88 }
89  
90  
91  
92 sub reset
93 {
94 0 ▶ my $self = shift ;
Subroutine reset: not called CC=2 SCAR=17.9
Pod undocumented
95  
96 0 my $def = $self->{Def};
97  
98 0 eval { $_[0] = $def->init() } ;
99  
100 0 ▶ if ($@)
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 0 0
101 {
102 0 $self->{ErrorNo} = $def->status() ;
103 0 return STATUS_ERROR ;
104 }
105  
106 0 $self->{ErrorNo} = 0;
107  
108 0 return STATUS_OK;
109 }
110  
111 sub compressedBytes
112 {
113 0 ▶ my $self = shift ;
Subroutine compressedBytes: not called CC=1 SCAR=6.9
Pod undocumented
114 0 $self->{CompBytes};
115 }
116  
117 sub uncompressedBytes
118 {
119 0 ▶ my $self = shift ;
Subroutine uncompressedBytes: not called CC=1 SCAR=6.9
Pod undocumented
120 0 $self->{UnCompBytes};
121 }
122  
123 11 1;
124  
125 __END__
↑ Summary Uncompress/Adapter/UnZstd.pm »