3 |
use strict; |
use strict; |
4 |
use blib; |
use blib; |
5 |
|
|
6 |
use Test::More tests => 174; |
use Test::More tests => 176; |
7 |
use File::Spec; |
use File::Spec; |
8 |
|
|
9 |
BEGIN { |
BEGIN { |
246 |
ok(my $hash2 = $isis->to_hash({ mfn => $isis->mfn }), 'to_hash(mfn)'); |
ok(my $hash2 = $isis->to_hash({ mfn => $isis->mfn }), 'to_hash(mfn)'); |
247 |
is_deeply( $hash2, $hash, 'same hash' ); |
is_deeply( $hash2, $hash, 'same hash' ); |
248 |
|
|
249 |
|
# test to_hash( include_subfields ) |
250 |
ok($hash = $isis->to_hash({ mfn => $isis->mfn, include_subfields => 1 }), 'to_hash(mfn,include_subfields)'); |
ok($hash = $isis->to_hash({ mfn => $isis->mfn, include_subfields => 1 }), 'to_hash(mfn,include_subfields)'); |
251 |
diag "to_hash = ",Dumper( $hash ) if ($debug); |
diag "to_hash = ",Dumper( $hash ) if ($debug); |
252 |
is_deeply( $hash, { |
is_deeply( $hash, { |
266 |
], |
], |
267 |
}, 'hash is_deeply'); |
}, 'hash is_deeply'); |
268 |
|
|
269 |
|
# test to_hash( join_subfields_with ) |
270 |
ok($hash = $isis->to_hash({ mfn => $isis->mfn, join_subfields_with => ' ; ' }), 'to_hash(mfn,join_subfields_with)'); |
ok($hash = $isis->to_hash({ mfn => $isis->mfn, join_subfields_with => ' ; ' }), 'to_hash(mfn,join_subfields_with)'); |
271 |
diag "to_hash = ",Dumper( $hash ) if ($debug); |
diag "to_hash = ",Dumper( $hash ) if ($debug); |
272 |
is_deeply( $hash, { |
is_deeply( $hash, { |
280 |
902 => [{ a => "a1 ; a2 ; a3 ; a4 ; a5", b => "b1 ; b2", c => "c1" }], |
902 => [{ a => "a1 ; a2 ; a3 ; a4 ; a5", b => "b1 ; b2", c => "c1" }], |
281 |
}, 'hash is_deeply'); |
}, 'hash is_deeply'); |
282 |
|
|
283 |
|
# test to_hash( hash_filter ) |
284 |
|
ok($hash = $isis->to_hash({ mfn => $isis->mfn, hash_filter => sub { |
285 |
|
my ($l,$f) = @_; |
286 |
|
if ($f == 900) { |
287 |
|
$l =~ s/0/o/g; |
288 |
|
} elsif ($f == 901) { |
289 |
|
$l =~ s/1/i/g; |
290 |
|
} elsif ($f == 902) { |
291 |
|
$l =~ s/2/s/g; |
292 |
|
} |
293 |
|
return $l; |
294 |
|
}}), 'to_hash(mfn,hash_filter)'); |
295 |
|
diag "to_hash = ",Dumper( $hash ) if ($debug); |
296 |
|
is_deeply( $hash, { |
297 |
|
"000" => [42], |
298 |
|
900 => [{ a => "9ooa", b => "9oob", c => "9ooc" }], |
299 |
|
901 => [ |
300 |
|
{ a => "90ia-i", b => "90ib-i", c => "90ic-i" }, |
301 |
|
{ a => "90ia-2", b => "90ib-2" }, |
302 |
|
{ a => "90ia-3" }, |
303 |
|
], |
304 |
|
902 => [{ a => ["a1", "as", "a3", "a4", "a5"], b => ["b1", "bs"], c => "c1" }], |
305 |
|
}, 'hash is_deeply'); |
306 |
|
|