xapian-core  1.4.20
Classes | Macros | Functions | Variables
api_query.cc File Reference

Query-related tests. More...

#include <config.h>
#include "api_query.h"
#include <xapian.h>
#include "testsuite.h"
#include "testutils.h"
#include "apitest.h"
+ Include dependency graph for api_query.cc:

Go to the source code of this file.

Classes

struct  wildcard_testcase
 
struct  positional_testcase
 

Macros

#define WILDCARD_EXCEPTION   { 0, 0, 0, "" }
 

Functions

 DEFINE_TESTCASE (queryterms1, !backend)
 
 DEFINE_TESTCASE (matchall2, !backend)
 
 DEFINE_TESTCASE (matchnothing1, !backend)
 
 DEFINE_TESTCASE (overload1, !backend)
 
 DEFINE_TESTCASE (possubqueries1, writable)
 Regression test and feature test. More...
 
 DEFINE_TESTCASE (xor3, backend)
 Test that XOR handles all remaining subqueries running out at the same. More...
 
 DEFINE_TESTCASE (nonutf8termdesc1, !backend)
 Check encoding of non-UTF8 terms in query descriptions. More...
 
 DEFINE_TESTCASE (queryintro1, !backend)
 Test introspection on Query objects. More...
 
 DEFINE_TESTCASE (phrasealldocs1, backend)
 Regression test for bug introduced in 1.3.1 and fixed in 1.3.3. More...
 
 DEFINE_TESTCASE (wildcard1, backend)
 
 DEFINE_TESTCASE (wildcard2, backend)
 Regression test for #696, fixed in 1.3.4. More...
 
 DEFINE_TESTCASE (dualprefixwildcard1, backend)
 
 DEFINE_TESTCASE (loosephrase1, backend)
 Regression test for bug fixed in 1.3.3 and 1.2.21. More...
 
 DEFINE_TESTCASE (loosenear1, backend)
 Regression tests for bugs fixed in 1.3.3 and 1.2.21. More...
 
 DEFINE_TESTCASE (complexphrase1, backend)
 Regression test for bug fixed in 1.3.6 - the first case segfaulted in 1.3.x. More...
 
 DEFINE_TESTCASE (complexnear1, backend)
 Regression test for bug fixed in 1.3.6 - the first case segfaulted in 1.3.x. More...
 
 DEFINE_TESTCASE (complexphrase2, backend)
 Check subqueries of MatchAll, MatchNothing and PostingSource are supported. More...
 
 DEFINE_TESTCASE (complexnear2, backend)
 Check subqueries of MatchAll, MatchNothing and PostingSource are supported. More...
 
 DEFINE_TESTCASE (zeroestimate1, backend)
 A zero estimated number of matches broke the code to round the estimate. More...
 
 DEFINE_TESTCASE (complexphrase3, backend)
 Feature test for OR under OP_PHRASE support added in 1.4.3. More...
 
 DEFINE_TESTCASE (complexnear3, backend)
 Feature test for OR under OP_NEAR support added in 1.4.3. More...
 
static void gen_subdbwithoutpos1_db (Xapian::WritableDatabase &db, const string &)
 
 DEFINE_TESTCASE (subdbwithoutpos1, generated)
 
 DEFINE_TESTCASE (notandor1, backend)
 
 DEFINE_TESTCASE (boolorbug1, backend)
 
 DEFINE_TESTCASE (hoistnotbug1, backend)
 
 DEFINE_TESTCASE (emptynot1, backend)
 
 DEFINE_TESTCASE (emptymaybe1, backend)
 
 DEFINE_TESTCASE (phraseweightcheckbug1, backend)
 
 DEFINE_TESTCASE (orphanedhint1, backend)
 

Variables

static const wildcard_testcase wildcard1_testcases []
 
static const positional_testcase loosephrase1_testcases []
 
static const positional_testcase loosenear1_testcases []
 

Detailed Description

Query-related tests.

Definition in file api_query.cc.

Macro Definition Documentation

◆ WILDCARD_EXCEPTION

#define WILDCARD_EXCEPTION   { 0, 0, 0, "" }

Definition at line 455 of file api_query.cc.

Function Documentation

◆ DEFINE_TESTCASE() [1/29]

DEFINE_TESTCASE ( queryterms1  ,
backend 
)

Regression test - in 1.0.10 and earlier "" was included in the list.

Definition at line 35 of file api_query.cc.

References Xapian::Query::get_terms_begin(), Xapian::Query::get_terms_end(), Xapian::Query::get_unique_terms_begin(), Xapian::Query::get_unique_terms_end(), Xapian::Query::MatchAll, query(), TEST, and TEST_EQUAL.

◆ DEFINE_TESTCASE() [2/29]

DEFINE_TESTCASE ( matchall2  ,
backend 
)

Definition at line 68 of file api_query.cc.

References Xapian::Query::MatchAll, and TEST_STRINGS_EQUAL.

◆ DEFINE_TESTCASE() [3/29]

