/[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

Contents of /trunk/t/002_isis.t

Parent Directory Parent Directory | Revision Log Revision Log


Revision 32 - (show annotations)
Wed Jan 5 15:46:26 2005 UTC (17 years, 5 months ago) by dpavlin
File MIME type: application/x-troff
File size: 3734 byte(s)
new api version
- added count method (instead of calling maxmfn directly in object)
- added POD coverage test
- moved unpack_cnt to be separate method and document it

1 #!/usr/bin/perl -w
2
3 use strict;
4 use blib;
5
6 use Data::Dumper;
7
8 use Test::More tests => 110;
9
10 BEGIN { use_ok( 'IsisDB' ); }
11
12 my $isis;
13
14 sub test_data {
15
16 my $args = {@_};
17
18 isa_ok ($isis, 'IsisDB');
19
20 cmp_ok($isis->count, '==', 5, "count is 5");
21
22 # test .CNT data
23
24 SKIP: {
25 skip "no CNT file for this database", 5 unless $isis->{cnt_file};
26
27 ok(my $isis_cnt = $isis->read_cnt, "read_cnt");
28
29 cmp_ok(scalar keys %{$isis_cnt}, '==', 2, "returns 2 elements");
30
31 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 cmp_ok($isis_cnt->{$c}->{$kn}, '==', $cnt->{$c}->{$kn}, "cnt $c $kn same");
59 }
60 }
61 }
62
63 # 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 foreach my $mfn (1 .. $isis->count) {
96 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 cmp_ok($v, '==', $rec->{$f}->[$i], "MFN $mfn $f:$i $v");
104 $i++;
105 }
106 }
107 }
108
109 # 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->count) {
117 my $md5 = md5_hex($isis->to_ascii($mfn));
118 cmp_ok($md5, 'eq', $args->{md5_ascii}[$mfn - 1], "md5 $mfn");
119 }
120 }
121
122 }
123
124 $isis = IsisDB->new (
125 isisdb => './data/winisis/BIBL',
126 include_deleted => 1,
127 );
128
129 print Dumper($isis);
130
131 test_data(
132 no_ident => 1,
133 md5_ascii => [ qw(
134 a369eff702307ba12eb81656ee0587fe
135 4fb38537a94f3f5954e40d9536b942b0
136 579a7c6901c654bdeac10547a98e5b71
137 7d2adf1675c83283aa9b82bf343e3d85
138 daf2cf86ca7e188e8360a185f3b43423
139 ) ],
140 );
141
142 $isis = IsisDB->new (
143 isisdb => './data/isismarc/BIBL',
144 include_deleted => 1,
145 );
146
147 test_data(
148 md5_ascii => [ qw(
149 f5587d9bcaa54257a98fe27d3c17a0b6
150 3be9a049f686f2a36af93a856dcae0f2
151 3961be5e3ba8fb274c89c08d18df4bcc
152 5f73ec00d08af044a2c4105f7d889e24
153 843b9ebccf16a498fba623c78f21b6c0
154 ) ],
155 );
156
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