X-Git-Url: http://jsfdemo.indexdata.com/?a=blobdiff_plain;f=perl%2Ft%2F05_search.t;h=97659833761fe850665a6f1ea85650a28ab41e01;hb=a137a5cabe5ce29c9c98445f4099f7d528663bb9;hp=e6eefa49f110076427174c7097b5cd24f21ea55d;hpb=2f8d4d90ec5eba3725182f83c067e141db160495;p=idzebra-moved-to-github.git diff --git a/perl/t/05_search.t b/perl/t/05_search.t index e6eefa4..9765983 100644 --- a/perl/t/05_search.t +++ b/perl/t/05_search.t @@ -1,6 +1,6 @@ #!perl # ============================================================================= -# $Id: 05_search.t,v 1.1 2003-03-03 00:44:39 pop Exp $ +# $Id: 05_search.t,v 1.4 2004-07-28 08:15:47 adam Exp $ # # Perl API header # ============================================================================= @@ -14,13 +14,14 @@ BEGIN { use strict; use warnings; -use Test::More tests => 7; +use Test::More tests => 12; # ---------------------------------------------------------------------------- # Session opening and closing BEGIN { use IDZebra; - IDZebra::logFile("test.log"); + unlink("test05.log"); + IDZebra::logFile("test05.log"); use_ok('IDZebra::Session'); use_ok('pod'); } @@ -34,13 +35,14 @@ isa_ok($sess,"IDZebra::Session"); # ---------------------------------------------------------------------------- # search -our $filecount = 6; +our $filecount = 8; my ($hits, $expected); # Search 1 databases my $rs1 = $sess->search(cqlmap => 'demo/cql.map', cql => 'IDZebra', + termset => 1, databases => [qw(demo1)]); $expected = $filecount; @@ -64,9 +66,34 @@ ok(($hits == $expected), "CQL search - found $hits/$expected records"); my $rs3 = $sess->search(cqlmap => 'demo/cql.map', pqf => '@attr 1=4 IDZebra'); $expected = $filecount * 2; -$hits = $rs2->count; +$hits = $rs3->count; +ok(($hits == $expected), "RPN search - found $hits/$expected records"); + +# Termlists; +my $rs4 = $sess->search(pqf => '@attr 1=4 @and IDZebra Session'); +$expected = 2; +$hits = $rs4->count; ok(($hits == $expected), "RPN search - found $hits/$expected records"); +my @terms = $rs4->terms(); +ok(($#terms == 1), "Got 2 terms in RPN expression"); +my $cc = 0; +foreach my $t (@terms) { + if ($t->{term} eq 'IDZebra') { + ok(($t->{count} = $filecount*2), "Term IDZebra ($t->{count})"); + $cc++; + } + elsif ($t->{term} eq 'Session') { + ok(($t->{count} = 2), "Term Session ($t->{count})"); + $cc++; + } else { + ok(0,"Invalid term $t->{term}"); + } + +} +ok (($cc == 2), "Got 2 terms for RS"); + + # More specific search