Added unflocks to all tests so that the tests run on OSX
[dbsrgits/DBM-Deep.git] / t / 05_bigarray.t
1 ##
2 # DBM::Deep Test
3 ##
4 use strict;
5 use Test::More tests => 2;
6 use File::Temp qw( tempfile tempdir );
7 use Fcntl qw( :flock );
8
9 use_ok( 'DBM::Deep' );
10
11 my $dir = tempdir( CLEANUP => 1 );
12 my ($fh, $filename) = tempfile( 'tmpXXXX', UNLINK => 1, DIR => $dir );
13 flock $fh, LOCK_UN;
14 my $db = DBM::Deep->new(
15         file => $filename,
16         type => DBM::Deep->TYPE_ARRAY
17 );
18
19 ##
20 # put/get many keys
21 ##
22 my $max_keys = 4000;
23
24 for ( 0 .. $max_keys ) {
25     $db->put( $_ => $_ * 2 );
26 }
27
28 my $count = -1;
29 for ( 0 .. $max_keys ) {
30     $count = $_;
31     unless ( $db->get( $_ ) == $_ * 2 ) {
32         last;
33     };
34 }
35 is( $count, $max_keys, "We read $count keys" );