X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F13_setpack.t;h=293806cd5cda6834b3f339910b34513f160361a8;hb=345e7fd079ea47414f8d2601e47689a0dbd16c97;hp=8f6d2cc14904905f71564851969a1cf5e22753c0;hpb=3ad3bcb6eb2fe7fdec1e92bcaa872b96d03e707a;p=dbsrgits%2FDBM-Deep.git diff --git a/t/13_setpack.t b/t/13_setpack.t index 8f6d2cc..293806c 100644 --- a/t/13_setpack.t +++ b/t/13_setpack.t @@ -2,12 +2,13 @@ # DBM::Deep Test ## use strict; -use Test::More tests => 4; +use Config; +use Test::More tests => 10; use t::common qw( new_fh ); use_ok( 'DBM::Deep' ); -my ($before, $after); +my ($default, $small, $medium, $large); { my ($fh, $filename) = new_fh(); @@ -17,7 +18,34 @@ my ($before, $after); ); $db->{key1} = "value1"; $db->{key2} = "value2"; - $before = (stat($db->_fh()))[7]; + $default = (stat($filename))[7]; +} + +{ + my ($fh, $filename) = new_fh(); + { + my $db = DBM::Deep->new( + file => $filename, + autoflush => 1, + pack_size => 'medium', + ); + + $db->{key1} = "value1"; + $db->{key2} = "value2"; + $medium = (stat($filename))[7]; + } + + # This tests the header to verify that the pack_size is really there + { + my $db = DBM::Deep->new( + file => $filename, + ); + + is( $db->{key1}, 'value1', 'Can read key1' ); + is( $db->{key2}, 'value2', 'Can read key2' ); + } + + cmp_ok( $medium, '==', $default, "The default is medium" ); } { @@ -31,7 +59,40 @@ my ($before, $after); $db->{key1} = "value1"; $db->{key2} = "value2"; - $after = (stat($db->_fh()))[7]; + $small = (stat($filename))[7]; + } + + # This tests the header to verify that the pack_size is really there + { + my $db = DBM::Deep->new( + file => $filename, + ); + + is( $db->{key1}, 'value1', 'Can read key1' ); + is( $db->{key2}, 'value2', 'Can read key2' ); + } + + cmp_ok( $medium, '>', $small, "medium is greater than small" ); +} + +eval "pack('Q', 0);"; +my $haveQ = !$@; + +SKIP: { + skip "Largefile support is not compiled into $^X", 3 + unless $haveQ; + + my ($fh, $filename) = new_fh(); + { + my $db = DBM::Deep->new( + file => $filename, + autoflush => 1, + pack_size => 'large', + ); + + $db->{key1} = "value1"; + $db->{key2} = "value2"; + $large = (stat($filename))[7]; } # This tests the header to verify that the pack_size is really there @@ -43,6 +104,20 @@ my ($before, $after); is( $db->{key1}, 'value1', 'Can read key1' ); is( $db->{key2}, 'value2', 'Can read key2' ); } + cmp_ok( $medium, '<', $large, "medium is smaller than large" ); } -cmp_ok( $after, '<', $before, "The new packsize reduced the size of the file" ); +#SKIP: { +# skip "Largefile support is compiled into $^X", 3 +# if $haveQ; +# +# my ($fh, $filename) = new_fh(); +# { +# my $db = DBM::Deep->new( +# file => $filename, +# autoflush => 1, +# pack_size => 'large', +# ); +# } +# +#}