/[webpac2]/trunk/t/3-normalize-xml.t
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /trunk/t/3-normalize-xml.t

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 62 by dpavlin, Tue Nov 15 14:31:12 2005 UTC revision 64 by dpavlin, Tue Nov 15 16:56:44 2005 UTC
# Line 1  Line 1 
1  #!/usr/bin/perl -w  #!/usr/bin/perl -w
2    
3  use Test::More tests => 10;  use Test::More tests => 74;
4  use Test::Exception;  use Test::Exception;
5  use Cwd qw/abs_path/;  use Cwd qw/abs_path/;
6  use blib;  use blib;
# Line 25  throws_ok { $n->open( tag => 'isis' ) } Line 25  throws_ok { $n->open( tag => 'isis' ) }
25  throws_ok { $n->open( tag => 'isis', xml_file => '/foo/bar/baz' ) } qr/file.*doesn't exist/, "open with invalid xml_file";  throws_ok { $n->open( tag => 'isis', xml_file => '/foo/bar/baz' ) } qr/file.*doesn't exist/, "open with invalid xml_file";
26  ok( $n->open(  ok( $n->open(
27          tag => 'isis',          tag => 'isis',
28          xml_file => "$abs_path../conf/normalize/isis.xml",          xml_file => "$abs_path/data/normalize.xml",
29  ), "open");  ), "open");
30    
31  my $rec = {  my $rec = {
32          '000' => [ '001' ],   '675' => [
33          '800' => [ 'foo' ],              {
34          '900' => [ 'bar' ],                'a' => '159.9'
35                }
36              ],
37     '210' => [
38                {
39                  'c' => 'New York University press',
40                  'a' => 'New York',
41                  'd' => 'cop. 1988'
42                }
43              ],
44     '700' => [
45                {
46                  'a' => 'Haynal',
47                  'b' => 'André'
48                }
49              ],
50     '801' => [
51                'FFZG'
52              ],
53     '991' => [
54                '8302'
55              ],
56     '000' => [
57                1
58              ],
59     '702' => [
60                {
61                  'a' => 'Holder',
62                  'b' => 'Elizabeth'
63                }
64              ],
65     '215' => [
66                {
67                  'c' => 'ilustr',
68                  'a' => 'xix, 202 str',
69                  'd' => '23cm'
70                }
71              ],
72     '990' => [
73                '2140',
74                '88',
75                'HAY'
76              ],
77     '200' => [
78                {
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'
83                }
84              ],
85     '610' => [
86                'povijest psihoanalize'
87              ],
88     '994' => [
89                {
90                  'c' => '',
91                  'a' => 'PS',
92                  'b' => 'MG'
93                }
94              ],
95     '320' => [
96                'Kazalo'
97              ],
98     '101' => [
99                'ENG'
100              ],
101     '686' => [
102                '2140'
103              ],
104     '300' => [
105                'Prijevod djela: '
106              ]
107  };  };
108    
109    foreach my $fld (keys %$rec) {
110            my $r = 0;
111            foreach my $item ($rec->{$fld}) {
112                    if (ref($item) eq 'HASH') {
113                            foreach my $sf (keys %$item) {
114                                    my $found = 0;
115                                    ok($n->get_data(\$rec, $fld, $sf, $r, \$found), "v${fld}^${sf}");
116                                    ok($found, "found");
117                            }
118                            my $found = 0;
119                            ok(! $n->get_data(\$rec, $fld, 'x', $r, \$found), "no v${fld}^x");
120                            ok(! $found, "not found");
121                    } else {
122                            my $found = 0;
123                            ok($n->get_data(\$rec, $fld, '', $r, \$found), "v${fld}");
124                            ok($found, "found");
125                    }
126            }
127            my $found = 0;
128            ok(! $n->get_data(\$rec, '999', '', $r, \$found), "no v${fld}");
129            ok(! $found, "not found");
130    }
131    
132  ok(my @ds = $n->data_structure( $rec ), "data_structure");  ok(my @ds = $n->data_structure( $rec ), "data_structure");
133    
134  #diag Dumper(@ds);  #diag Dumper($rec, \@ds);

Legend:
Removed from v.62  
changed lines
  Added in v.64

  ViewVC Help
Powered by ViewVC 1.1.26