converted TODO test into real one (corrupted master index)
[dbsrgits/DBM-Deep.git] / t / 07error.t
CommitLineData
ffed8b01 1##
2# DBM::Deep Test
3##
4use strict;
1e9d4578 5use Test::More tests => 5;
ffed8b01 6
7use_ok( 'DBM::Deep' );
8
9unlink "t/test.db";
10my $db = DBM::Deep->new( "t/test.db" );
11if ($db->error()) {
12 die "ERROR: " . $db->error();
13}
14
15##
16# cause an error
17##
18eval { $db->push("foo"); }; # ERROR -- array-only method
ffed8b01 19ok( $db->error() );
20
1e9d4578 21##
22# make sure you can clear the error state
23##
ffed8b01 24$db->clear_error();
ffed8b01 25ok( !$db->error() );
26undef $db;
27
1e9d4578 28##
29# test a corrupted file
30##
ffed8b01 31open FH, '>t/test.db';
32print FH 'DPDB';
33close FH;
1e9d4578 34eval { $db = DBM::Deep->new( "t/test.db" ); };
35ok( $@ );
36
37##
38# test a file type mismatch
39##
40unlink "t/test.db";
41my %hash;
42tie %hash, 'DBM::Deep', 't/test.db';
43$hash{'foo'} = 'bar';
44undef %hash;
45my @array;
46eval { tie @array, 'DBM::Deep', 't/test.db'; };
47ok( $@ );