File Coverage

blib/lib/REFECO/Blockchain/Contract/Solidity/ABI/Type/String.pm
Criterion Covered Total %
statement 24 24 100.0
branch 2 2 100.0
condition n/a
subroutine 6 6 100.0
pod 0 2 0.0
total 32 34 94.1


line stmt bran cond sub pod time code
1              
2             use strict;
3 3     3   1507 use warnings;
  3         23  
  3         94  
4 3     3   16 no indirect;
  3         4  
  3         77  
5 3     3   14  
  3         6  
  3         15  
6             use parent qw(REFECO::Blockchain::Contract::Solidity::ABI::Type);
7 3     3   151  
  3         6  
  3         15  
8             my $self = shift;
9             return $self->encoded if $self->encoded;
10 11     11 0 17  
11 11 100       28 my $hex = unpack("H*", $self->data);
12              
13 4         18 # for dynamic length basic types the length must be included
14             $self->push_dynamic($self->encode_length(length(pack("H*", $hex))));
15             $self->push_dynamic($self->pad_right($hex));
16 4         23  
17 4         18 return $self->encoded;
18             }
19 4         13  
20             my $self = shift;
21             my @data = $self->data->@*;
22              
23 1     1 0 2 my $size = hex shift @data;
24 1         4 my $string_data = join('', @data);
25             my $packed_string = pack("H*", $string_data);
26 1         3 return substr($packed_string, 0, $size);
27 1         3 }
28 1         6  
29 1         6 1;
30