2 # Before `make install' is performed this script should be runnable with
3 # `make test'. After `make install' it should work as `perl test.pl'
5 #########################
9 BEGIN { plan tests => 22 };
10 use Search::Xapian qw(:ops);
12 #########################
14 # Insert your test code below, the Test module is use()ed here so read
15 # its man page ( perldoc Test ) for help writing this test script.
17 # None of the following tests can be expected to succeed without first
18 # creating a test database in the directory testdb.
20 my $db = Search::Xapian::Database->new( 'testdb' );
21 my $enq = Search::Xapian::Enquire->new( $db );
22 my $query = Search::Xapian::Query->new( 'test' );
24 $enq->set_query( $query );
27 ok( $mset = $enq->get_mset(0, 10) );
29 ok( @matches = $mset->items() );
31 ok( $match = $matches[0] );
32 ok( $match->get_docid() );
33 ok( $match->get_percent() );
38 ok( $doc = $match->get_document() );
39 ok( $doc->get_data() );
41 ok( exists $matches[1] );
42 ok( !exists $matches[10] );
43 ok( exists $matches[-1] );
45 # Test that "tying by hand" still works.
48 tie( @a, 'Search::Xapian::MSet::Tied', shift );
51 ok( $mset = $enq->get_mset(0, 1) );
52 ok( scalar(tie_mset($mset)) == 1 );
55 ok( @ematches = $enq->matches(0, 2) );
57 ok( $match = $ematches[0] );
58 ok( $match->get_docid() );
59 ok( $match->get_percent() );
64 ok( $rset = Search::Xapian::RSet->new() );
65 $rset->add_document( 1 );
67 ok( $eset = $enq->get_eset( 10, $rset ) );
68 ok( $eset->size() != 0 );
71 ok( @eterms = $eset->items() );
72 ok( scalar @eterms == $eset->size() );
73 ok( $eterms[0]->get_termname() eq $eset->begin()->get_termname() );