added to_ascii to be more like Biblio::ISIS API [0.05]
[MARC-Fast] / t / 001_marc.t
index 60254b5..7a665dc 100755 (executable)
@@ -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;
 
@@ -21,12 +23,14 @@ throws_ok { $marc = MARC::Fast->new(%param); } qr/foo.bar/, "marcdb exist";
 $param{marcdb} = 'data/unimarc.iso';
 
 SKIP: {
-       skip "no ",$param{marcdb}," test file ", 18 unless (-e $param{marcdb});
+       skip "no $param{marcdb} test file ", 17 unless (-e $param{marcdb});
 
        ok($marc = MARC::Fast->new(%param), "new");
 
        isa_ok ($marc, 'MARC::Fast');
 
+       #diag Dumper($marc);
+
        cmp_ok($marc->count, '==', scalar @{$marc->{leaders}}, "count == leaders");
        cmp_ok($marc->count, '==', scalar @{$marc->{fh_offset}}, "count == fh_offset");
 
@@ -36,5 +40,10 @@ SKIP: {
 
        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);
        }
 }