6 use Test::More tests => 63;
8 use Data::Dump qw/dump/;
11 use_ok( 'MARC::Fast' );
14 my $debug = shift @ARGV;
16 my $marc_file = 't/camel.usmarc';
21 throws_ok { $marc = MARC::Fast->new(%param); } qr/marcdb/, "marcdb parametar";
23 $param{marcdb} = '/foo/bar/file';
25 throws_ok { $marc = MARC::Fast->new(%param); } qr/foo.bar/, "marcdb exist";
27 $param{marcdb} = $marc_file if -e $marc_file;
30 skip "no $param{marcdb} test file ", 37 unless (-e $param{marcdb});
32 diag "marc file: $marc_file";
34 ok($marc = MARC::Fast->new(%param), "new");
36 isa_ok ($marc, 'MARC::Fast');
40 cmp_ok($marc->count, '==', scalar @{$marc->{leader}}, "count == leader");
41 cmp_ok($marc->count, '==', scalar @{$marc->{fh_offset}}, "count == fh_offset");
43 ok(! $marc->fetch(0), "fetch 0");
44 ok(! $marc->last_leader, "no last_leader");
45 ok($marc->fetch($marc->count), "fetch max:".$marc->count);
46 ok(! $marc->fetch($marc->count + 1), "fetch max+1:".($marc->count+1));
49 ok($marc->fetch($_), "fetch($_)");
51 ok($marc->last_leader, "last_leader $_");
53 ok(my $hash = $marc->to_hash($_), "to_hash($_)");
54 diag "to_hash($_) = ",Data::Dump::dump($hash) if ($debug);
56 ok(my $hash_sf = $marc->to_hash($_, include_subfields => 1), "to_hash($_,include_subfields)");
57 diag "to_hash($_, include_subfields => 1) = ",Data::Dump::dump($hash_sf) 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");