2 # =============================================================================
3 # $Id: 08_scan.t,v 1.2 2004-07-28 08:15:47 adam Exp $
6 # =============================================================================
11 push (@INC,'demo','blib/lib','blib/arch');
17 use Test::More tests => 17;
19 # ----------------------------------------------------------------------------
20 # Session opening and closing
24 IDZebra::logFile("test08.log");
25 # IDZebra::logLevel(15);
26 use_ok('IDZebra::Session');
31 # ----------------------------------------------------------------------------
32 # Session opening and closing
33 my $sess = IDZebra::Session->open(configFile => 'demo/zebra.cfg',
34 groupName => 'demo1');
36 $sess->databases('demo1');
39 # -----------------------------------------------------------------------------
40 # Scan titles in multiple databases
42 my $sl1 = $sess->scan(expression => "\@attr 1=4 \@attr 6=2 a",
43 databases => [qw(demo1 demo2)]);
45 &test_list($sl1,$filecount, $filecount*2,1);
46 # -----------------------------------------------------------------------------
47 # Scan titles in a single and default database
48 my $sl2 = $sess->scan(expression => "\@attr 1=4 \@attr 6=2 a");
49 &test_list($sl2,$filecount, $filecount,1);
52 # -----------------------------------------------------------------------------
53 # Scan long list, with position...
54 my $sl3 = $sess->scan(expression => "\@attr 1=1016 a");
56 my @entries = $sl3->entries(position => 5,
57 num_entries => 10000);
59 my $count = $#entries + 1;
60 ok (($sl3->errCode == 0),"scan successful");
61 ok (($sl3->num_entries == $count),"fetched $count entries");
64 foreach my $se (@entries) {
65 $posok = 0 if ($se->position != $i);
68 ok (($posok),"position of each term");
71 # -----------------------------------------------------------------------------
73 eval {my $sl4 = $sess->scan(expression => "\@attr 1=9999 a");};
74 ok (($@ ne ""),"Wrong scan die");
75 ok (($sess->errCode != 0),
76 "Error reported in session: ".$sess->errCode.
77 " (". $sess->errString. ")");
80 # ----------------------------------------------------------------------------
84 # ============================================================================
86 my ($sl, $ecount, $occ, $offset) = @_;
87 my @entries = $sl->entries();
88 my $count = $#entries + 1;
89 ok (($sl->errCode == 0),"scan successfull");
90 ok (($sl->num_entries == $ecount),
91 "number of entries is ".$sl->num_entries);
92 ok (($count == $sl->num_entries),"fetched $count entries");
97 foreach my $se (@entries) {
98 $occcount += $se->occurrences();
99 $posok = 0 if ($se->position != $i);
103 ok ($occcount == $occ,"occurrences: $occcount");
104 ok (($posok),"position of each term");