6 use Test::More tests => 6;
8 use File::Temp qw( tempfile tempdir );
10 use_ok( 'DBM::Deep' );
12 my $dir = tempdir( CLEANUP => 1 );
13 my ($fh, $filename) = tempfile( 'tmpXXXX', UNLINK => 1, DIR => $dir );
16 # test a corrupted file
18 open FH, ">$filename";
22 DBM::Deep->new( $filename );
23 } qr/DBM::Deep: Corrupted file, no master index record/, "Fail if there's no master index record";
26 my ($fh, $filename) = tempfile( 'tmpXXXX', UNLINK => 1, DIR => $dir );
28 tie %hash, 'DBM::Deep', $filename;
33 tie @array, 'DBM::Deep', $filename;
34 } qr/DBM::Deep: File type mismatch/, "Fail if we try and tie a hash file with an array";
37 DBM::Deep->new( file => $filename, type => DBM::Deep->TYPE_ARRAY )
38 } qr/DBM::Deep: File type mismatch/, "Fail if we try and open a hash file with an array";
42 my ($fh, $filename) = tempfile( 'tmpXXXX', UNLINK => 1, DIR => $dir );
44 tie @array, 'DBM::Deep', $filename;
49 tie %hash, 'DBM::Deep', $filename;
50 } qr/DBM::Deep: File type mismatch/, "Fail if we try and tie an array file with a hash";
53 DBM::Deep->new( file => $filename, type => DBM::Deep->TYPE_HASH )
54 } qr/DBM::Deep: File type mismatch/, "Fail if we try and open an array file with a hash";