Update Perl internals so that it matches the current Zebra API.
[idzebra-moved-to-github.git] / perl / t / 04_cql.t
1 #!perl
2 # =============================================================================
3 # $Id: 04_cql.t,v 1.3 2004-07-28 08:15:47 adam Exp $
4 #
5 # Perl API header
6 # =============================================================================
7 BEGIN {
8     if ($ENV{PERL_CORE}) {
9         chdir 't' if -d 't';
10     }
11     push (@INC,'demo','blib/lib','blib/arch');
12 }
13
14 use strict;
15 use warnings;
16
17 use Test::More tests => 7;
18
19 # ----------------------------------------------------------------------------
20 # Session opening and closing
21 BEGIN {
22     use IDZebra;
23     unlink("test04.log");
24     IDZebra::logFile("test04.log");
25     use_ok('IDZebra::Session'); 
26 }
27
28
29 # ----------------------------------------------------------------------------
30 # Session opening and closing
31 my $sess = IDZebra::Session->new();
32
33 # ----------------------------------------------------------------------------
34 # CQL stuff
35 $sess->cqlmap('demo/cql.map');
36
37 $SIG{__WARN__} = \&catch_warn;
38
39 &check_cql($sess, "IDZebra", 0);
40 &check_cql($sess, "dc.title=IDZebra", 0);
41 &check_cql($sess, "dc.title=(IDZebra and Session)", 0);
42 &check_cql($sess, "dc.title=IDZebra and Session)", -1);
43 &check_cql($sess, "dc.title='IDZebra::Session'", 0);
44 &check_cql($sess, "anything=IDZebra", 16);
45
46 sub check_cql {
47     my ($sess, $query, $exp) = @_;
48     my ($rpn, $stat) = $sess->cql2pqf($query);
49     if ($exp) {
50         ok(($stat == $exp), "Wrong query ($stat): '$query'");
51     } else {
52         ok((($stat == 0) && ($rpn ne "")), "Good query query: '$query'");
53     }
54 }
55
56
57 sub catch_warn {
58     1;
59 }