/[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 36 - (show annotations)
Thu Jan 6 20:48:07 2005 UTC (19 years, 2 months ago) by dpavlin
File MIME type: application/x-troff
File size: 3831 byte(s)
renamed module to Biblio::Isis

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

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.26