/[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 25 - (hide annotations)
Fri Dec 31 05:43:20 2004 UTC (17 years, 11 months ago) by dpavlin
File MIME type: application/x-troff
File size: 3656 byte(s)
major improvments and new version:
- implement logically deleted records (really!)
- re-ordered values tests using cmp_ok so that reporting is correct,
- return record in fetch even if it's in memory (bugfix)
- removed some obsolete code

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

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.26