Removed final vestiges of misunderstandings
[dbsrgits/DBM-Deep.git] / t / 03_bighash.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
86867f3a 10use Test::Deep;
fde3db1a 11use t::common qw( new_fh );
ffed8b01 12
535203b1 13plan tests => 5;
14
ffed8b01 15use_ok( 'DBM::Deep' );
16
eff6a245 17diag "This test can take up to a minute to run. Please be patient.";
18
fde3db1a 19my ($fh, $filename) = new_fh();
ffed8b01 20my $db = DBM::Deep->new(
2a81bf9e 21 file => $filename,
86867f3a 22 type => DBM::Deep->TYPE_HASH,
ffed8b01 23);
ffed8b01 24
25##
26# put/get many keys
27##
a4e2db58 28my $max_keys = 4000;
29
ffed8b01 30for ( 0 .. $max_keys ) {
31 $db->put( "hello $_" => "there " . $_ * 2 );
32}
33
30029562 34my $count = -1;
ffed8b01 35for ( 0 .. $max_keys ) {
30029562 36 $count = $_;
37 unless ( $db->get( "hello $_" ) eq "there " . $_ * 2 ) {
38 last;
39 };
ffed8b01 40}
30029562 41is( $count, $max_keys, "We read $count keys" );
bee3661a 42
86867f3a 43my @keys = sort keys %$db;
44cmp_ok( scalar(@keys), '==', $max_keys + 1, "Number of keys is correct" );
45my @control = sort map { "hello $_" } 0 .. $max_keys;
46cmp_deeply( \@keys, \@control, "Correct keys are there" );
47
bee3661a 48$db->clear;
49cmp_ok( scalar(keys %$db), '==', 0, "Number of keys after clear() is correct" );