/[webpac2]/trunk/t/3-normalize.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/3-normalize.t

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

revision 791 by dpavlin, Tue Jan 30 18:21:17 2007 UTC revision 819 by dpavlin, Wed Apr 11 10:09:34 2007 UTC
# Line 2  Line 2 
2    
3  use strict;  use strict;
4    
5  use Test::More tests => 322;  use Test::More tests => 341;
6  use Test::Exception;  use Test::Exception;
7  use Cwd qw/abs_path/;  use Cwd qw/abs_path/;
8  use blib;  use blib;
# Line 191  sub test_s { Line 191  sub test_s {
191    
192          # simple list manipulatons          # simple list manipulatons
193          cmp_ok( join('', prefix('ab', 'cd') ), 'eq', 'abcd', 'prefix');          cmp_ok( join('', prefix('ab', 'cd') ), 'eq', 'abcd', 'prefix');
194            cmp_ok( join('-', prefix('', 'x', 'y') ), 'eq', 'x-y', 'prefix empty');
195            cmp_ok( join('-', prefix(0, 'x', 'y') ), 'eq', '0x-0y', 'prefix 0');
196    
197          cmp_ok( join('', suffix('xy', 'cd') ), 'eq', 'cdxy', 'suffix');          cmp_ok( join('', suffix('xy', 'cd') ), 'eq', 'cdxy', 'suffix');
198            cmp_ok( join('-', suffix('', 'x', 'y' ) ), 'eq', 'x-y', 'suffix empty');
199            cmp_ok( join('-', suffix(0, 'x', 'y' ) ), 'eq', 'x0-y0', 'suffix 0');
200    
201          cmp_ok( join('', surround('->', '<-', 'a','b','c') ), 'eq', '->a<-->b<-->c<-', 'surround');          cmp_ok( join('', surround('->', '<-', 'a','b','c') ), 'eq', '->a<-->b<-->c<-', 'surround');
202            cmp_ok( join('-', surround('', '', 'x','y','z') ), 'eq', 'x-y-z', 'surround empty');
203            cmp_ok( join('-', surround(0, 0, 'x','y','z') ), 'eq', '0x0-0y0-0z0', 'surround 0 0');
204    
205          # count          # count
206          my @el;          my @el;
# Line 207  sub test_s { Line 215  sub test_s {
215    
216          ok(_set_load_row(sub {          ok(_set_load_row(sub {
217                  my ($database,$input,$mfn) = @_;                  my ($database,$input,$mfn) = @_;
218                  diag "load_row( $database, $input, $mfn )";                  diag "load_row( $database, $input, $mfn )" if ($debug);
219                  cmp_ok( $#_, '==', 2, 'have 3 arguments');                  cmp_ok( $#_, '==', 2, 'have 3 arguments');
220                  ok($database, '_load_row database');                  ok($database, '_load_row database');
221                  ok($input, '_load_row input');                  ok($input, '_load_row input');
# Line 236  sub test_s { Line 244  sub test_s {
244                  );                  );
245    
246                  ok(my $l = WebPAC::Normalize::_get_lookup(), '_get_lookup');                  ok(my $l = WebPAC::Normalize::_get_lookup(), '_get_lookup');
247                  diag "_get_lookup = ", dump($l);                  diag "_get_lookup = ", dump($l) if ($debug);
248    
249                  my @lookup;                  my @lookup;
250    
251                  ok(@lookup = lookup(                  ok(@lookup = lookup(
252                                  sub {                                  sub {
253                                          diag "in show";                                          diag "in show" if ($debug);
254                                          rec('900','x');                                          rec('900','x');
255                                  },                                  },
256                                  'db','input','key',                                  'db','input','key',
# Line 261  sub test_s { Line 269  sub test_s {
269          }          }
270    
271          ok(my $l = WebPAC::Normalize::_get_lookup(), '_get_lookup');          ok(my $l = WebPAC::Normalize::_get_lookup(), '_get_lookup');
272          diag "_get_lookup = ", dump($l);          diag "_get_lookup = ", dump($l) if ($debug);
273    
274          is_deeply( $l, {          is_deeply( $l, {
275                  db => {                  db => {
# Line 281  sub test_s { Line 289  sub test_s {
289    
290  #######  #######
291    
292          diag "lookup_hash1 = ", dump($lookup_hash1);          diag "lookup_hash1 = ", dump($lookup_hash1) if ($debug);
293          ok(_set_lookup( $lookup_hash1 ), '_set_lookup $lookup_hash1');          ok(_set_lookup( $lookup_hash1 ), '_set_lookup $lookup_hash1');
294    
295          throws_ok { _set_load_row() } qr/CODE/, 'empty _set_load_row()';          throws_ok { _set_load_row() } qr/CODE/, 'empty _set_load_row()';
# Line 740  sub test_s { Line 748  sub test_s {
748                  'marc_duplicate',                  'marc_duplicate',
749                  { '200' => [{ a => 42, b => 'bar', c => 'baz', d => 'bing', e => 'bong' }] },                  { '200' => [{ a => 42, b => 'bar', c => 'baz', d => 'bing', e => 'bong' }] },
750                  qq{                  qq{
751                            marc_leader('06',42);
752                            marc_leader('11',0);
753                          marc('900', 'a', rec('200','a') );                          marc('900', 'a', rec('200','a') );
754                          marc('900', 'b', rec('200','b') );                          marc('900', 'b', rec('200','b') );
755                          marc_duplicate;                          marc_duplicate;
756                            marc_leader('11',1);
757                          marc_remove('900','b');                          marc_remove('900','b');
758                          marc('900', 'b', rec('200','c') );                          marc('900', 'b', rec('200','c') );
759                          marc_duplicate;                          marc_duplicate;
760                            marc_leader('11',2);
761                          marc_remove('900','b');                          marc_remove('900','b');
762                          marc('900', 'b', rec('200','d') );                          marc('900', 'b', rec('200','d') );
763                          marc_duplicate;                          marc_duplicate;
764                            marc_leader('11',3);
765                          marc_remove('900','b');                          marc_remove('900','b');
766                          marc('900', 'b', rec('200','e') );                          marc('900', 'b', rec('200','e') );
767                  },                  },
# Line 758  sub test_s { Line 771  sub test_s {
771                  ],                  ],
772          );          );
773    
774            cmp_ok( marc_count(), '==', 3, 'marc_count' );
775    
776          my $i = 0;          my $i = 0;
777          foreach my $v ( qw/bar baz bing bong/ ) {          foreach my $v ( qw/bar baz bing bong/ ) {
778    
# Line 769  sub test_s { Line 784  sub test_s {
784                          [ [ '900', ' ', ' ', 'a', 42, 'b', $v ] ],                          [ [ '900', ' ', ' ', 'a', 42, 'b', $v ] ],
785                          "MARC copy $i has $v",                          "MARC copy $i has $v",
786                  );                  );
787                    is_deeply(WebPAC::Normalize::_get_marc_leader(), { '06' => 42, 11 => $i }, "_get_marc_leader copy $i");
788                  $i++;                  $i++;
789          }          }
790    
# Line 827  sub test_s { Line 843  sub test_s {
843                  '^aa1^bb1^aa2^bb2^cc1^cc2',                  '^aa1^bb1^aa2^bb2^cc1^cc2',
844                  '_pack_subfields_hash( $h, 1 )'                  '_pack_subfields_hash( $h, 1 )'
845          );          );
846    
847            _clean_ds();
848            test_s(qq{
849                    marc_fixed('008', 0, 'abcdef');
850                    marc_fixed('000', 5, '5');
851                    marc_fixed('000', 10, 'A');
852                    marc_fixed('000', 0, '0');
853            });
854            ok( my $m = WebPAC::Normalize::_get_marc_fields(), '_get_marc_fields');
855            diag dump( $m );
856            is_deeply( WebPAC::Normalize::_get_marc_fields(),
857                    [
858                            ["008", "abcdef"],
859                            #        0....5....10
860                            ["000", "0    5    A"]
861                    ]
862            );
863  }  }
864    

Legend:
Removed from v.791  
changed lines
  Added in v.819

  ViewVC Help
Powered by ViewVC 1.1.26