Commit | Line | Data |
ffed8b01 |
1 | ## |
2 | # DBM::Deep Test |
3 | ## |
4 | use strict; |
535203b1 |
5 | use Test::More; |
6 | |
7 | plan skip_all => "You must set \$ENV{LONG_TESTS} to run the long tests" |
8 | unless $ENV{LONG_TESTS}; |
9 | |
10 | plan tests => 4; |
fde3db1a |
11 | use t::common qw( new_fh ); |
ffed8b01 |
12 | |
13 | use_ok( 'DBM::Deep' ); |
14 | |
eff6a245 |
15 | diag "This test can take up to a minute to run. Please be patient."; |
16 | |
fde3db1a |
17 | my ($fh, $filename) = new_fh(); |
ffed8b01 |
18 | my $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 |
26 | my $max_keys = 4000; |
27 | |
ffed8b01 |
28 | for ( 0 .. $max_keys ) { |
29 | $db->put( $_ => $_ * 2 ); |
30 | } |
31 | |
30029562 |
32 | my $count = -1; |
ffed8b01 |
33 | for ( 0 .. $max_keys ) { |
30029562 |
34 | $count = $_; |
a4e2db58 |
35 | unless ( $db->get( $_ ) == $_ * 2 ) { |
30029562 |
36 | last; |
37 | }; |
ffed8b01 |
38 | } |
30029562 |
39 | is( $count, $max_keys, "We read $count keys" ); |
bee3661a |
40 | |
41 | cmp_ok( scalar(@$db), '==', $max_keys + 1, "Number of elements is correct" ); |
42 | $db->clear; |
43 | cmp_ok( scalar(@$db), '==', 0, "Number of elements after clear() is correct" ); |