/[webpac2]/trunk/t/1-validate.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/1-validate.t

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

revision 858 by dpavlin, Sun May 27 17:09:47 2007 UTC revision 862 by dpavlin, Sun May 27 19:28:18 2007 UTC
# Line 1  Line 1 
1  #!/usr/bin/perl -w  #!/usr/bin/perl -w
2    
3  use strict;  use strict;
4  use Test::More tests => 51;  use Test::More tests => 54;
5  use Test::Exception;  use Test::Exception;
6  use blib;  use blib;
7    
# Line 18  ok(my $abs_path = abs_path($0), "abs_pat Line 18  ok(my $abs_path = abs_path($0), "abs_pat
18  $abs_path =~ s#/[^/]*$#/#;  $abs_path =~ s#/[^/]*$#/#;
19    
20  ok(my $v = new WebPAC::Validate(  ok(my $v = new WebPAC::Validate(
21          path => "$abs_path/data/validate_test_simple",          debug => $debug,
22    ), "new witout path");
23    
24    ok( ! $v->{rules}, 'no path' );
25    
26    ok(my $v = new WebPAC::Validate(
27            path => "$abs_path/data/validate_test",
28          debug => $debug,          debug => $debug,
29  ), "new with path");  ), "new with path");
30    
31  ok($v->{rules}, "rules exist");  ok($v->{rules}, "rules exist");
32    
33  is_deeply( $v->{rules}, {  is_deeply( $v->{rules}, {
34          '900' => [ 'a', 'b', 'c', 'd' ],          '900' => 1,
35            '901' => [ 'a' ],
36            '902' => [ 'b', 'c' ],
37            '903' => [ 'a', 'b', 'c' ],
38            '904' => [ 'a' ],
39            '905' => [ 'a*' ],
40  }, 'simple rules parsed');  }, 'simple rules parsed');
41    
42  ok($v = new WebPAC::Validate(  diag dump( $v ) if ( $debug );
         debug => $debug,  
 ), "new witout path");  
43    
44  ok( ! $v->{rules}, 'no path' );  ok( $v->read_validate_file( "$abs_path/data/validate_test_simple" ), "read_validate_file" );
45    
46  ok( $v->read_validate_file( "$abs_path/data/validate_test" ), "read_validate_file" );  diag dump( $v ) if ( $debug );
47    
48  ok($v->{rules}, "rules exist");  ok($v->{rules}, "rules exist");
49    
50  is_deeply( $v->{rules}, {  is_deeply( $v->{rules}, {
51            '900' => [ 'a', 'b', 'c', 'd' ],
52    }, 'rules parsed');
53    
54    ok( $v->read_validate_file( "$abs_path/data/validate_test" ), "read_validate_file" );
55    
56    is_deeply( $v->{rules}, {
57          '900' => 1,          '900' => 1,
58          '901' => [ 'a' ],          '901' => [ 'a' ],
59          '902' => [ 'b', 'c' ],          '902' => [ 'b', 'c' ],
60          '903' => [ 'a', 'b', 'c' ],          '903' => [ 'a', 'b', 'c' ],
61          '904' => [ 'a' ],          '904' => [ 'a' ],
62          '905' => [ 'a*' ],          '905' => [ 'a*' ],
63  }, 'rules parsed');  }, 'rules');
64    
65    ok($v->{rules}, "rules exist");
66    
67  throws_ok { $v->validate_rec() } qr/rec/, "validate_rec need rec";  throws_ok { $v->validate_rec() } qr/rec/, "validate_rec need rec";
68    
# Line 173  $expected_error, 'validate without subfi Line 189  $expected_error, 'validate without subfi
189    
190  ok(my $r1 = $v->report, 'report');  ok(my $r1 = $v->report, 'report');
191    
192    diag "report: $r1" if ( $debug );
193    
194  is_deeply(  is_deeply(
195          test_v({          test_v({
196                  '900' => 'foo',                  '900' => 'foo',
# Line 184  is_deeply( Line 202  is_deeply(
202          }, undef),          }, undef),
203  $expected_error, 'validate with subfields');  $expected_error, 'validate with subfields');
204    
   
205  ok(my $r2 = $v->report, 'report');  ok(my $r2 = $v->report, 'report');
206    
207  cmp_ok($r1, 'eq', $r2, 'subfields same as non-subfields');  cmp_ok($r1, 'eq', $r2, 'subfields same as non-subfields');

Legend:
Removed from v.858  
changed lines
  Added in v.862

  ViewVC Help
Powered by ViewVC 1.1.26