/[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 26 - (hide annotations)
Mon Nov 19 16:37:00 2007 UTC (16 years, 5 months ago) by dpavlin
File MIME type: application/x-troff
File size: 1655 byte(s)
use Data::Dump for nicer (shorter/more readable) output instead of
Data::Dumper
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 dpavlin 26 use Data::Dump qw/dump/;
9 dpavlin 1
10 dpavlin 16 BEGIN {
11     use_ok( 'MARC::Fast' );
12     }
13 dpavlin 1
14 dpavlin 11 my $debug = shift @ARGV;
15 dpavlin 21
16     my $marc_file = 't/camel.usmarc';
17    
18 dpavlin 1 my $marc;
19     my %param;
20    
21     throws_ok { $marc = MARC::Fast->new(%param); } qr/marcdb/, "marcdb parametar";
22    
23     $param{marcdb} = '/foo/bar/file';
24    
25     throws_ok { $marc = MARC::Fast->new(%param); } qr/foo.bar/, "marcdb exist";
26    
27 dpavlin 21 $param{marcdb} = $marc_file if -e $marc_file;
28 dpavlin 1
29 dpavlin 2 SKIP: {
30 dpavlin 13 skip "no $param{marcdb} test file ", 37 unless (-e $param{marcdb});
31 dpavlin 1
32 dpavlin 21 diag "marc file: $marc_file";
33    
34 dpavlin 2 ok($marc = MARC::Fast->new(%param), "new");
35 dpavlin 1
36 dpavlin 2 isa_ok ($marc, 'MARC::Fast');
37 dpavlin 1
38 dpavlin 9 #diag Dumper($marc);
39    
40 dpavlin 18 cmp_ok($marc->count, '==', scalar @{$marc->{leader}}, "count == leader");
41 dpavlin 2 cmp_ok($marc->count, '==', scalar @{$marc->{fh_offset}}, "count == fh_offset");
42 dpavlin 1
43 dpavlin 2 ok(! $marc->fetch(0), "fetch 0");
44 dpavlin 18 ok(! $marc->last_leader, "no last_leader");
45 dpavlin 2 ok($marc->fetch($marc->count), "fetch max:".$marc->count);
46     ok(! $marc->fetch($marc->count + 1), "fetch max+1:".($marc->count+1));
47    
48     foreach (1 .. 10) {
49 dpavlin 23 ok($marc->fetch($_), "fetch($_)");
50 dpavlin 9
51 dpavlin 18 ok($marc->last_leader, "last_leader $_");
52    
53 dpavlin 23 ok(my $hash = $marc->to_hash($_), "to_hash($_)");
54 dpavlin 16 diag "to_hash($_) = ",Data::Dump::dump($hash) if ($debug);
55 dpavlin 23
56     ok(my $hash_sf = $marc->to_hash($_, include_subfields => 1), "to_hash($_,include_subfields)");
57     diag "to_hash($_, include_subfields => 1) = ",Data::Dump::dump($hash_sf) if ($debug);
58    
59     ok(my $ascii = $marc->to_ascii($_), "to_ascii($_)");
60 dpavlin 11 diag "to_ascii($_) ::\n$ascii" if ($debug);
61 dpavlin 2 }
62 dpavlin 18
63 dpavlin 23 ok(! $marc->fetch(0), "fetch(0) again");
64 dpavlin 18 ok(! $marc->last_leader, "no last_leader");
65 dpavlin 1 }

Properties

Name Value
svn:executable

  ViewVC Help
Powered by ViewVC 1.1.26