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

Annotation of /trunk/t/1-lookup.t

Parent Directory Parent Directory | Revision Log Revision Log


Revision 12 - (hide annotations)
Sat Jul 16 22:57:26 2005 UTC (18 years, 10 months ago) by dpavlin
File MIME type: application/x-troff
File size: 1073 byte(s)
improvements to WebPAC::Normalize::XML

1 dpavlin 3 #!/usr/bin/perl -w
2    
3 dpavlin 4 use strict;
4 dpavlin 12 use Test::More tests => 16;
5 dpavlin 3 use Test::Exception;
6     use blib;
7    
8 dpavlin 4 use Data::Dumper;
9    
10 dpavlin 3 BEGIN {
11 dpavlin 4 use_ok( 'WebPAC::Lookup' );
12 dpavlin 3 }
13    
14 dpavlin 4 throws_ok { new WebPAC::Lookup() } qr/lookup_file/, "new without lookup_file";
15 dpavlin 3
16 dpavlin 5 ok(my $lookup = new WebPAC::Lookup(
17     lookup_file => 'conf/lookup/example.pm',
18     filter => {
19     'upper' => sub { return uc(shift); },
20     },
21     ), "new");
22 dpavlin 4
23 dpavlin 12 ok(my $regex = $lookup->regex, "regex");
24     diag "regex: $regex";
25    
26 dpavlin 4 my $rec = {
27     '000' => [ '001' ],
28     '800' => [ 'foo' ],
29     '900' => [ 'bar' ],
30     };
31    
32 dpavlin 7 diag "testing WebPAC::Lookup own methods";
33    
34 dpavlin 4 ok($lookup->add( $rec ), "add");
35    
36     ok($lookup->{'lookup'}, "have lookup hash");
37    
38     my $lookup_res = {
39     '800:foo' => [ 'bar' ],
40     '000:001' => [ '001' ],
41 dpavlin 5 '900:bar' => [ 'FOO', 'foo' ]
42 dpavlin 4 };
43    
44     is_deeply($lookup_res, $lookup->{'lookup'}, "lookup data");
45    
46 dpavlin 7 foreach my $k (keys %{ $lookup_res }) {
47     ok(my @l = $lookup->lookup("lookup{$k}"), "lookup{$k}");
48    
49     cmp_ok($#l, '==', $#{$lookup_res->{$k}}, "result size");
50    
51     is_deeply($lookup_res->{$k}, \@l, "result values");
52     }
53    
54     diag "testing WebPAC::Lookup inherited methods";

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.26