--- trunk/t/001_marc.t 2006/07/13 14:00:23 9 +++ trunk/t/001_marc.t 2007/10/29 22:33:35 18 @@ -3,11 +3,18 @@ use strict; use blib; -use Test::More tests => 20; +use Test::More tests => 53; use Test::Exception; -use Data::Dumper; -BEGIN { use_ok( 'MARC::Fast' ); } +BEGIN { + use_ok( 'MARC::Fast' ); +} + +my $debug = shift @ARGV; +if ( $debug ) { + eval { require Data::Dump; }; + $debug = 0 if ($@); +} my $marc; my %param; @@ -21,7 +28,7 @@ $param{marcdb} = 'data/unimarc.iso'; SKIP: { - skip "no $param{marcdb} test file ", 17 unless (-e $param{marcdb}); + skip "no $param{marcdb} test file ", 37 unless (-e $param{marcdb}); ok($marc = MARC::Fast->new(%param), "new"); @@ -29,17 +36,25 @@ #diag Dumper($marc); - cmp_ok($marc->count, '==', scalar @{$marc->{leaders}}, "count == leaders"); + cmp_ok($marc->count, '==', scalar @{$marc->{leader}}, "count == leader"); cmp_ok($marc->count, '==', scalar @{$marc->{fh_offset}}, "count == fh_offset"); ok(! $marc->fetch(0), "fetch 0"); + ok(! $marc->last_leader, "no last_leader"); 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($marc->last_leader, "last_leader $_"); + ok(my $hash = $marc->to_hash($_), "to_hash $_"); - diag "$_ :: ",Dumper($hash); + diag "to_hash($_) = ",Data::Dump::dump($hash) if ($debug); + ok(my $ascii = $marc->to_ascii($_), "to_ascii $_"); + diag "to_ascii($_) ::\n$ascii" if ($debug); } + + ok(! $marc->fetch(0), "fetch 0 again"); + ok(! $marc->last_leader, "no last_leader"); }