Added more tests on SPLICE
[dbsrgits/DBM-Deep.git] / t / 27_filehandle.t
CommitLineData
714618f0 1##
2# DBM::Deep Test
3##
4use strict;
5use Test::More tests => 4;
6
7use DBM::Deep;
8
9open(FILE, "t/27_filehandle.t.db") || die("Can't open t/27_filehandle.t.db\n");
10
11my $db;
12
13# test if we can open and read a db using its filehandle
14
15ok(($db = DBM::Deep->new(fh => *FILE)), "open db in filehandle");
16ok($db->{hash}->{foo}->[1] eq 'b', "and get at stuff in the database");
17
18undef $db;
19close(FILE);
20
21# now the same, but with an offset into the file. Use the database that's
22# embedded in the test for the DATA filehandle. First, find the database ...
23open(FILE, "t/28_DATA.t") || die("Can't open t/28_DATA.t\n");
24while(my $line = <FILE>) {
25 last if($line =~ /^__DATA__/);
26}
27my $offset = tell(FILE);
28close(FILE);
29
30open(FILE, "t/28_DATA.t");
31ok(($db = DBM::Deep->new(fh => *FILE, file_offset => $offset)), "open db in filehandle with offset");
32ok($db->{hash}->{foo}->[1] eq 'b', "and get at stuff in the database");
33