/[Biblio-Isis]/trunk/t/002_isis.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

Annotation of /trunk/t/002_isis.t

Parent Directory Parent Directory | Revision Log Revision Log


Revision 28 - (hide annotations)
Sat Jan 1 22:29:49 2005 UTC (17 years, 11 months ago) by dpavlin
File MIME type: application/x-troff
File size: 3752 byte(s)
test read_cnt

1 dpavlin 19 #!/usr/bin/perl -w
2    
3     use strict;
4     use blib;
5    
6     use Data::Dumper;
7    
8 dpavlin 28 use Test::More tests => 110;
9 dpavlin 19
10     BEGIN { use_ok( 'IsisDB' ); }
11    
12     my $isis;
13    
14     sub test_data {
15    
16 dpavlin 21 my $args = {@_};
17    
18 dpavlin 19 isa_ok ($isis, 'IsisDB');
19    
20     cmp_ok($isis->{maxmfn}, '==', 5, "maxmfn set to 5");
21    
22     # test .CNT data
23    
24     SKIP: {
25     skip "no CNT file for this database", 5 unless $isis->{cnt_file};
26    
27 dpavlin 28 ok(my $isis_cnt = $isis->read_cnt, "read_cnt");
28 dpavlin 19
29 dpavlin 28 cmp_ok(scalar keys %{$isis_cnt}, '==', 2, "returns 2 elements");
30    
31 dpavlin 19 my $cnt = {
32     '1' => {
33     'N' => 15,
34     'K' => 5,
35     'FMAXPOS' => 8,
36     'POSRX' => 1,
37     'ABNORMAL' => 1,
38     'ORDN' => 5,
39     'LIV' => 0,
40     'ORDF' => 5,
41     'NMAXPOS' => 1
42     },
43     '2' => {
44     'N' => 15,
45     'K' => 5,
46     'FMAXPOS' => 4,
47     'POSRX' => 1,
48     'ABNORMAL' => 0,
49     'ORDN' => 5,
50     'LIV' => 0,
51     'ORDF' => 5,
52     'NMAXPOS' => 1
53     }
54     };
55    
56     foreach my $c (keys %{$cnt}) {
57     foreach my $kn (keys %{$cnt->{$c}}) {
58 dpavlin 28 cmp_ok($isis_cnt->{$c}->{$kn}, '==', $cnt->{$c}->{$kn}, "cnt $c $kn same");
59 dpavlin 19 }
60     }
61     }
62    
63 dpavlin 21 # test fetch
64    
65     my $data = [ {
66     '801' => [ '^aFFZG' ],
67     '702' => [ '^aHolder^bElizabeth' ],
68     '990' => [ '2140', '88', 'HAY' ],
69     '675' => [ '^a159.9' ],
70     '210' => [ '^aNew York^cNew York University press^dcop. 1988' ],
71     }, {
72     '210' => [ '^aNew York^cUniversity press^d1989' ],
73     '700' => [ '^aFrosh^bStephen' ],
74     '990' => [ '2140', '89', 'FRO' ],
75     '200' => [ '^aPsychoanalysis and psychology^eminding the gap^fStephen Frosh' ],
76     '215' => [ '^aIX, 275 str.^d23 cm' ],
77     }, {
78     '210' => [ '^aLondon^cFree Associoation Books^d1992' ],
79     '700' => [ '^aTurkle^bShirlie' ],
80     '990' => [ '2140', '92', 'LAC' ],
81     '200' => [ '^aPsychoanalitic politics^eJacques Lacan and Freud\'s French Revolution^fSherry Turkle' ],
82     '686' => [ '^a2140', '^a2140' ],
83    
84     }, {
85     '700' => [ '^aGross^bRichard' ],
86     '200' => [ '^aKey studies in psychology^fRichard D. Gross' ],
87     '210' => [ '^aLondon^cHodder & Stoughton^d1994' ],
88     '10' => [ '^a0-340-59691-0' ],
89     }, {
90     # identifier test
91     '225' => [ '1#^aMcGraw-Hill series in Psychology' ],
92     '200' => [ '1#^aPsychology^fCamille B. Wortman, Elizabeth F. Loftus, Mary E. Marshal' ],
93     } ];
94    
95 dpavlin 22 foreach my $mfn (1 .. $isis->{'maxmfn'}) {
96 dpavlin 21 my $rec;
97     ok($rec = $isis->fetch($mfn), "fetch $mfn");
98    
99     foreach my $f (keys %{$data->[$mfn-1]}) {
100     my $i = 0;
101     foreach my $v (@{$data->[$mfn-1]->{$f}}) {
102     $v =~ s/^[01# ][01# ]// if ($args->{no_ident});
103 dpavlin 25 cmp_ok($v, '==', $rec->{$f}->[$i], "MFN $mfn $f:$i $v");
104 dpavlin 21 $i++;
105     }
106     }
107     }
108    
109 dpavlin 22 # test to_ascii
110    
111     SKIP: {
112     eval "use Digest::MD5 qw(md5_hex)";
113    
114     skip "no Digest::MD5 module", 5 if ($@);
115    
116     foreach my $mfn (1 .. $isis->{'maxmfn'}) {
117     my $md5 = md5_hex($isis->to_ascii($mfn));
118 dpavlin 25 cmp_ok($md5, 'eq', $args->{md5_ascii}[$mfn - 1], "md5 $mfn");
119 dpavlin 22 }
120     }
121    
122 dpavlin 19 }
123    
124     $isis = IsisDB->new (
125     isisdb => './data/winisis/BIBL',
126 dpavlin 25 include_deleted => 1,
127 dpavlin 19 );
128    
129     print Dumper($isis);
130    
131 dpavlin 22 test_data(
132     no_ident => 1,
133     md5_ascii => [ qw(
134     a369eff702307ba12eb81656ee0587fe
135     4fb38537a94f3f5954e40d9536b942b0
136 dpavlin 25 579a7c6901c654bdeac10547a98e5b71
137 dpavlin 22 7d2adf1675c83283aa9b82bf343e3d85
138     daf2cf86ca7e188e8360a185f3b43423
139     ) ],
140     );
141 dpavlin 19
142     $isis = IsisDB->new (
143     isisdb => './data/isismarc/BIBL',
144 dpavlin 25 include_deleted => 1,
145 dpavlin 19 );
146    
147 dpavlin 22 test_data(
148     md5_ascii => [ qw(
149     f5587d9bcaa54257a98fe27d3c17a0b6
150     3be9a049f686f2a36af93a856dcae0f2
151     3961be5e3ba8fb274c89c08d18df4bcc
152     5f73ec00d08af044a2c4105f7d889e24
153     843b9ebccf16a498fba623c78f21b6c0
154     ) ],
155     );
156 dpavlin 25
157     # check logically deleted
158    
159     $isis = IsisDB->new (
160     isisdb => './data/winisis/BIBL',
161     include_deleted => 1,
162     );
163    
164     ok($isis->fetch(3), "deleted found");
165     cmp_ok($isis->{deleted}, '==', 3, "MFN 3 is deleted");
166    
167     $isis = IsisDB->new (
168     isisdb => './data/winisis/BIBL',
169     );
170    
171     ok(! $isis->fetch(3), "deleted not found");
172     cmp_ok($isis->{deleted}, '==', 3, "MFN 3 is deleted");
173    

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.26