2 # =============================================================================
3 # $Id: 08_scan.t,v 1.1 2003-03-04 19:33:53 pop Exp $
6 # =============================================================================
11 push (@INC,'demo','blib/lib','blib/arch');
17 use Test::More tests => 17;
19 # ----------------------------------------------------------------------------
20 # Session opening and closing
23 IDZebra::logFile("test.log");
24 # IDZebra::logLevel(15);
25 use_ok('IDZebra::Session');
30 # ----------------------------------------------------------------------------
31 # Session opening and closing
32 my $sess = IDZebra::Session->open(configFile => 'demo/zebra.cfg',
33 groupName => 'demo1');
35 #$sess->databases('demo1');
38 # -----------------------------------------------------------------------------
39 # Scan titles in multiple databases
41 my $sl1 = $sess->scan(expression => "\@attr 1=4 \@attr 6=2 a",
42 databases => [qw(demo1 demo2)]);
44 &test_list($sl1,$filecount, $filecount*2,1);
45 # -----------------------------------------------------------------------------
46 # Scan titles in a single and default database
47 my $sl2 = $sess->scan(expression => "\@attr 1=4 \@attr 6=2 a");
48 &test_list($sl2,$filecount, $filecount,1);
51 # -----------------------------------------------------------------------------
52 # Scan long list, with position...
53 my $sl3 = $sess->scan(expression => "\@attr 1=1016 a");
55 my @entries = $sl3->entries(position => 5,
56 num_entries => 10000);
58 my $count = $#entries + 1;
59 ok (($sl3->errCode == 0),"scan successfull");
60 ok (($sl3->num_entries == $count),"fetched $count entries");
63 foreach my $se (@entries) {
64 $posok = 0 if ($se->position != $i);
67 ok (($posok),"position of each term");
70 # -----------------------------------------------------------------------------
72 eval {my $sl4 = $sess->scan(expression => "\@attr 1=9999 a");};
73 ok (($@ ne ""),"Wrong scan die");
74 ok (($sess->errCode != 0),
75 "Error reported in session: ".$sess->errCode.
76 " (". $sess->errString. ")");
79 # ----------------------------------------------------------------------------
83 # ============================================================================
85 my ($sl, $ecount, $occ, $offset) = @_;
86 my @entries = $sl->entries();
87 my $count = $#entries + 1;
88 ok (($sl->errCode == 0),"scan successfull");
89 ok (($sl->num_entries == $ecount),
90 "number of entries is ".$sl->num_entries);
91 ok (($count == $sl->num_entries),"fetched $count entries");
96 foreach my $se (@entries) {
97 $occcount += $se->occurrences();
98 $posok = 0 if ($se->position != $i);
102 ok ($occcount == $occ,"occurrences: $occcount");
103 ok (($posok),"position of each term");