--- trunk/t/3-normalize-xml.t 2005/11/15 16:56:40 63 +++ trunk/t/3-normalize-xml.t 2005/11/15 16:56:44 64 @@ -1,6 +1,6 @@ #!/usr/bin/perl -w -use Test::More tests => 10; +use Test::More tests => 74; use Test::Exception; use Cwd qw/abs_path/; use blib; @@ -25,15 +25,110 @@ throws_ok { $n->open( tag => 'isis', xml_file => '/foo/bar/baz' ) } qr/file.*doesn't exist/, "open with invalid xml_file"; ok( $n->open( tag => 'isis', - xml_file => "$abs_path../conf/normalize/isis.xml", + xml_file => "$abs_path/data/normalize.xml", ), "open"); my $rec = { - '000' => [ '001' ], - '800' => [ 'foo' ], - '900' => [ 'bar' ], + '675' => [ + { + 'a' => '159.9' + } + ], + '210' => [ + { + 'c' => 'New York University press', + 'a' => 'New York', + 'd' => 'cop. 1988' + } + ], + '700' => [ + { + 'a' => 'Haynal', + 'b' => 'André' + } + ], + '801' => [ + 'FFZG' + ], + '991' => [ + '8302' + ], + '000' => [ + 1 + ], + '702' => [ + { + 'a' => 'Holder', + 'b' => 'Elizabeth' + } + ], + '215' => [ + { + 'c' => 'ilustr', + 'a' => 'xix, 202 str', + 'd' => '23cm' + } + ], + '990' => [ + '2140', + '88', + 'HAY' + ], + '200' => [ + { + 'e' => 'from Freud and Ferenczi to Michael balint', + 'a' => 'Controversies in psychoanalytic method', + 'g' => 'translated by Elizabeth Holder on the basisi of a first draft by Archie Hooton ; with a preface by Daniel N. Stern', + 'f' => 'by André E. Haynal' + } + ], + '610' => [ + 'povijest psihoanalize' + ], + '994' => [ + { + 'c' => '', + 'a' => 'PS', + 'b' => 'MG' + } + ], + '320' => [ + 'Kazalo' + ], + '101' => [ + 'ENG' + ], + '686' => [ + '2140' + ], + '300' => [ + 'Prijevod djela: ' + ] }; +foreach my $fld (keys %$rec) { + my $r = 0; + foreach my $item ($rec->{$fld}) { + if (ref($item) eq 'HASH') { + foreach my $sf (keys %$item) { + my $found = 0; + ok($n->get_data(\$rec, $fld, $sf, $r, \$found), "v${fld}^${sf}"); + ok($found, "found"); + } + my $found = 0; + ok(! $n->get_data(\$rec, $fld, 'x', $r, \$found), "no v${fld}^x"); + ok(! $found, "not found"); + } else { + my $found = 0; + ok($n->get_data(\$rec, $fld, '', $r, \$found), "v${fld}"); + ok($found, "found"); + } + } + my $found = 0; + ok(! $n->get_data(\$rec, '999', '', $r, \$found), "no v${fld}"); + ok(! $found, "not found"); +} + ok(my @ds = $n->data_structure( $rec ), "data_structure"); -#diag Dumper(@ds); +#diag Dumper($rec, \@ds);