xapian-core  2.0.0
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  editdist_testcase
 
struct  positional_testcase
 
struct  Exception_estimateop2
 
class  MDecider_estimateop2
 

Macros

#define WILDCARD_EXCEPTION   { 0, 0, 0, "" }
 
#define QUERY_ALLDOCS   "Query(<alldocuments>)"
 
#define EDITDIST_EXCEPTION   { 0, 0, 0, "" }
 
#define UTF8(X)   reinterpret_cast<const char*>(u8"" X "")
 

Functions

 DEFINE_TESTCASE (queryterms1, !backend)
 
 DEFINE_TESTCASE (matchall2, !backend)
 
 DEFINE_TESTCASE (matchnothing1, !backend)
 
 DEFINE_TESTCASE (overload1, !backend)
 
 DEFINE_TESTCASE (possubqueries1, backend)
 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 (wildcard3, backend)
 Regression test for bug in initial implementation. More...
 
 DEFINE_TESTCASE (wildcard4, backend)
 Regression test for OP_WILDCARD bug, fixed in 1.4.26. More...
 
 DEFINE_TESTCASE (dualprefixwildcard1, backend)
 
 DEFINE_TESTCASE (specialwildcard1, !backend)
 Test special case wildcards. More...
 
static void gen_singlecharwildcard1_db (Xapian::WritableDatabase &db, const string &)
 
 DEFINE_TESTCASE (singlecharwildcard1, backend)
 Test ? extended wildcard. More...
 
static void gen_multicharwildcard1_db (Xapian::WritableDatabase &db, const string &)
 
 DEFINE_TESTCASE (multicharwildcard1, backend)
 Test * extended wildcard. More...
 
 DEFINE_TESTCASE (editdist1, backend)
 
 DEFINE_TESTCASE (editdist2, backend)
 Test Unicode edit distance calculations. More...
 
 DEFINE_TESTCASE (dualprefixeditdist1, 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, backend)
 
 DEFINE_TESTCASE (notandor1, backend)
 
 DEFINE_TESTCASE (boolorbug1, backend)
 
 DEFINE_TESTCASE (hoistnotbug1, backend)
 
 DEFINE_TESTCASE (emptynot1, backend)
 
 DEFINE_TESTCASE (emptymaybe1, backend)
 
 DEFINE_TESTCASE (allnot1, backend)
 
 DEFINE_TESTCASE (emptymayberhs1, backend)
 
 DEFINE_TESTCASE (phraseweightcheckbug1, backend)
 
 DEFINE_TESTCASE (orphanedhint1, backend)
 
 DEFINE_TESTCASE (docidrangebugs1, backend)
 
 DEFINE_TESTCASE (estimateopbug1, backend)
 
 DEFINE_TESTCASE (estimateopbug2, backend &&!remote)
 

Variables

static const wildcard_testcase wildcard1_testcases []
 
static const editdist_testcase editdist1_testcases []
 
static const editdist_testcase editdist2_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

◆ EDITDIST_EXCEPTION

#define EDITDIST_EXCEPTION   { 0, 0, 0, "" }

Definition at line 808 of file api_query.cc.

◆ QUERY_ALLDOCS

#define QUERY_ALLDOCS   "Query(<alldocuments>)"

◆ UTF8

#define UTF8 (   X)    reinterpret_cast<const char*>(u8"" X "")

Definition at line 869 of file api_query.cc.

◆ WILDCARD_EXCEPTION

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

Definition at line 492 of file api_query.cc.

Function Documentation

◆ DEFINE_TESTCASE() [1/42]

DEFINE_TESTCASE ( allnot1  ,
backend   
)

◆ DEFINE_TESTCASE() [2/42]

DEFINE_TESTCASE ( boolorbug1  ,
backend   
)

◆ DEFINE_TESTCASE() [3/42]

DEFINE_TESTCASE ( complexnear1  ,
backend   
)

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

Definition at line 1047 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() [4/42]

DEFINE_TESTCASE ( complexnear2  ,
backend   
)

