4 use Test::More tests => 18;
11 use_ok( 'WebPAC::Lookup' );
14 my $debug = shift @ARGV;
16 throws_ok { new WebPAC::Lookup( no_log => 1 ) } qr/lookup_file/, "new without lookup_file";
18 ok(my $lookup = new WebPAC::Lookup(
19 lookup_file => 'conf/lookup/example.pm',
21 'upper' => sub { return uc(shift); },
25 ok(my $regex = $lookup->regex, "regex");
34 diag "testing WebPAC::Lookup own methods";
36 ok($lookup->add( $rec ), "add");
38 ok(my $l1 = $lookup->{_lookup_data}, "{_lookup_data}");
39 diag "lookup->{_lookup_data} = ",Dumper($lookup->{_lookup_data}) if ($debug);
40 ok(my $l2 = $lookup->lookup_hash, "lookup_hash");
41 diag "lookup->lookup_hash = ",Dumper($lookup->lookup_hash) if ($debug);
43 is_deeply( $l1, $l2, 'lookups same');
46 '800:foo' => [ 'bar' ],
47 '000:001' => [ '001' ],
48 '900:bar' => [ 'FOO', 'foo' ]
51 is_deeply($lookup_res, $lookup->{'_lookup_data'}, "lookup data");
53 foreach my $k (keys %{ $lookup_res }) {
54 ok(my @l = $lookup->lookup("lookup{$k}"), "lookup{$k}");
56 cmp_ok($#l, '==', $#{$lookup_res->{$k}}, "result size");
58 is_deeply($lookup_res->{$k}, \@l, "result values");
61 diag "testing WebPAC::Lookup inherited methods";