Commit | Line | Data |
---|---|---|
ffed8b01 | 1 | ## |
2 | # DBM::Deep Test | |
3 | ## | |
4 | use strict; | |
a4e2db58 | 5 | use Test::More tests => 2; |
2a81bf9e | 6 | use File::Temp qw( tempfile tempdir ); |
ffed8b01 | 7 | |
8 | use_ok( 'DBM::Deep' ); | |
9 | ||
2a81bf9e | 10 | my $dir = tempdir( CLEANUP => 1 ); |
11 | my ($fh, $filename) = tempfile( 'tmpXXXX', UNLINK => 1, DIR => $dir ); | |
ffed8b01 | 12 | my $db = DBM::Deep->new( |
2a81bf9e | 13 | file => $filename, |
ffed8b01 | 14 | type => DBM::Deep->TYPE_HASH |
15 | ); | |
ffed8b01 | 16 | |
17 | ## | |
18 | # put/get many keys | |
19 | ## | |
a4e2db58 | 20 | my $max_keys = 4000; |
21 | ||
ffed8b01 | 22 | for ( 0 .. $max_keys ) { |
23 | $db->put( "hello $_" => "there " . $_ * 2 ); | |
24 | } | |
25 | ||
30029562 | 26 | my $count = -1; |
ffed8b01 | 27 | for ( 0 .. $max_keys ) { |
30029562 | 28 | $count = $_; |
29 | unless ( $db->get( "hello $_" ) eq "there " . $_ * 2 ) { | |
30 | last; | |
31 | }; | |
ffed8b01 | 32 | } |
30029562 | 33 | is( $count, $max_keys, "We read $count keys" ); |