File: 10query.t

package info (click to toggle)
libsearch-xapian-perl 1.2.25.5-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 848 kB
  • sloc: perl: 2,332; makefile: 6
file content (49 lines) | stat: -rw-r--r-- 1,362 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
use strict;
# Before `make install' is performed this script should be runnable with
# `make test'. After `make install' it should work as `perl test.pl'

#########################

use Test::More;
BEGIN { plan tests => 10 };
use Search::Xapian qw(:standard);
use Config;

ok(1); # If we made it this far, we're ok.

#########################

# Adjust query description from 1.4 to match.
sub qd {
    local $_ = (shift @_)->get_description();
    if (substr($_, 0, 1) eq 'Q') {
	s/\@([0-9]+)/:(pos=$1)/g;
	$_ = "Xapian::$_";
    }
    return $_;
}

my $query = Search::Xapian::Query->new(
	OP_AND,
	Search::Xapian::Query->new( "foo" ),
	"bar"
);
ok(defined $query, "AND query created");
is(qd($query), 'Xapian::Query((foo AND bar))', "AND query contains foo part");

$query = Search::Xapian::Query::MatchAll;
is(qd($query), 'Xapian::Query(<alldocuments>)');
$query = Search::Xapian::Query->new("");
is(qd($query), 'Xapian::Query(<alldocuments>)');
$query = Search::Xapian::Query::MatchNothing;
is(qd($query), 'Xapian::Query()');
$query = Search::Xapian::Query->new();
is(qd($query), 'Xapian::Query()');

eval {
    Search::Xapian::Query->new("hello", 1, 2, 3, 4);
};
ok(defined $@, "Bad query ctor threw exception");
like($@, qr!^USAGE: Search::Xapian::Query->new\('term'\) or Search::Xapian::Query->new\(OP, <args>\) at \S+/10query\.t line \d+\.?$!);

ok(1);