All the tests now pass with the broken out classes
[dbsrgits/DBM-Deep.git] / t / 05_bigarray.t
CommitLineData
ffed8b01 1##
2# DBM::Deep Test
3##
4use strict;
535203b1 5use Test::More;
6
7plan skip_all => "You must set \$ENV{LONG_TESTS} to run the long tests"
8 unless $ENV{LONG_TESTS};
9
10plan tests => 4;
fde3db1a 11use t::common qw( new_fh );
ffed8b01 12
13use_ok( 'DBM::Deep' );
14
eff6a245 15diag "This test can take up to a minute to run. Please be patient.";
16
fde3db1a 17my ($fh, $filename) = new_fh();
ffed8b01 18my $db = DBM::Deep->new(
2a81bf9e 19 file => $filename,
fde3db1a 20 type => DBM::Deep->TYPE_ARRAY,
ffed8b01 21);
ffed8b01 22
23##
24# put/get many keys
25##
9ab67b8c 26my $max_keys = 4000;
27
ffed8b01 28for ( 0 .. $max_keys ) {
29 $db->put( $_ => $_ * 2 );
30}
31
30029562 32my $count = -1;
ffed8b01 33for ( 0 .. $max_keys ) {
30029562 34 $count = $_;
a4e2db58 35 unless ( $db->get( $_ ) == $_ * 2 ) {
30029562 36 last;
37 };
ffed8b01 38}
30029562 39is( $count, $max_keys, "We read $count keys" );
bee3661a 40
41cmp_ok( scalar(@$db), '==', $max_keys + 1, "Number of elements is correct" );
42$db->clear;
43cmp_ok( scalar(@$db), '==', 0, "Number of elements after clear() is correct" );