blib/lib/Test/Structures/Data.pm

filter: Statementstmt 100% 33 / 33 Branchbran 100% 2 / 2 Conditioncond 50.0% 1 / 2 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 100% 8 / 8 Podpod 100% 1 / 1 totaltotal 93.7% 45 / 48 CC 4 SCAR 7.4
CC
4
Cov
97%
is_value_found_in_hash_values
4.0
BEGIN
1.0
BEGIN
1.0
CRAP 2.1
↑ Summary
1 #############
2 # Created By: setitesuk
3 # Created On: 2010-04-20
4  
5 package Test::Structures::Data;
6 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 ▶use English qw{-no_match_vars};
Subroutine BEGIN: called CC=1 SCAR=0.0
10 1 ▶use Readonly; Readonly::Scalar our $VERSION => 0.025;
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 1 ▶use base qw{Exporter};
Subroutine BEGIN: called CC=1 SCAR=0.0
13 1 our @EXPORT = qw{is_value_found_in_hash_values}; ## no critic (Modules::ProhibitAutomaticExportation)
14  
15 1 ▶use Test::Builder;
Subroutine BEGIN: called CC=1 SCAR=0.0
16  
17 1 my $test = Test::Builder->new();
18  
19 =head1 NAME
20  
21 Test::Structures::Data
22  
23 =head1 VERSION
24  
25 $LastChangedRevision$
26  
27 =head1 SYNOPSIS
28  
29 use Test::More tests => 21;
30 use Test::Structures::Data;
31  
32 is_value_found_in_hash_values( $value, $href, $optional_description );
33  
34 =head1 DESCRIPTION
35  
36 This module gives additional tests created by Test::Builder which will test data structures. Currently only one is available,
37 however more are planned.
38  
39 =head1 SUBROUTINES/METHODS
40  
41 =head2 is_value_found_in_hash_values
42  
43 exported by default. This test checks to see if the value you provide is within the values of the hashref also provided as the second arguement.
44  
45 is_value_found_in_hash_values( $value, $href, $optional_description );
46  
47 =cut
48  
49 1 ▶sub is_value_found_in_hash_values {
Subroutine is_value_found_in_hash_values: called CC=4 SCAR=13.9
Pod documented
50 1 my ( $value, $hash, $desc ) = @_;
51  
52 1 my $result;
53  
54 1 foreach my $key ( keys %{ $hash } ) {
55 6 ▶ if ( $value eq $hash->{$key} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($value eq $hash->{$key}) 1 5 6
56 1 $result = 1;
57 1 last;
58 }
59 }
60  
61 1 ▶ return $test->ok( $result, $desc ) || $test->diag( "$value not found in hash $hash" );
Condition50%1/2
$test->ok($result, $desc) || $test->diag("$value not found in hash $hash")
l!l
10
MC/DC0%0/2
$test->ok($result, $desc) || $test->diag("$value not found in hash $hash")
$test->ok($result, $desc) $test->diag("$value not found in hash $hash")
Truth table33%1/3
A || B
A= $test->ok($result, $desc)B= $test->diag("$value not found in hash $hash")
ABresult
1X1
011
000
62 }
63  
64 1 1;
65 __END__
↑ Summary