Commit | Line | Data |
ffed8b01 |
1 | use strict; |
0e3e3555 |
2 | use warnings FATAL => 'all'; |
3 | |
535203b1 |
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 | |
0e3e3555 |
9 | use t::common qw( new_dbm ); |
ffed8b01 |
10 | |
11 | use_ok( 'DBM::Deep' ); |
12 | |
0e3e3555 |
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" ); |
ffed8b01 |
40 | } |
bee3661a |
41 | |
0e3e3555 |
42 | done_testing; |