Fixed immediate dependence on DBI
[dbsrgits/DBM-Deep.git] / t / 05_bigarray.t
1 use strict;
2 use warnings FATAL => 'all';
3
4 use Test::More;
5
6 plan skip_all => "You must set \$ENV{LONG_TESTS} to run the long tests"
7     unless $ENV{LONG_TESTS};
8
9 use t::common qw( new_dbm );
10
11 use_ok( 'DBM::Deep' );
12
13 diag "This test can take up to several minutes to run. Please be patient.";
14
15 my $dbm_factory = new_dbm( type => DBM::Deep->TYPE_ARRAY );
16 while ( 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" );
40 }
41
42 done_testing;