Commit | Line | Data |
ffed8b01 |
1 | ## |
2 | # DBM::Deep Test |
3 | ## |
4 | use strict; |
9a63e1f2 |
5 | use Config; |
6 | use Test::More tests => 10; |
fde3db1a |
7 | use t::common qw( new_fh ); |
ffed8b01 |
8 | |
9 | use_ok( 'DBM::Deep' ); |
10 | |
9a63e1f2 |
11 | my ($default, $small, $medium, $large); |
ffed8b01 |
12 | |
251dfd0e |
13 | { |
fde3db1a |
14 | my ($fh, $filename) = new_fh(); |
251dfd0e |
15 | my $db = DBM::Deep->new( |
2a81bf9e |
16 | file => $filename, |
e0098e7f |
17 | autoflush => 1, |
251dfd0e |
18 | ); |
19 | $db->{key1} = "value1"; |
20 | $db->{key2} = "value2"; |
9a63e1f2 |
21 | $default = (stat($db->_fh()))[7]; |
22 | } |
23 | |
24 | { |
25 | my ($fh, $filename) = new_fh(); |
26 | { |
27 | my $db = DBM::Deep->new( |
28 | file => $filename, |
29 | autoflush => 1, |
30 | pack_size => 'medium', |
31 | ); |
32 | |
33 | $db->{key1} = "value1"; |
34 | $db->{key2} = "value2"; |
35 | $medium = (stat($db->_fh()))[7]; |
36 | } |
37 | |
38 | # This tests the header to verify that the pack_size is really there |
39 | { |
40 | my $db = DBM::Deep->new( |
41 | file => $filename, |
42 | ); |
43 | |
44 | is( $db->{key1}, 'value1', 'Can read key1' ); |
45 | is( $db->{key2}, 'value2', 'Can read key2' ); |
46 | } |
47 | |
48 | cmp_ok( $medium, '==', $default, "The default is medium" ); |
251dfd0e |
49 | } |
50 | |
51 | { |
fde3db1a |
52 | my ($fh, $filename) = new_fh(); |
9b2370e0 |
53 | { |
54 | my $db = DBM::Deep->new( |
55 | file => $filename, |
56 | autoflush => 1, |
57 | pack_size => 'small', |
58 | ); |
251dfd0e |
59 | |
9b2370e0 |
60 | $db->{key1} = "value1"; |
61 | $db->{key2} = "value2"; |
9a63e1f2 |
62 | $small = (stat($db->_fh()))[7]; |
9b2370e0 |
63 | } |
64 | |
65 | # This tests the header to verify that the pack_size is really there |
66 | { |
67 | my $db = DBM::Deep->new( |
68 | file => $filename, |
69 | ); |
70 | |
71 | is( $db->{key1}, 'value1', 'Can read key1' ); |
72 | is( $db->{key2}, 'value2', 'Can read key2' ); |
73 | } |
9a63e1f2 |
74 | |
75 | cmp_ok( $medium, '>', $small, "medium is greater than small" ); |
251dfd0e |
76 | } |
ffed8b01 |
77 | |
9a63e1f2 |
78 | SKIP: { |
79 | skip "Largefile support is not compiled into $^X", 3 |
80 | if 1; #unless $Config{ uselargefile }; |
81 | |
82 | my ($fh, $filename) = new_fh(); |
83 | { |
84 | my $db = DBM::Deep->new( |
85 | file => $filename, |
86 | autoflush => 1, |
87 | pack_size => 'large', |
88 | ); |
89 | |
90 | $db->{key1} = "value1"; |
91 | $db->{key2} = "value2"; |
92 | $large = (stat($db->_fh()))[7]; |
93 | } |
94 | |
95 | # This tests the header to verify that the pack_size is really there |
96 | { |
97 | my $db = DBM::Deep->new( |
98 | file => $filename, |
99 | ); |
100 | |
101 | is( $db->{key1}, 'value1', 'Can read key1' ); |
102 | is( $db->{key2}, 'value2', 'Can read key2' ); |
103 | } |
104 | cmp_ok( $medium, '<', $large, "medium is smaller than large" ); |
105 | } |