/[MARC-Fast]/trunk/t/001_marc.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/001_marc.t

Parent Directory Parent Directory | Revision Log Revision Log


Revision 11 - (show annotations)
Fri Nov 3 20:34:31 2006 UTC (17 years, 5 months ago) by dpavlin
File MIME type: application/x-troff
File size: 1200 byte(s)
added to_ascii to be more like Biblio::ISIS API [0.05]

1 #!/usr/bin/perl -w
2
3 use strict;
4 use blib;
5
6 use Test::More tests => 40;
7 use Test::Exception;
8 use Data::Dump qw/dump/;
9
10 BEGIN { use_ok( 'MARC::Fast' ); }
11
12 my $debug = shift @ARGV;
13
14 my $marc;
15 my %param;
16
17 throws_ok { $marc = MARC::Fast->new(%param); } qr/marcdb/, "marcdb parametar";
18
19 $param{marcdb} = '/foo/bar/file';
20
21 throws_ok { $marc = MARC::Fast->new(%param); } qr/foo.bar/, "marcdb exist";
22
23 $param{marcdb} = 'data/unimarc.iso';
24
25 SKIP: {
26 skip "no $param{marcdb} test file ", 17 unless (-e $param{marcdb});
27
28 ok($marc = MARC::Fast->new(%param), "new");
29
30 isa_ok ($marc, 'MARC::Fast');
31
32 #diag Dumper($marc);
33
34 cmp_ok($marc->count, '==', scalar @{$marc->{leaders}}, "count == leaders");
35 cmp_ok($marc->count, '==', scalar @{$marc->{fh_offset}}, "count == fh_offset");
36
37 ok(! $marc->fetch(0), "fetch 0");
38 ok($marc->fetch($marc->count), "fetch max:".$marc->count);
39 ok(! $marc->fetch($marc->count + 1), "fetch max+1:".($marc->count+1));
40
41 foreach (1 .. 10) {
42 ok($marc->fetch($_), "fetch $_");
43
44 ok(my $hash = $marc->to_hash($_), "to_hash $_");
45 diag "to_hash($_) = ",dump($hash) if ($debug);
46 ok(my $ascii = $marc->to_ascii($_), "to_ascii $_");
47 diag "to_ascii($_) ::\n$ascii" if ($debug);
48 }
49 }

Properties

Name Value
svn:executable

  ViewVC Help
Powered by ViewVC 1.1.26