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 #########################
7 # change 'tests => 1' to 'tests => last_test_to_print';
11 BEGIN {$SIG{__WARN__} = sub { die "Terminating test due to warning: $_[0]" } };
14 BEGIN { plan tests => 22 };
17 #########################
19 # Insert your test code below, the Test module is use()ed here so read
20 # its man page ( perldoc Test ) for help writing this test script.
22 # None of the following tests can be expected to succeed without first
23 # creating a test database in the directory testdb.
26 ok( $db = Xapian::Database->new( 'testdb' ), "test db opened ok" );
29 ok( $enq = Xapian::Enquire->new( $db ), "enquire object created" );
34 ok( $query = Xapian::Query->new(OP_VALUE_RANGE, 0, "a", "b") );
36 $enq->set_query($query);
37 ok( $mset = $enq->get_mset(0, 10), "got mset" );
38 is( $mset->size, 0, "range a..b ok" );
40 ok( $query = Xapian::Query->new(OP_VALUE_RANGE, 0, "four", "seven") );
42 $enq->set_query($query);
43 ok( $mset = $enq->get_mset(0, 10), "got mset" );
44 is( $mset->size, 1, "range four..seven ok" );
46 is( $mset->begin()->get_document()->get_value(0), "one" );
48 ok( $query = Xapian::Query->new(OP_VALUE_RANGE, 0, "one", "zero") );
50 $enq->set_query($query);
51 ok( $mset = $enq->get_mset(0, 10), "got mset" );
52 is( $mset->size, 2, "range one..zero ok" );
53 my $mseti = $mset->begin();
54 is( $mseti->get_document()->get_value(0), "one" );
56 is( $mseti->get_document()->get_value(0), "two" );
58 ok( $query = Xapian::Query->new(OP_VALUE_LE, 0, "one") );
59 $enq->set_query($query);
60 ok( $mset = $enq->get_mset(0, 10), "got mset" );
61 # FIXME: bug in xapian-core in 1.0.6 and earlier means this gives the wrong answer
62 #is( $mset->size, 1, "range ..one ok" );
64 $mseti = $mset->begin();
65 is( $mseti->get_document()->get_value(0), "one" );
67 ok( $query = Xapian::Query->new(OP_VALUE_GE, 0, "two") );
68 $enq->set_query($query);
69 ok( $mset = $enq->get_mset(0, 10), "got mset" );
70 is( $mset->size, 1, "range one.. ok" );
71 $mseti = $mset->begin();
72 is( $mseti->get_document()->get_value(0), "two" );