Fixed immediate dependence on DBI
[dbsrgits/DBM-Deep.git] / t / 05_bigarray.t
CommitLineData
ffed8b01 1use strict;
0e3e3555 2use warnings FATAL => 'all';
3
535203b1 4use Test::More;
5
6plan skip_all => "You must set \$ENV{LONG_TESTS} to run the long tests"
7 unless $ENV{LONG_TESTS};
8
0e3e3555 9use t::common qw( new_dbm );
ffed8b01 10
11use_ok( 'DBM::Deep' );
12
0e3e3555 13diag "This test can take up to several minutes to run. Please be patient.";
14
15my $dbm_factory = new_dbm( type => DBM::Deep->TYPE_ARRAY );
16while ( my $dbm_maker = $dbm_factory->() ) {
17 my $db = $dbm_maker->();
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" );
36
37 cmp_ok( scalar(@$db), '==', $max_keys + 1, "Number of elements is correct" );
38 $db->clear;
39 cmp_ok( scalar(@$db), '==', 0, "Number of elements after clear() is correct" );
ffed8b01 40}
bee3661a 41
0e3e3555 42done_testing;