/[webpac2]/trunk/t/2-input.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/2-input.t

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

revision 507 by dpavlin, Mon May 15 13:15:01 2006 UTC revision 599 by dpavlin, Thu Jul 13 13:55:19 2006 UTC
# Line 1  Line 1 
1  #!/usr/bin/perl -w  #!/usr/bin/perl -w
2    
3  use Test::More tests => 62;  use Test::More tests => 68;
4  use Test::Exception;  use Test::Exception;
5  use Cwd qw/abs_path/;  use Cwd qw/abs_path/;
6  use blib;  use blib;
# Line 30  throws_ok { $input->open( ) } qr/path/, Line 30  throws_ok { $input->open( ) } qr/path/,
30    
31  throws_ok { $input->open( path => '/dev/null', ) } qr/can't find database/ , "open";  throws_ok { $input->open( path => '/dev/null', ) } qr/can't find database/ , "open";
32    
33  ok($input->open( path => "$abs_path/winisis/BIBL" ), "open");  ok($input->open( path => "$abs_path/winisis/BIBL" ), "open winisis");
34  ok($input_lm->open( path => "$abs_path/winisis/BIBL", low_mem => 1 ), "open");  ok($input_lm->open( path => "$abs_path/winisis/BIBL", low_mem => 1 ), "open winisis");
35    
36  sub test_after_open($) {  sub test_after_open($) {
37          my $input = shift;          my $input = shift;
# Line 68  sub test_start_limit($$$$) { Line 68  sub test_start_limit($$$$) {
68    
69          diag "offset $s, limit: $l, expected: $e";          diag "offset $s, limit: $l, expected: $e";
70    
71          ok($s = $input->open( path => "$abs_path/winisis/BIBL", offset => $s, limit => $l, debug => 1 ), "open");          ok($s = $input->open( path => "$abs_path/winisis/BIBL", offset => $s, limit => $l, debug => 1 ), "open winisis");
72          cmp_ok($s, '==', $size, "db size from open = $size");          cmp_ok($s, '==', $size, "db size from open = $size");
73          cmp_ok($input->size, '==', $e, "input->size = $e");          cmp_ok($input->size, '==', $e, "input->size = $e");
74  }  }
# Line 86  diag "testing with $module"; Line 86  diag "testing with $module";
86    
87  ok($input = new WebPAC::Input( module => $module, low_mem => 1, no_log => $no_log, no_progress_bar => 1 ), "new $module");  ok($input = new WebPAC::Input( module => $module, low_mem => 1, no_log => $no_log, no_progress_bar => 1 ), "new $module");
88    
89  ok($input->open( path => "$abs_path/data/marc.iso" ), "open");  ok($input->open( path => "$abs_path/data/marc.iso" ), "open marc.iso");
90    
91  test_after_open($input);  test_after_open($input);
92    
93  test_fetch($input, $input->size);  test_fetch($input, $input->size);
94    
95    # test modify_record
96    $module = 'WebPAC::Input::ISIS';
97    ok($input = new WebPAC::Input( module => $module, no_log => $no_log, no_progress_bar => 1 ), "new $module");
98    
99    ok($input->open( path => "$abs_path/modify_isis/LIBRI",), "open modify_isis (plain)");
100    ok(my $rec_p = $input->fetch, 'fetch');
101    
102    ok($input->open(
103            path => "$abs_path/modify_isis/LIBRI",
104            modify_records => {
105                    200 => {
106                            '*' => { '^c' => '. ' },
107                    }
108            },
109    ), "open modify_isis (with modify_records)");
110    
111    ok(my $rec = $input->fetch, 'fetch');
112    
113    cmp_ok($rec_p->{200}->[0]->{f} . '. ' . $rec_p->{200}->[0]->{c}, 'eq' ,$rec->{200}->[0]->{f}, 'modify_records working');

Legend:
Removed from v.507  
changed lines
  Added in v.599

  ViewVC Help
Powered by ViewVC 1.1.26