/[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 514 by dpavlin, Tue May 16 13:38:09 2006 UTC revision 515 by dpavlin, Tue May 16 15:23:05 2006 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 => 5;  use Test::More tests => 16;
5  use Test::Exception;  use Test::Exception;
6  use blib;  use blib;
7    
# Line 24  ok(my $v = new WebPAC::Validate( Line 24  ok(my $v = new WebPAC::Validate(
24  ), "new");  ), "new");
25    
26  ok($v->{rules}, "rules exist");  ok($v->{rules}, "rules exist");
27    
28    is_deeply( $v->{rules}, {
29            '900' => 1,
30            '901' => [ 'a' ],
31            '902' => [ 'b', 'c' ],
32            '903' => [ 'a', 'b', 'c' ],
33    }, 'rules parsed');
34    
35    throws_ok { $v->validate_errors() } qr/rec/, "validate_rec need rec";
36    
37    ok($v->validate_errors({ '900' => 'foo' }), '900 garbage input');
38    
39    ok(! $v->validate_errors({
40            '900' => [ qw/foo bar baz/ ]
41    }), '900 no sf');
42    
43    ok($v->validate_errors({
44            '901' => [ qw/foo bar baz/ ]
45    }), '901 no sf');
46    
47    ok(! $v->validate_errors({
48            '901' => [ { 'a' => 42 } ]
49    }), '901^a');
50    
51    ok($v->validate_errors({
52            '901' => [ { 'b' => 42 } ]
53    }), '901^b');
54    
55    ok(! $v->validate_errors({
56            '902' => [ { 'b' => 1 }, { 'c' => 2 } ]
57    }), '902^b 902^c');
58    
59    ok($v->validate_errors({
60            '902' => [ { 'a' => 0 }, { 'b' => 1 }, { 'c' => 2 } ]
61    }), '902^a 902^b 902^c');
62    
63    ok(! $v->validate_errors({
64            '903' => [ { 'a' => 0 }, { 'b' => 1 }, { 'c' => 2 } ]
65    }), '903^a 903^b 903^c');
66    
67    ok($v->validate_errors({
68            '903' => [ { 'a' => 0 }, { 'b' => 1 }, { 'c' => 2 }, { 'd' => 3 } ]
69    }), '903^a 903^b 903^c 903^d');

Legend:
Removed from v.514  
changed lines
  Added in v.515

  ViewVC Help
Powered by ViewVC 1.1.26