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

Annotation of /trunk/t/001_marc.t

Parent Directory Parent Directory | Revision Log Revision Log


Revision 23 - (hide annotations)
Sun Nov 4 22:44:42 2007 UTC (16 years, 5 months ago) by dpavlin
File MIME type: application/x-troff
File size: 1701 byte(s)
much more sane implementation of to_hash which now include
option include_subfields just like Biblio::Isis does. [0.09]
1 dpavlin 1 #!/usr/bin/perl -w
2    
3     use strict;
4     use blib;
5    
6 dpavlin 23 use Test::More tests => 63;
7 dpavlin 1 use Test::Exception;
8    
9 dpavlin 16 BEGIN {
10     use_ok( 'MARC::Fast' );
11     }
12 dpavlin 1
13 dpavlin 11 my $debug = shift @ARGV;
14 dpavlin 21
15     my $marc_file = 't/camel.usmarc';
16    
17 dpavlin 16 if ( $debug ) {
18     eval { require Data::Dump; };
19     $debug = 0 if ($@);
20     }
21 dpavlin 11
22 dpavlin 1 my $marc;
23     my %param;
24    
25     throws_ok { $marc = MARC::Fast->new(%param); } qr/marcdb/, "marcdb parametar";
26    
27     $param{marcdb} = '/foo/bar/file';
28    
29     throws_ok { $marc = MARC::Fast->new(%param); } qr/foo.bar/, "marcdb exist";
30    
31 dpavlin 21 $param{marcdb} = $marc_file if -e $marc_file;
32 dpavlin 1
33 dpavlin 2 SKIP: {
34 dpavlin 13 skip "no $param{marcdb} test file ", 37 unless (-e $param{marcdb});
35 dpavlin 1
36 dpavlin 21 diag "marc file: $marc_file";
37    
38 dpavlin 2 ok($marc = MARC::Fast->new(%param), "new");
39 dpavlin 1
40 dpavlin 2 isa_ok ($marc, 'MARC::Fast');
41 dpavlin 1
42 dpavlin 9 #diag Dumper($marc);
43    
44 dpavlin 18 cmp_ok($marc->count, '==', scalar @{$marc->{leader}}, "count == leader");
45 dpavlin 2 cmp_ok($marc->count, '==', scalar @{$marc->{fh_offset}}, "count == fh_offset");
46 dpavlin 1
47 dpavlin 2 ok(! $marc->fetch(0), "fetch 0");
48 dpavlin 18 ok(! $marc->last_leader, "no last_leader");
49 dpavlin 2 ok($marc->fetch($marc->count), "fetch max:".$marc->count);
50     ok(! $marc->fetch($marc->count + 1), "fetch max+1:".($marc->count+1));
51    
52     foreach (1 .. 10) {
53 dpavlin 23 ok($marc->fetch($_), "fetch($_)");
54 dpavlin 9
55 dpavlin 18 ok($marc->last_leader, "last_leader $_");
56    
57 dpavlin 23 ok(my $hash = $marc->to_hash($_), "to_hash($_)");
58 dpavlin 16 diag "to_hash($_) = ",Data::Dump::dump($hash) if ($debug);
59 dpavlin 23
60     ok(my $hash_sf = $marc->to_hash($_, include_subfields => 1), "to_hash($_,include_subfields)");
61     diag "to_hash($_, include_subfields => 1) = ",Data::Dump::dump($hash_sf) if ($debug);
62    
63     ok(my $ascii = $marc->to_ascii($_), "to_ascii($_)");
64 dpavlin 11 diag "to_ascii($_) ::\n$ascii" if ($debug);
65 dpavlin 2 }
66 dpavlin 18
67 dpavlin 23 ok(! $marc->fetch(0), "fetch(0) again");
68 dpavlin 18 ok(! $marc->last_leader, "no last_leader");
69 dpavlin 1 }

Properties

Name Value
svn:executable

  ViewVC Help
Powered by ViewVC 1.1.26