X-Git-Url: http://git.rot13.org/?p=MARC-Fast;a=blobdiff_plain;f=t%2F001_marc.t;h=ddb90706991fb80d2c833a80ba7a6af2914afa98;hp=50902341648723c1bfcfc62a41187b28562c0d27;hb=4ed177eeead2afff1d64a38fce08780baf679bda;hpb=2908568e3d5cbbae3ae26230f2c56d8b0b2ee24e diff --git a/t/001_marc.t b/t/001_marc.t index 5090234..ddb9070 100755 --- a/t/001_marc.t +++ b/t/001_marc.t @@ -3,8 +3,8 @@ use strict; use blib; -use Test::More tests => 53; -use Test::Exception; +use Test::More tests => 63; +use Data::Dump qw/dump/; BEGIN { use_ok( 'MARC::Fast' ); @@ -14,19 +14,16 @@ my $debug = shift @ARGV; my $marc_file = 't/camel.usmarc'; -if ( $debug ) { - eval { require Data::Dump; }; - $debug = 0 if ($@); -} - my $marc; my %param; -throws_ok { $marc = MARC::Fast->new(%param); } qr/marcdb/, "marcdb parametar"; +eval { $marc = MARC::Fast->new(%param) }; +ok( $@ =~ /marcdb/, "marcdb parametar" ); $param{marcdb} = '/foo/bar/file'; -throws_ok { $marc = MARC::Fast->new(%param); } qr/foo.bar/, "marcdb exist"; +eval { $marc = MARC::Fast->new(%param) }; +ok( $@ =~ /foo.bar/, "marcdb exist" ); $param{marcdb} = $marc_file if -e $marc_file; @@ -50,16 +47,20 @@ SKIP: { ok(! $marc->fetch($marc->count + 1), "fetch max+1:".($marc->count+1)); foreach (1 .. 10) { - ok($marc->fetch($_), "fetch $_"); + ok($marc->fetch($_), "fetch($_)"); ok($marc->last_leader, "last_leader $_"); - ok(my $hash = $marc->to_hash($_), "to_hash $_"); + ok(my $hash = $marc->to_hash($_), "to_hash($_)"); diag "to_hash($_) = ",Data::Dump::dump($hash) if ($debug); - ok(my $ascii = $marc->to_ascii($_), "to_ascii $_"); + + ok(my $hash_sf = $marc->to_hash($_, include_subfields => 1), "to_hash($_,include_subfields)"); + diag "to_hash($_, include_subfields => 1) = ",Data::Dump::dump($hash_sf) 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->fetch(0), "fetch(0) again"); ok(! $marc->last_leader, "no last_leader"); }