/[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 18 - (show annotations)
Mon Oct 29 22:33:35 2007 UTC (16 years, 5 months ago) by dpavlin
File MIME type: application/x-troff
File size: 1433 byte(s)
added $marc->last_leader which returns leader of
last record accessed with $marc->fetch
bump version to [0.08]

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

Properties

Name Value
svn:executable

  ViewVC Help
Powered by ViewVC 1.1.26