DEFINE_TESTCASE ( matchnothing1  ,
backend 
)

◆ DEFINE_TESTCASE() [4/29]

DEFINE_TESTCASE ( overload1  ,
backend 
)

◆ DEFINE_TESTCASE() [5/29]

DEFINE_TESTCASE ( possubqueries1  ,
writable   
)

Regression test and feature test.

This threw AssertionError in 1.0.9 and earlier (bug#201) and gave valgrind errors in 1.0.11 and earlier (bug#349).

Currently the OR-subquery case is supported, other operators aren't.

Definition at line 268 of file api_query.cc.

References Xapian::WritableDatabase::add_document(), Xapian::Document::add_posting(), Xapian::Query::get_description(), Xapian::Enquire::get_mset(), get_writable_database(), Xapian::Query::OP_AND, Xapian::Query::OP_NEAR, Xapian::Query::OP_OR, Xapian::Query::OP_PHRASE, Xapian::Enquire::set_query(), TEST_EXCEPTION, and TEST_STRINGS_EQUAL.

◆ DEFINE_TESTCASE() [6/29]

DEFINE_TESTCASE ( xor3  ,
backend   
)

Test that XOR handles all remaining subqueries running out at the same.

Definition at line 336 of file api_query.cc.

References get_database(), Xapian::Enquire::get_mset(), Xapian::Query::OP_XOR, Xapian::Enquire::set_query(), Xapian::MSet::size(), and TEST_EQUAL.

◆ DEFINE_TESTCASE() [7/29]

DEFINE_TESTCASE ( nonutf8termdesc1  ,
backend 
)

Check encoding of non-UTF8 terms in query descriptions.

Definition at line 366 of file api_query.cc.

References TEST_EQUAL.

◆ DEFINE_TESTCASE() [8/29]

DEFINE_TESTCASE ( queryintro1  ,
backend 
)

◆ DEFINE_TESTCASE() [9/29]

DEFINE_TESTCASE ( phrasealldocs1  ,
backend   
)

Regression test for bug introduced in 1.3.1 and fixed in 1.3.3.

Definition at line 435 of file api_query.cc.

References get_database(), Xapian::Enquire::get_mset(), Xapian::Query::OP_AND_NOT, Xapian::Query::OP_PHRASE, Xapian::Enquire::set_query(), Xapian::MSet::size(), and TEST_EQUAL.

◆ DEFINE_TESTCASE() [10/29]

DEFINE_TESTCASE ( wildcard1  ,
backend   
)

◆ DEFINE_TESTCASE() [11/29]

DEFINE_TESTCASE ( wildcard2  ,
backend   
)

◆ DEFINE_TESTCASE() [12/29]

DEFINE_TESTCASE ( dualprefixwildcard1  ,
backend   
)

◆ DEFINE_TESTCASE() [13/29]

DEFINE_TESTCASE ( loosephrase1  ,
backend   
)

Regression test for bug fixed in 1.3.3 and 1.2.21.

Definition at line 567 of file api_query.cc.

References Xapian::MSet::empty(), get_database(), Xapian::Enquire::get_mset(), Xapian::Query::OP_PHRASE, Xapian::Enquire::set_query(), Xapian::MSet::size(), TEST, and TEST_EQUAL.

◆ DEFINE_TESTCASE() [14/29]

DEFINE_TESTCASE ( loosenear1  ,
backend   
)

Regression tests for bugs fixed in 1.3.3 and 1.2.21.

Definition at line 600 of file api_query.cc.

References Xapian::MSet::empty(), get_database(), Xapian::Enquire::get_mset(), Xapian::Query::OP_NEAR, Xapian::Enquire::set_query(), Xapian::MSet::size(), TEST, and TEST_EQUAL.

◆ DEFINE_TESTCASE() [15/29]

DEFINE_TESTCASE ( complexphrase1  ,
backend   
)

Regression test for bug fixed in 1.3.6 - the first case segfaulted in 1.3.x.

Definition at line 620 of file api_query.cc.

References Xapian::MSet::empty(), get_database(), Xapian::Enquire::get_mset(), Xapian::Query::OP_PHRASE, query(), Xapian::Enquire::set_query(), and TEST.

◆ DEFINE_TESTCASE() [16/29]

DEFINE_TESTCASE ( complexnear1  ,
backend   
)

Regression test for bug fixed in 1.3.6 - the first case segfaulted in 1.3.x.

Definition at line 636 of file api_query.cc.

References Xapian::MSet::empty(), get_database(), Xapian::Enquire::get_mset(), Xapian::Query::OP_NEAR, query(), Xapian::Enquire::set_query(), and TEST.

◆ DEFINE_TESTCASE() [17/29]

DEFINE_TESTCASE ( complexphrase2  ,
backend   
)

Check subqueries of MatchAll, MatchNothing and PostingSource are supported.

Definition at line 652 of file api_query.cc.

References get_database(), Xapian::Enquire::get_mset(), Xapian::Query::MatchAll, Xapian::Query::MatchNothing, Xapian::Query::OP_OR, Xapian::Query::OP_PHRASE, query(), and Xapian::Enquire::set_query().

◆ DEFINE_TESTCASE() [18/29]

DEFINE_TESTCASE ( complexnear2  ,
backend   
)

Check subqueries of MatchAll, MatchNothing and PostingSource are supported.

Definition at line 673 of file api_query.cc.

References get_database(), Xapian::Enquire::get_mset(), Xapian::Query::MatchAll, Xapian::Query::MatchNothing, Xapian::Query::OP_NEAR, Xapian::Query::OP_OR, query(), and Xapian::Enquire::set_query().

◆ DEFINE_TESTCASE() [19/29]

DEFINE_TESTCASE ( zeroestimate1  ,
backend   
)

A zero estimated number of matches broke the code to round the estimate.

Definition at line 694 of file api_query.cc.

References get_database(), Xapian::MSet::get_matches_estimated(), Xapian::Enquire::get_mset(), Xapian::Query::OP_PHRASE, Xapian::Enquire::set_query(), and TEST_EQUAL.

◆ DEFINE_TESTCASE() [20/29]

DEFINE_TESTCASE ( complexphrase3  ,
backend   
)

Feature test for OR under OP_PHRASE support added in 1.4.3.

Definition at line 705 of file api_query.cc.

References get_database(), Xapian::Enquire::get_mset(), mset_expect_order(), Xapian::Query::OP_PHRASE, query(), and Xapian::Enquire::set_query().

◆ DEFINE_TESTCASE() [21/29]

DEFINE_TESTCASE ( complexnear3  ,
backend   
)

Feature test for OR under OP_NEAR support added in 1.4.3.

Definition at line 731 of file api_query.cc.

References get_database(), Xapian::Enquire::get_mset(), mset_expect_order(), Xapian::Query::OP_NEAR, query(), and Xapian::Enquire::set_query().

◆ DEFINE_TESTCASE() [22/29]

DEFINE_TESTCASE ( subdbwithoutpos1  ,
generated   
)

◆ DEFINE_TESTCASE() [23/29]

DEFINE_TESTCASE ( notandor1  ,
backend   
)

◆ DEFINE_TESTCASE() [24/29]

DEFINE_TESTCASE ( boolorbug1  ,
backend   
)

◆ DEFINE_TESTCASE() [25/29]

DEFINE_TESTCASE ( hoistnotbug1  ,
backend   
)

◆ DEFINE_TESTCASE() [26/29]

DEFINE_TESTCASE ( emptynot1  ,
backend   
)

◆ DEFINE_TESTCASE() [27/29]

DEFINE_TESTCASE ( emptymaybe1  ,
backend   
)

◆ DEFINE_TESTCASE() [28/29]

DEFINE_TESTCASE ( phraseweightcheckbug1  ,
backend   
)

◆ DEFINE_TESTCASE() [29/29]

DEFINE_TESTCASE ( orphanedhint1  ,
backend   
)

◆ gen_subdbwithoutpos1_db()

static void gen_subdbwithoutpos1_db ( Xapian::WritableDatabase db,
const string &   
)
static

Variable Documentation

◆ loosenear1_testcases

const positional_testcase loosenear1_testcases[]
static
Initial value:
= {
{ 4, { "test", "the", "with", 0 }, 1 },
{ 4, { "expect", "word", "the", 0 }, 2 },
{ 4, { "line", "be", "blank", 0 }, 1 },
{ 2, { "banana", "banana", 0, 0 }, 0 },
{ 3, { "banana", "banana", 0, 0 }, 0 },
{ 2, { "word", "word", 0, 0 }, 2 },
{ 4, { "work", "meant", "work", 0 }, 0 },
{ 4, { "this", "one", "yet", "one" }, 0 }
}

Definition at line 588 of file api_query.cc.

◆ loosephrase1_testcases

const positional_testcase loosephrase1_testcases[]
static
Initial value:
= {
{ 5, { "expect", "to", "mset", 0 }, 0 },
{ 5, { "word", "well", "the", 0 }, 2 },
{ 5, { "if", "word", "doesnt", 0 }, 0 },
{ 5, { "at", "line", "three", 0 }, 0 },
{ 5, { "paragraph", "other", "the", 0 }, 0 },
{ 5, { "other", "the", "with", 0 }, 0 }
}

Definition at line 557 of file api_query.cc.

◆ wildcard1_testcases

const wildcard_testcase wildcard1_testcases[]
static
Initial value:
= {
{ "th", 6, 'E', WILDCARD_EXCEPTION },
{ "thou", 1, 'E', { "though", 0, 0, 0 } },
{ "s", 2, 'F', { "say", "search", 0, 0 } },
{ "s", 2, 'M', { "simpl", "so", 0, 0 } }
}
#define WILDCARD_EXCEPTION
Definition: api_query.cc:455

Definition at line 457 of file api_query.cc.