Check subqueries of MatchAll, MatchNothing and PostingSource are supported.

Definition at line 1084 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() [5/42]

DEFINE_TESTCASE ( complexnear3  ,
backend   
)

Feature test for OR under OP_NEAR support added in 1.4.3.

Definition at line 1142 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() [6/42]

DEFINE_TESTCASE ( complexphrase1  ,
backend   
)

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

Definition at line 1031 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() [7/42]

DEFINE_TESTCASE ( complexphrase2  ,
backend   
)

Check subqueries of MatchAll, MatchNothing and PostingSource are supported.

Definition at line 1063 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() [8/42]

DEFINE_TESTCASE ( complexphrase3  ,
backend   
)

Feature test for OR under OP_PHRASE support added in 1.4.3.

Definition at line 1116 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() [9/42]

DEFINE_TESTCASE ( docidrangebugs1  ,
backend   
)

◆ DEFINE_TESTCASE() [10/42]

DEFINE_TESTCASE ( dualprefixeditdist1  ,
backend   
)

◆ DEFINE_TESTCASE() [11/42]

DEFINE_TESTCASE ( dualprefixwildcard1  ,
backend   
)

◆ DEFINE_TESTCASE() [12/42]

DEFINE_TESTCASE ( editdist1  ,
backend   
)

◆ DEFINE_TESTCASE() [13/42]

DEFINE_TESTCASE ( editdist2  ,
backend   
)

◆ DEFINE_TESTCASE() [14/42]

DEFINE_TESTCASE ( emptymaybe1  ,
backend   
)

◆ DEFINE_TESTCASE() [15/42]

DEFINE_TESTCASE ( emptymayberhs1  ,
backend   
)

◆ DEFINE_TESTCASE() [16/42]

DEFINE_TESTCASE ( emptynot1  ,
backend   
)

◆ DEFINE_TESTCASE() [17/42]

DEFINE_TESTCASE ( estimateopbug1  ,
backend   
)

◆ DEFINE_TESTCASE() [18/42]

DEFINE_TESTCASE ( estimateopbug2  ,
backend &&!  remote 
)

Definition at line 1486 of file api_query.cc.

References FAIL_TEST, get_database(), and query().

◆ DEFINE_TESTCASE() [19/42]

DEFINE_TESTCASE ( hoistnotbug1  ,
backend   
)

◆ DEFINE_TESTCASE() [20/42]

DEFINE_TESTCASE ( loosenear1  ,
backend   
)

◆ DEFINE_TESTCASE() [21/42]

DEFINE_TESTCASE ( loosephrase1  ,
backend   
)

◆ DEFINE_TESTCASE() [22/42]

DEFINE_TESTCASE ( matchall2  ,
backend 
)

Definition at line 67 of file api_query.cc.

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

◆ DEFINE_TESTCASE() [23/42]

DEFINE_TESTCASE ( matchnothing1  ,
backend 
)

◆ DEFINE_TESTCASE() [24/42]

DEFINE_TESTCASE ( multicharwildcard1  ,
backend   
)

◆ DEFINE_TESTCASE() [25/42]

DEFINE_TESTCASE ( nonutf8termdesc1  ,
backend 
)

Check encoding of non-UTF8 terms in query descriptions.

Definition at line 395 of file api_query.cc.

References TEST_EQUAL.

◆ DEFINE_TESTCASE() [26/42]

DEFINE_TESTCASE ( notandor1  ,
backend   
)

◆ DEFINE_TESTCASE() [27/42]

DEFINE_TESTCASE ( orphanedhint1  ,
backend   
)

◆ DEFINE_TESTCASE() [28/42]

DEFINE_TESTCASE ( overload1  ,
backend 
)

◆ DEFINE_TESTCASE() [29/42]

DEFINE_TESTCASE ( phrasealldocs1  ,
backend   
)

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

Definition at line 472 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() [30/42]

DEFINE_TESTCASE ( phraseweightcheckbug1  ,
backend   
)

◆ DEFINE_TESTCASE() [31/42]

