File Coverage

blib/lib/XAO/testcases/FS/blobs.pm
Criterion Covered Total %
statement 18 38 47.3
branch n/a
condition n/a
subroutine 6 7 85.7
pod 0 1 0.0
total 24 46 52.1


line stmt bran cond sub pod time code
1             package XAO::testcases::FS::blobs;
2 1     1   651 use strict;
  1         2  
  1         28  
3 1     1   462 use XAO::Utils;
  1         18327  
  1         64  
4 1     1   477 use XAO::Objects;
  1         5833  
  1         31  
5 1     1   9 use Error qw(:try);
  1         3  
  1         6  
6              
7 1     1   143 use base qw(XAO::testcases::FS::base);
  1         2  
  1         485  
8              
9             ###############################################################################
10              
11             sub test_charsets {
12 0     0 0   my $self=shift;
13              
14 0           my $odb=$self->get_odb();
15              
16 0           my $list=$odb->fetch('/Customers');
17 0           $self->assert(ref($list), "Failure getting c1 reference");
18              
19 1     1   9 use bytes;
  1         14  
  1         7  
20 0           for(my $len=3; $len<=999999; $len*=10) {
21             ### dprint "Testing blobs, length=$len";
22 0           my $obj=$list->get_new;
23              
24 0           $obj->add_placeholder(
25             name => 'blob',
26             type => 'blob',
27             maxlength => $len,
28             );
29              
30 0           my %expect;
31 0           for(my $t=1; $t<5; ++$t) {
32 0           my $data='';
33 0           for(my $i=0; $i<$len; ++$i) {
34 0           $data.=chr(int(rand(256)));
35             }
36 0           $self->assert(length($data)==$len,
37             "Data block we built for len=$len is actually ".length($data)." long");
38 0           $obj->put(blob => $data);
39 0           my $id=$list->put($obj);
40 0           $expect{$id}=$data;
41             }
42              
43 0           foreach my $id (keys %expect) {
44 0           my $got=$list->get($id)->get('blob');
45 0           $self->assert($got eq $expect{$id},
46             "Got wrong blob content for id=$id, len=$len");
47             }
48              
49 0           $obj->drop_placeholder('blob');
50             }
51             }
52              
53             ###############################################################################
54             1;