6 use Test::More tests => 63;
7 use Data::Dump qw/dump/;
10 use_ok( 'MARC::Fast' );
13 my $debug = shift @ARGV;
15 my $marc_file = 't/camel.usmarc';
20 eval { $marc = MARC::Fast->new(%param) };
21 ok( $@ =~ /marcdb/, "marcdb parametar" );
23 $param{marcdb} = '/foo/bar/file';
25 eval { $marc = MARC::Fast->new(%param) };
26 ok( $@ =~ /foo.bar/, "marcdb exist" );
28 $param{marcdb} = $marc_file if -e $marc_file;
31 skip "no $param{marcdb} test file ", 37 unless (-e $param{marcdb});
33 diag "marc file: $marc_file";
35 ok($marc = MARC::Fast->new(%param), "new");
37 isa_ok ($marc, 'MARC::Fast');
41 cmp_ok($marc->count, '==', scalar @{$marc->{leader}}, "count == leader");
42 cmp_ok($marc->count, '==', scalar @{$marc->{fh_offset}}, "count == fh_offset");
44 ok(! $marc->fetch(0), "fetch 0");
45 ok(! $marc->last_leader, "no last_leader");
46 ok($marc->fetch($marc->count), "fetch max:".$marc->count);
47 ok(! $marc->fetch($marc->count + 1), "fetch max+1:".($marc->count+1));
50 ok($marc->fetch($_), "fetch($_)");
52 ok($marc->last_leader, "last_leader $_");
54 ok(my $hash = $marc->to_hash($_), "to_hash($_)");
55 diag "to_hash($_) = ",Data::Dump::dump($hash) if ($debug);
57 ok(my $hash_sf = $marc->to_hash($_, include_subfields => 1), "to_hash($_,include_subfields)");
58 diag "to_hash($_, include_subfields => 1) = ",Data::Dump::dump($hash_sf) if ($debug);
60 ok(my $ascii = $marc->to_ascii($_), "to_ascii($_)");
61 diag "to_ascii($_) ::\n$ascii" if ($debug);
64 ok(! $marc->fetch(0), "fetch(0) again");
65 ok(! $marc->last_leader, "no last_leader");