Commit | Line | Data |
f72b2dfb |
1 | ## |
2 | # DBM::Deep Test |
3 | ## |
4 | use strict; |
5 | use Test::More tests => 8; |
6 | |
7 | use t::common qw( new_fh ); |
8 | |
9 | use_ok( 'DBM::Deep' ); |
10 | |
11 | my %sizes; |
12 | |
13 | { |
14 | my ($fh, $filename) = new_fh(); |
15 | { |
16 | my $db = DBM::Deep->new( |
17 | file => $filename, |
18 | data_sector_size => 32, |
19 | ); |
20 | |
21 | do_stuff( $db ); |
22 | } |
23 | |
24 | $sizes{32} = -s $filename; |
25 | |
26 | { |
27 | my $db = DBM::Deep->new( $filename ); |
28 | verify( $db ); |
29 | } |
30 | } |
31 | |
32 | { |
33 | my ($fh, $filename) = new_fh(); |
34 | { |
35 | my $db = DBM::Deep->new( |
36 | file => $filename, |
37 | data_sector_size => 64, |
38 | ); |
39 | |
40 | do_stuff( $db ); |
41 | } |
42 | |
43 | $sizes{64} = -s $filename; |
44 | |
45 | { |
46 | my $db = DBM::Deep->new( $filename ); |
47 | verify( $db ); |
48 | } |
49 | } |
50 | |
51 | { |
52 | my ($fh, $filename) = new_fh(); |
53 | { |
54 | my $db = DBM::Deep->new( |
55 | file => $filename, |
56 | data_sector_size => 128, |
57 | ); |
58 | |
59 | do_stuff( $db ); |
60 | } |
61 | |
62 | $sizes{128} = -s $filename; |
63 | |
64 | { |
65 | my $db = DBM::Deep->new( $filename ); |
66 | verify( $db ); |
67 | } |
68 | } |
69 | |
70 | { |
71 | my ($fh, $filename) = new_fh(); |
72 | { |
73 | my $db = DBM::Deep->new( |
74 | file => $filename, |
75 | data_sector_size => 256, |
76 | ); |
77 | |
78 | do_stuff( $db ); |
79 | } |
80 | |
81 | $sizes{256} = -s $filename; |
82 | |
83 | { |
84 | my $db = DBM::Deep->new( $filename ); |
85 | verify( $db ); |
86 | } |
87 | } |
88 | |
89 | cmp_ok( $sizes{256}, '>', $sizes{128}, "Filesize for 256 > filesize for 128" ); |
90 | cmp_ok( $sizes{128}, '>', $sizes{64}, "Filesize for 128 > filesize for 64" ); |
91 | cmp_ok( $sizes{64}, '>', $sizes{32}, "Filesize for 64 > filesize for 32" ); |
92 | |
93 | sub do_stuff { |
94 | my ($db) = @_; |
95 | |
96 | $db->{foo}{bar} = [ 1 .. 3 ]; |
97 | } |
98 | |
99 | sub verify { |
100 | my ($db) = @_; |
101 | |
102 | cmp_ok( $db->{foo}{bar}[2], '==', 3, "Correct value found" ); |
103 | } |