/[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 811 by dpavlin, Sun Apr 1 21:47:40 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 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.811  
changed lines
  Added in v.819

  ViewVC Help
Powered by ViewVC 1.1.26