hash_filter now accepts whole line from record and field number. Removed
[Biblio-Isis] / t / 2_isis.t
index 239bbe7..1ebebe1 100755 (executable)
@@ -3,7 +3,7 @@
 use strict;
 use blib;
 
-use Test::More tests => 132;
+use Test::More tests => 174;
 use File::Spec;
 
 BEGIN {
@@ -18,8 +18,7 @@ BEGIN {
 }
 
 
-my $debug = shift @ARGV;
-$debug = length( $debug ) if ($debug);
+my $debug = length( shift(@ARGV) || '' );
 my $isis;
 
 my $path_winisis = File::Spec->catfile('data', 'winisis', 'BIBL');
@@ -193,6 +192,12 @@ diag "record = ",Dumper($isis->{record}) if ($debug);
 $isis = Biblio::Isis->new (
        isisdb => $path_winisis,
        debug => $debug,
+       hash_filter => sub {
+               my ($l,$nr) = @_;
+               ok(grep(/$nr/, keys %{ $isis->{record} }), "hash_filter $nr in record");
+               ok(grep(/\Q$l\E/, @{ $isis->{record}->{$nr} }), "hash_filter line $l found");
+               return($l);
+       },
 );
 
 ok(! $isis->fetch(3), "deleted not found");
@@ -260,3 +265,16 @@ is_deeply( $hash, {
   ],
 }, 'hash is_deeply');
 
+ok($hash = $isis->to_hash({ mfn => $isis->mfn, join_subfields_with => ' ; ' }), 'to_hash(mfn,join_subfields_with)');
+diag "to_hash = ",Dumper( $hash ) if ($debug);
+is_deeply( $hash, {
+   "000" => [42],
+   900   => [{ a => "900a", b => "900b", c => "900c" }],
+   901   => [
+              { a => "901a-1", b => "901b-1", c => "901c-1" },
+              { a => "901a-2", b => "901b-2" },
+              { a => "901a-3" },
+            ],
+   902   => [{ a => "a1 ; a2 ; a3 ; a4 ; a5", b => "b1 ; b2", c => "c1" }],
+}, 'hash is_deeply');
+