--- trunk/t/001_marc.t 2005/01/04 10:26:07 1 +++ trunk/t/001_marc.t 2006/11/03 20:34:31 11 @@ -3,12 +3,14 @@ use strict; use blib; -use Test::More tests => 20; +use Test::More tests => 40; use Test::Exception; -use Data::Dumper; +use Data::Dump qw/dump/; BEGIN { use_ok( 'MARC::Fast' ); } +my $debug = shift @ARGV; + my $marc; my %param; @@ -18,20 +20,30 @@ throws_ok { $marc = MARC::Fast->new(%param); } qr/foo.bar/, "marcdb exist"; -$param{marcdb} = '../unimarc.iso'; +$param{marcdb} = 'data/unimarc.iso'; -ok($marc = MARC::Fast->new(%param), "new"); +SKIP: { + skip "no $param{marcdb} test file ", 17 unless (-e $param{marcdb}); -isa_ok ($marc, 'MARC::Fast'); + ok($marc = MARC::Fast->new(%param), "new"); -cmp_ok($marc->count, '==', scalar @{$marc->{leaders}}, "count == leaders"); -cmp_ok($marc->count, '==', scalar @{$marc->{fh_offset}}, "count == fh_offset"); + isa_ok ($marc, 'MARC::Fast'); -ok(! $marc->fetch(0), "fetch 0"); -ok($marc->fetch($marc->count), "fetch max:".$marc->count); -ok(! $marc->fetch($marc->count + 1), "fetch max+1:".($marc->count+1)); + #diag Dumper($marc); -foreach (1 .. 10) { - ok($marc->fetch($_), "fetch $_"); -} + cmp_ok($marc->count, '==', scalar @{$marc->{leaders}}, "count == leaders"); + cmp_ok($marc->count, '==', scalar @{$marc->{fh_offset}}, "count == fh_offset"); + + ok(! $marc->fetch(0), "fetch 0"); + ok($marc->fetch($marc->count), "fetch max:".$marc->count); + ok(! $marc->fetch($marc->count + 1), "fetch max+1:".($marc->count+1)); + foreach (1 .. 10) { + ok($marc->fetch($_), "fetch $_"); + + ok(my $hash = $marc->to_hash($_), "to_hash $_"); + diag "to_hash($_) = ",dump($hash) if ($debug); + ok(my $ascii = $marc->to_ascii($_), "to_ascii $_"); + diag "to_ascii($_) ::\n$ascii" if ($debug); + } +}