New testing feature that allows specification of the workdir for the tests
[dbsrgits/DBM-Deep.git] / t / 13_setpack.t
1 ##
2 # DBM::Deep Test
3 ##
4 use strict;
5 use Test::More tests => 2;
6 use t::common qw( new_fh );
7
8 use_ok( 'DBM::Deep' );
9
10 my ($before, $after);
11
12 {
13     my ($fh, $filename) = new_fh();
14     my $db = DBM::Deep->new(
15         file => $filename,
16         autoflush => 1
17     );
18     $db->{key1} = "value1";
19     $db->{key2} = "value2";
20     $before = (stat($db->_fh()))[7];
21 }
22
23 {
24     my ($fh, $filename) = new_fh();
25     my $db = DBM::Deep->new(
26         file => $filename,
27         autoflush => 1
28     );
29
30     ##
31     # set pack to 2-byte (16-bit) words
32     ##
33     $db->_get_self->{engine}->set_pack( 2, 'S' );
34
35     $db->{key1} = "value1";
36     $db->{key2} = "value2";
37     $after = (stat($db->_fh()))[7];
38 }
39
40 ok( $after < $before, "The new packsize reduced the size of the file" );