3 use Test::More tests => 74;
11 use_ok( 'WebPAC::Normalize::XML' );
14 ok(my $abs_path = abs_path($0), "abs_path");
15 $abs_path =~ s#/[^/]*$#/#;
16 diag "abs_path: $abs_path";
18 throws_ok { new WebPAC::Normalize::XML( lookup_regex => 'foo' ) } qr/pair/, "lookup_regex without lookup";
19 throws_ok { new WebPAC::Normalize::XML( lookup => 'bar' ) } qr/pair/, "lookup without lookup_regex";
21 ok(my $n = new WebPAC::Normalize::XML( debug => 0 ), "new");
23 throws_ok { $n->open() } qr/tag/, "open without tag";
24 throws_ok { $n->open( tag => 'isis' ) } qr/xml_file/, "open without xml_file";
25 throws_ok { $n->open( tag => 'isis', xml_file => '/foo/bar/baz' ) } qr/file.*doesn't exist/, "open with invalid xml_file";
28 xml_file => "$abs_path/data/normalize.xml",
39 'c' => 'New York University press',
68 'a' => 'xix, 202 str',
79 'e' => 'from Freud and Ferenczi to Michael balint',
80 'a' => 'Controversies in psychoanalytic method',
81 'g' => 'translated by Elizabeth Holder on the basisi of a first draft by Archie Hooton ; with a preface by Daniel N. Stern',
82 'f' => 'by André E. Haynal'
86 'povijest psihoanalize'
109 foreach my $fld (keys %$rec) {
111 foreach my $item ($rec->{$fld}) {
112 if (ref($item) eq 'HASH') {
113 foreach my $sf (keys %$item) {
115 ok($n->get_data(\$rec, $fld, $sf, $r, \$found), "v${fld}^${sf}");
119 ok(! $n->get_data(\$rec, $fld, 'x', $r, \$found), "no v${fld}^x");
120 ok(! $found, "not found");
123 ok($n->get_data(\$rec, $fld, '', $r, \$found), "v${fld}");
128 ok(! $n->get_data(\$rec, '999', '', $r, \$found), "no v${fld}");
129 ok(! $found, "not found");
132 ok(my $ds = $n->data_structure( $rec ), "data_structure");
134 diag Dumper($rec, $ds);