Commit | Line | Data |
---|---|---|
ffed8b01 | 1 | ## |
2 | # DBM::Deep Test | |
3 | ## | |
4 | use strict; | |
9ab67b8c | 5 | use Test::More tests => 2; |
2a81bf9e | 6 | use File::Temp qw( tempfile tempdir ); |
58910373 | 7 | use Fcntl qw( :flock ); |
ffed8b01 | 8 | |
9 | use_ok( 'DBM::Deep' ); | |
10 | ||
2a81bf9e | 11 | my $dir = tempdir( CLEANUP => 1 ); |
12 | my ($fh, $filename) = tempfile( 'tmpXXXX', UNLINK => 1, DIR => $dir ); | |
58910373 | 13 | flock $fh, LOCK_UN; |
ffed8b01 | 14 | my $db = DBM::Deep->new( |
2a81bf9e | 15 | file => $filename, |
ffed8b01 | 16 | type => DBM::Deep->TYPE_ARRAY |
17 | ); | |
ffed8b01 | 18 | |
19 | ## | |
20 | # put/get many keys | |
21 | ## | |
9ab67b8c | 22 | my $max_keys = 4000; |
23 | ||
ffed8b01 | 24 | for ( 0 .. $max_keys ) { |
25 | $db->put( $_ => $_ * 2 ); | |
26 | } | |
27 | ||
30029562 | 28 | my $count = -1; |
ffed8b01 | 29 | for ( 0 .. $max_keys ) { |
30029562 | 30 | $count = $_; |
a4e2db58 | 31 | unless ( $db->get( $_ ) == $_ * 2 ) { |
30029562 | 32 | last; |
33 | }; | |
ffed8b01 | 34 | } |
30029562 | 35 | is( $count, $max_keys, "We read $count keys" ); |