r11693@rob-kinyons-powerbook58: rob | 2006-04-30 22:15:38 -0400
[dbsrgits/DBM-Deep.git] / t / 03_bighash.t
index 03d8298..cf082bd 100644 (file)
@@ -2,16 +2,18 @@
 # DBM::Deep Test
 ##
 use strict;
-use Test::More tests => 2;
-use File::Temp qw( tempfile tempdir );
+use Test::More tests => 5;
+use Test::Deep;
+use t::common qw( new_fh );
 
 use_ok( 'DBM::Deep' );
 
-my $dir = tempdir( CLEANUP => 1 );
-my ($fh, $filename) = tempfile( 'tmpXXXX', UNLINK => 1, DIR => $dir );
+diag "This test can take up to a minute to run. Please be patient.";
+
+my ($fh, $filename) = new_fh();
 my $db = DBM::Deep->new(
        file => $filename,
-       type => DBM::Deep->TYPE_HASH
+       type => DBM::Deep->TYPE_HASH,
 );
 
 ##
@@ -31,3 +33,11 @@ for ( 0 .. $max_keys ) {
     };
 }
 is( $count, $max_keys, "We read $count keys" );
+
+my @keys = sort keys %$db;
+cmp_ok( scalar(@keys), '==', $max_keys + 1, "Number of keys is correct" );
+my @control =  sort map { "hello $_" } 0 .. $max_keys;
+cmp_deeply( \@keys, \@control, "Correct keys are there" );
+
+$db->clear;
+cmp_ok( scalar(keys %$db), '==', 0, "Number of keys after clear() is correct" );