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

Diff of /trunk/t/001_marc.t

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 21 by dpavlin, Mon Oct 29 22:41:21 2007 UTC revision 29 by dpavlin, Thu Feb 4 12:54:00 2010 UTC
# Line 3  Line 3 
3  use strict;  use strict;
4  use blib;  use blib;
5    
6  use Test::More tests => 53;  use Test::More tests => 63;
7  use Test::Exception;  use Data::Dump qw/dump/;
8    
9  BEGIN {  BEGIN {
10          use_ok( 'MARC::Fast' );          use_ok( 'MARC::Fast' );
# Line 14  my $debug = shift @ARGV; Line 14  my $debug = shift @ARGV;
14    
15  my $marc_file = 't/camel.usmarc';  my $marc_file = 't/camel.usmarc';
16    
 if ( $debug ) {  
         eval { require Data::Dump; };  
         $debug = 0 if ($@);  
 }  
   
17  my $marc;  my $marc;
18  my %param;  my %param;
19    
20  throws_ok { $marc = MARC::Fast->new(%param); } qr/marcdb/, "marcdb parametar";  eval { $marc = MARC::Fast->new(%param) };
21    ok( $@ =~ /marcdb/, "marcdb parametar" );
22    
23  $param{marcdb} = '/foo/bar/file';  $param{marcdb} = '/foo/bar/file';
24    
25  throws_ok { $marc = MARC::Fast->new(%param); } qr/foo.bar/, "marcdb exist";  eval { $marc = MARC::Fast->new(%param) };
26    ok( $@ =~ /foo.bar/, "marcdb exist" );
27    
28  $param{marcdb} = $marc_file if -e $marc_file;  $param{marcdb} = $marc_file if -e $marc_file;
29    
# Line 50  SKIP: { Line 47  SKIP: {
47          ok(! $marc->fetch($marc->count + 1), "fetch max+1:".($marc->count+1));          ok(! $marc->fetch($marc->count + 1), "fetch max+1:".($marc->count+1));
48    
49          foreach (1 .. 10) {          foreach (1 .. 10) {
50                  ok($marc->fetch($_), "fetch $_");                  ok($marc->fetch($_), "fetch($_)");
51    
52                  ok($marc->last_leader, "last_leader $_");                  ok($marc->last_leader, "last_leader $_");
53    
54                  ok(my $hash = $marc->to_hash($_), "to_hash $_");                  ok(my $hash = $marc->to_hash($_), "to_hash($_)");
55                  diag "to_hash($_) = ",Data::Dump::dump($hash) if ($debug);                  diag "to_hash($_) = ",Data::Dump::dump($hash) if ($debug);
56                  ok(my $ascii = $marc->to_ascii($_), "to_ascii $_");  
57                    ok(my $hash_sf = $marc->to_hash($_, include_subfields => 1), "to_hash($_,include_subfields)");
58                    diag "to_hash($_, include_subfields => 1) = ",Data::Dump::dump($hash_sf) if ($debug);
59    
60                    ok(my $ascii = $marc->to_ascii($_), "to_ascii($_)");
61                  diag "to_ascii($_) ::\n$ascii" if ($debug);                  diag "to_ascii($_) ::\n$ascii" if ($debug);
62          }          }
63    
64          ok(! $marc->fetch(0), "fetch 0 again");          ok(! $marc->fetch(0), "fetch(0) again");
65          ok(! $marc->last_leader, "no last_leader");          ok(! $marc->last_leader, "no last_leader");
66  }  }

Legend:
Removed from v.21  
changed lines
  Added in v.29

  ViewVC Help
Powered by ViewVC 1.1.26