6 use Test::More tests => 53;
10 use_ok( 'MARC::Fast' );
13 my $debug = shift @ARGV;
15 my $marc_file = 't/camel.usmarc';
18 eval { require Data::Dump; };
25 throws_ok { $marc = MARC::Fast->new(%param); } qr/marcdb/, "marcdb parametar";
27 $param{marcdb} = '/foo/bar/file';
29 throws_ok { $marc = MARC::Fast->new(%param); } qr/foo.bar/, "marcdb exist";
31 $param{marcdb} = $marc_file if -e $marc_file;
34 skip "no $param{marcdb} test file ", 37 unless (-e $param{marcdb});
36 diag "marc file: $marc_file";
38 ok($marc = MARC::Fast->new(%param), "new");
40 isa_ok ($marc, 'MARC::Fast');
44 cmp_ok($marc->count, '==', scalar @{$marc->{leader}}, "count == leader");
45 cmp_ok($marc->count, '==', scalar @{$marc->{fh_offset}}, "count == fh_offset");
47 ok(! $marc->fetch(0), "fetch 0");
48 ok(! $marc->last_leader, "no last_leader");
49 ok($marc->fetch($marc->count), "fetch max:".$marc->count);
50 ok(! $marc->fetch($marc->count + 1), "fetch max+1:".($marc->count+1));
53 ok($marc->fetch($_), "fetch $_");
55 ok($marc->last_leader, "last_leader $_");
57 ok(my $hash = $marc->to_hash($_), "to_hash $_");
58 diag "to_hash($_) = ",Data::Dump::dump($hash) if ($debug);
59 ok(my $ascii = $marc->to_ascii($_), "to_ascii $_");
60 diag "to_ascii($_) ::\n$ascii" if ($debug);
63 ok(! $marc->fetch(0), "fetch 0 again");
64 ok(! $marc->last_leader, "no last_leader");