Voodoo/Validate/signed_int.pm

filter: Statementstmt 35.4% 11 / 31 Branchbran 0.0% 0 / 16 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 60.0% 3 / 5 Podpod 0.0% 0 / 2 totaltotal 23.7% 14 / 59 CC 10 SCAR 35.2
CC
10
Cov
22%
config
56.0
valid
20.0
BEGIN
1.0
CRAP 33.9
« Voodoo/View/HTML.pm ↑ Summary Voodoo/Install/Distribution.pm »
1 package Apache::Voodoo::Validate::signed_int;
2  
3 1 $VERSION = "3.0200";
4  
5 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 1 ▶use base("Apache::Voodoo::Validate::Plugin");
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 0 ▶sub config {
Subroutine config: not called CC=7 SCAR=40.3
Pod undocumented
11 0 my ($self,$c) = @_;
12 0 my @e;
13 0 ▶ if (defined($c->{bytes})) {
Branch: 2 branches
BranchTrueFalseTotal
if (defined $c->{'bytes'}) { } 0 0 0
elsif (defined $c->{'max'} and defined $c->{'min'}) { } 0 0 0
14 0 ▶ if ($c->{bytes} =~ /^\d+$/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($c->{'bytes'} =~ /^\d+$/) { } 0 0 0
15 0 $self->{'max'} = ( 2 ** ($c->{bytes} * 8))/2;
16 0 $self->{'min'} = (0 - (2 ** ($c->{bytes} * 8))/2 - 1);
17 }
18 else {
19 0 push(@e,"'bytes' must be a positive integer");
20 }
21 }
22 ▶ elsif (defined($c->{max}) && defined($c->{min})) {
Condition0%0/3
defined $c->{"max"} and defined $c->{"min"}
!ll&&!rl&&r
000
MC/DC0%0/2
defined $c->{"max"} and defined $c->{"min"}
defined $c->{"max"} defined $c->{"min"}
Truth table0%0/3
A and B
A= defined $c->{"max"}B= defined $c->{"min"}
ABresult
0X0
100
111
23 0 ▶ if ($c->{max} =~ /^\d+$/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($c->{'max'} =~ /^\d+$/) { } 0 0 0
24 0 $self->{max} = $c->{max};
25 }
26 else {
27 0 push(@e,"'max' must be zero or a positive integer");
28 }
29  
30 0 ▶ if ($c->{min} =~ /^(0+|-\d+)$/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($c->{'min'} =~ /^(0+|-\d+)$/) { } 0 0 0
31 0 $self->{min} = $c->{min};
32 }
33 else {
34 0 push(@e,"'min' must be zero or a negative integer");
35 }
36 }
37 else {
38 0 push(@e,"either 'max' and 'min' or 'bytes' is a required parameter");
39 }
40  
41 0 return @e;
42 }
43  
44 0 ▶sub valid {
Subroutine valid: not called CC=4 SCAR=30.0
Pod undocumented
45 0 my ($self,$v) = @_;
46  
47 0 ▶ return undef,'BAD' unless ($v =~ /^(\+|-)?\d*$/);
Branch: 1 branch
BranchTrueFalseTotal
unless $v =~ /^(\+|-)?\d*$/ 0 0 0
48 0 ▶ return undef,'MAX' unless ($v <= $self->{'max'});
Branch: 1 branch
BranchTrueFalseTotal
unless $v <= $self->{"max"} 0 0 0
49 0 ▶ return undef,'MIN' unless ($v >= $self->{'min'});
Branch: 1 branch
BranchTrueFalseTotal
unless $v >= $self->{"min"} 0 0 0
50  
51 0 return $v;
52 }
53  
54 1 1;
55  
56 ################################################################################
57 # Copyright (c) 2005-2010 Steven Edwards (maverick@smurfbane.org).
58 # All rights reserved.
59 #
60 # You may use and distribute Apache::Voodoo under the terms described in the
61 # LICENSE file include in this package. The summary is it's a legalese version
62 # of the Artistic License :)
63 #
64 ################################################################################
« Voodoo/View/HTML.pm ↑ Summary Voodoo/Install/Distribution.pm »