X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=perl%2Ft%2F05_search.t;h=0ba8ad2ac47bb8a037f56be8fbe60ce2a8f759b1;hb=03e275196b3f82415a965d0bdd6bfa52a15d7446;hp=404c23f9ce3fea52269a6c43f06cf408e076c2b1;hpb=87c62083368d018a7d159fcfd6fc1c930b02b7e3;p=idzebra-moved-to-github.git diff --git a/perl/t/05_search.t b/perl/t/05_search.t index 404c23f..0ba8ad2 100644 --- a/perl/t/05_search.t +++ b/perl/t/05_search.t @@ -1,6 +1,6 @@ #!perl # ============================================================================= -# $Id: 05_search.t,v 1.2 2003-03-04 19:33:53 pop Exp $ +# $Id: 05_search.t,v 1.3 2003-07-26 16:27:46 pop Exp $ # # Perl API header # ============================================================================= @@ -14,7 +14,7 @@ BEGIN { use strict; use warnings; -use Test::More tests => 7; +use Test::More tests => 12; # ---------------------------------------------------------------------------- # Session opening and closing @@ -41,6 +41,7 @@ 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 +65,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