Standardized test incantations
[dbsrgits/DBM-Deep.git] / t / 09_deeparray.t
1 ##
2 # DBM::Deep Test
3 ##
4 use strict;
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 => 3;
11 use t::common qw( new_fh );
12
13 diag "This test can take up to a minute to run. Please be patient.";
14
15 use_ok( 'DBM::Deep' );
16
17 my ($fh, $filename) = new_fh();
18
19 my $max_levels = 1000;
20
21 {
22     my $db = DBM::Deep->new(
23         file => $filename,
24         type => DBM::Deep->TYPE_ARRAY,
25     );
26
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";
34 }
35
36 {
37     open $fh, '+<', $filename;
38     my $db = DBM::Deep->new(
39         file => $filename,
40         type => DBM::Deep->TYPE_ARRAY,
41     );
42
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" );
52 }