1 |
#!/usr/bin/perl -w |
#!/usr/bin/perl -w |
2 |
|
|
3 |
use Test::More tests => 124; |
use Test::More tests => 132; |
4 |
use Test::Exception; |
use Test::Exception; |
5 |
use Cwd qw/abs_path/; |
use Cwd qw/abs_path/; |
6 |
use blib; |
use blib; |
121 |
if (ref($item) eq 'HASH') { |
if (ref($item) eq 'HASH') { |
122 |
foreach my $sf (keys %$item) { |
foreach my $sf (keys %$item) { |
123 |
my $found = 0; |
my $found = 0; |
124 |
ok($n->get_data(\$rec, $fld, $sf, $r, \$found), "v${fld}^${sf}"); |
ok($n->get_data(\$rec, $fld, $sf, $r, \$found), "v${fld}^${sf} / $r"); |
125 |
ok($found, "found"); |
ok($found, "found"); |
126 |
} |
} |
127 |
my $found = 0; |
my $found = 0; |
128 |
ok(! $n->get_data(\$rec, $fld, 'x', $r, \$found), "no v${fld}^x"); |
ok(! $n->get_data(\$rec, $fld, 'x', $r, \$found), "no v${fld}^x / $r"); |
129 |
ok(! $found, "not found"); |
ok(! $found, "not found"); |
130 |
} else { |
} else { |
131 |
my $found = 0; |
my $found = 0; |
132 |
ok($n->get_data(\$rec, $fld, '', $r, \$found), "v${fld}"); |
ok($n->get_data(\$rec, $fld, undef, $r, \$found), "v${fld} / $r"); |
133 |
ok($found, "found"); |
ok($found, "found"); |
134 |
} |
} |
135 |
} |
} |
136 |
my $found = 0; |
my $found = 0; |
137 |
ok(! $n->get_data(\$rec, '999', '', $r, \$found), "no v${fld}"); |
ok(! $n->get_data(\$rec, '999', '', $r, \$found), "no v${fld} / $r"); |
138 |
ok(! $found, "not found"); |
ok(! $found, "not found"); |
139 |
} |
} |
140 |
|
|
171 |
push @{$rec->{'000'}}, 42 unless ($rec->{'000'}); |
push @{$rec->{'000'}}, 42 unless ($rec->{'000'}); |
172 |
#diag "test normalisation of: ",Dumper($n->{import_xml}->{indexer}, $rec); |
#diag "test normalisation of: ",Dumper($n->{import_xml}->{indexer}, $rec); |
173 |
ok(my $ds = $n->data_structure( $rec ), "data_structure"); |
ok(my $ds = $n->data_structure( $rec ), "data_structure"); |
174 |
#diag Dumper($ds); |
#diag Dumper($ds->{$tag}->{display}); # if ($i == 0); |
175 |
cmp_ok($ds->{$tag}->{display}->[$i], 'eq', $r, "parse $tag/$i - $r"); |
cmp_ok($ds->{$tag}->{display}->[$i], 'eq', $r, "parse $tag/$i - $r"); |
176 |
} |
} |
177 |
|
|
212 |
} ], |
} ], |
213 |
}; |
}; |
214 |
|
|
215 |
my $import = { |
$import = { |
216 |
'Tag' => { 'isis' => [ |
'Tag' => { 'isis' => [ |
217 |
{ content => '0 v900^a 1 v900^b 2 v900^c 3 v900^x 4' }, |
{ content => '0 v900^a 1 v900^b 2 v900^c 3 v900^x 4' }, |
218 |
] }, |
] }, |
232 |
} |
} |
233 |
} |
} |
234 |
|
|
235 |
my $import = { |
$import = { |
236 |
'Tag_a' => { 'isis' => [ |
'Tag_a' => { 'isis' => [ |
237 |
{ content => 'v900^a' }, |
{ content => 'v900^a' }, |
238 |
] }, |
] }, |
245 |
'Tag_x' => { 'isis' => [ |
'Tag_x' => { 'isis' => [ |
246 |
{ content => 'v900^x' }, |
{ content => 'v900^x' }, |
247 |
] }, |
] }, |
248 |
|
'Tag_s1' => { 'isis' => [ |
249 |
|
{ content => 'v900^a = v900^c' }, |
250 |
|
] }, |
251 |
|
'Tag_s2' => { 'isis' => [ |
252 |
|
{ content => 's900^a s900^b s900^c s900^x' }, |
253 |
|
] }, |
254 |
}; |
}; |
255 |
|
|
256 |
parse_test_arr($import, 'Tag_a', $rec, [ '','a1','','a2' ] ); |
parse_test_arr($import, 'Tag_a', $rec, [ '','a1','','a2' ] ); |
257 |
parse_test_arr($import, 'Tag_b', $rec, [ 'b1','b2','b3','b4' ] ); |
parse_test_arr($import, 'Tag_b', $rec, [ 'b1','b2','b3','b4' ] ); |
258 |
parse_test_arr($import, 'Tag_c', $rec, [ '','','c1','c2' ] ); |
parse_test_arr($import, 'Tag_c', $rec, [ '','','c1','c2' ] ); |
259 |
parse_test_arr($import, 'Tag_x', $rec, [ 'b1','a1_b2','b3_c1','a2_b4_c2' ] ); |
parse_test_arr($import, 'Tag_x', $rec, [ 'b1','a1_b2','b3_c1','a2_b4_c2' ] ); |
260 |
|
parse_test_arr($import, 'Tag_s1', $rec, [ '', 'a1', 'c1', 'a2 = c2' ] ); |
261 |
|
|