Standardized test incantations
[dbsrgits/DBM-Deep.git] / t / 09_deeparray.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 => 3;
fde3db1a 11use t::common qw( new_fh );
ffed8b01 12
13ff93d5 13diag "This test can take up to a minute to run. Please be patient.";
14
2a81bf9e 15use_ok( 'DBM::Deep' );
ffed8b01 16
fde3db1a 17my ($fh, $filename) = new_fh();
ffed8b01 18
2a81bf9e 19my $max_levels = 1000;
ffed8b01 20
2a81bf9e 21{
22 my $db = DBM::Deep->new(
23 file => $filename,
24 type => DBM::Deep->TYPE_ARRAY,
25 );
ffed8b01 26
2a81bf9e 27 $db->[0] = [];
28 my $temp_db = $db->[0];
29 for my $k ( 0 .. $max_levels ) {
30 $temp_db->[$k] = [];
31 $temp_db = $temp_db->[$k];
32 }
33 $temp_db->[0] = "deepvalue";
ffed8b01 34}
ffed8b01 35
2a81bf9e 36{
45f047f8 37 open $fh, '+<', $filename;
2a81bf9e 38 my $db = DBM::Deep->new(
39 file => $filename,
40 type => DBM::Deep->TYPE_ARRAY,
41 );
ffed8b01 42
2a81bf9e 43 my $cur_level = -1;
44 my $temp_db = $db->[0];
45 for my $k ( 0 .. $max_levels ) {
46 $cur_level = $k;
47 $temp_db = $temp_db->[$k];
48 eval { $temp_db->isa( 'DBM::Deep' ) } or last;
49 }
50 is( $cur_level, $max_levels, "We read all the way down to level $cur_level" );
51 is( $temp_db->[0], "deepvalue", "And we retrieved the value at the bottom of the ocean" );
ffed8b01 52}