DEFINE_TESTCASE ( possubqueries1  ,
backend   
)

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 267 of file api_query.cc.

References Xapian::WritableDatabase::add_document(), Xapian::Document::add_posting(), get_database(), Xapian::Query::get_description(), Xapian::Enquire::get_mset(), 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() [32/42]

DEFINE_TESTCASE ( queryintro1  ,
backend 
)

◆ DEFINE_TESTCASE() [33/42]

DEFINE_TESTCASE ( queryterms1  ,
backend 
)

◆ DEFINE_TESTCASE() [34/42]

DEFINE_TESTCASE ( singlecharwildcard1  ,
backend   
)

◆ DEFINE_TESTCASE() [35/42]

DEFINE_TESTCASE ( specialwildcard1  ,
backend 
)

Test special case wildcards.

Definition at line 648 of file api_query.cc.

References Xapian::Query::OP_WILDCARD, QUERY_ALLDOCS, TEST_EQUAL, and Xapian::Query::WILDCARD_PATTERN_GLOB.

◆ DEFINE_TESTCASE() [36/42]

DEFINE_TESTCASE ( subdbwithoutpos1  ,
backend   
)

◆ DEFINE_TESTCASE() [37/42]

DEFINE_TESTCASE ( wildcard1  ,
backend   
)

◆ DEFINE_TESTCASE() [38/42]

DEFINE_TESTCASE ( wildcard2  ,
backend   
)

◆ DEFINE_TESTCASE() [39/42]

DEFINE_TESTCASE ( wildcard3  ,
backend   
)

Regression test for bug in initial implementation.

If any terms started with A-Z then the next term that didn't wasn't considered.

Definition at line 581 of file api_query.cc.

References Xapian::WritableDatabase::add_document(), Xapian::Document::add_term(), get_database(), Xapian::Query::OP_WILDCARD, Xapian::MSet::size(), TEST_EQUAL, and Xapian::Query::WILDCARD_PATTERN_GLOB.

◆ DEFINE_TESTCASE() [40/42]

DEFINE_TESTCASE ( wildcard4  ,
backend   
)

◆ DEFINE_TESTCASE() [41/42]

DEFINE_TESTCASE ( xor3  ,
backend   
)

◆ DEFINE_TESTCASE() [42/42]

DEFINE_TESTCASE ( zeroestimate1  ,
backend   
)

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

Definition at line 1105 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.

◆ gen_multicharwildcard1_db()

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

◆ gen_singlecharwildcard1_db()

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

◆ gen_subdbwithoutpos1_db()

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

Variable Documentation

◆ editdist1_testcases

const editdist_testcase editdist1_testcases[]
static
Initial value:
= {
{ "muse", 2, 8, 'E', EDITDIST_EXCEPTION },
{ "museum", 3, 3, 'E', { "mset", "must", "use", 0 } },
{ "thou", 0, 9, 'E', { 0, 0, 0, 0 } },
{ "though", 0, 9, 'E', { "though", 0, 0, 0 } },
{ "museum", 3, 1, 'F', { "mset", 0, 0, 0 } },
{ "museum", 3, 1, 'M', { "use", 0, 0, 0 } },
}
#define EDITDIST_EXCEPTION
Definition: api_query.cc:808

Definition at line 810 of file api_query.cc.

Referenced by DEFINE_TESTCASE().

◆ editdist2_testcases

const editdist_testcase editdist2_testcases[]
static
Initial value:
= {
{ UTF8("\U00010000"), 1, 8, 'E', { UTF8("a\U00010000"), 0, 0, 0 } },
}
#define UTF8(X)
Definition: api_query.cc:869

Definition at line 872 of file api_query.cc.

Referenced by DEFINE_TESTCASE().

◆ 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 999 of file api_query.cc.

Referenced by DEFINE_TESTCASE().

◆ 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 968 of file api_query.cc.

Referenced by DEFINE_TESTCASE().

◆ 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:492

Definition at line 494 of file api_query.cc.

Referenced by DEFINE_TESTCASE().