49 unsigned int maxtermsperfield = atoi(arg.c_str());
50 for (
unsigned int i = 0; i <
doccount; ++i) {
52 for (
unsigned int j =
randint(maxtermsperfield) + 1; j != 0; --j) {
69 unsigned int maxchildren_)
70 : maxtermsperfield(maxtermsperfield_),
71 maxchildren(maxchildren_)
83 list<Xapian::Query>::iterator
pick(
unsigned int num) {
84 list<Xapian::Query>::iterator i = pieces.begin();
85 for (
unsigned int c = 0; c != num && i != pieces.end(); ++c, ++i) {}
109 env.
pieces.push_back(combined);
122 env.
pieces.push_back(combined);
135 env.
pieces.push_back(combined);
145 if (env.
pieces.size() < 2)
return;
146 list<Xapian::Query>::iterator i = env.
pick(2);
149 env.
pieces.push_back(combined);
165 unsigned int maxchildren_,
166 unsigned int maxsteps_)
167 : env(maxtermsperfield_, maxchildren_),
191 unsigned int steps =
randint(maxsteps) + 1;
192 while (steps-- != 0) {
206 unsigned int maxtermsperfield = 100;
207 unsigned int repetitions = 10000;
211 string arg(
str(maxtermsperfield));
221 unsigned int count = 0;
222 while (++count != repetitions) {
225 tout <<
"query " << count <<
": " <<
query <<
"\n";
231 tout << mset1 <<
"\n";
232 tout << mset10 <<
"\n";
233 tout << msetall <<
"\n";
235 TEST(mset10.empty());
236 TEST(msetall.empty());
Xapian::docid add_document(const Xapian::Document &document)
Add a new document to the database.
The environment used by the steps when building a query.
Run multiple tests for different backends.
#define TEST(a)
Test a condition, without an additional explanation for failure.
This class is used to access a database, or a group of databases.
Xapian::Database get_database(const std::vector< std::string > &files)
Get a database instance of the current type.
void(* QueryStep)(QueryBuilderEnv &)
Match documents which an odd number of subqueries match.
bool mset_range_is_same(const Xapian::MSet &mset1, unsigned int first1, const Xapian::MSet &mset2, unsigned int first2, unsigned int count)
static void combine_XOR(QueryBuilderEnv &env)
Combine some queries with XOR.
list< Xapian::Query >::iterator pick(unsigned int num)
Get an iterator pointing to the "num"th element in pieces.
a generic test suite engine
vector< QueryStep > options
The possible steps.
Class representing a list of search results.
MSet get_mset(Xapian::doccount first, Xapian::doccount maxitems, Xapian::doccount checkatleast=0, const RSet *omrset=0, const MatchDecider *mdecider=0) const
Get (a portion of) the match set for the current query.
Convert types to std::string.
Xapian::doccount get_doccount() const
Get the number of documents in the database.
QueryBuilder(unsigned int maxtermsperfield_, unsigned int maxchildren_, unsigned int maxsteps_)
QueryBuilderEnv(unsigned int maxtermsperfield_, unsigned int maxchildren_)
unsigned int maxtermsperfield
list< Xapian::Query > pieces
Workspace for the query builder steps.
Base class for backend handling in test harness.
Xapian::Query make_query()
Build a random query.
This class provides read/write access to a database.
std::ostringstream tout
The debug printing stream.
Xapian::Query pop()
Pop a query from the front of the list of pieces, and return it.
Public interfaces for the Xapian library.
BackendManager * backendmanager
backendmanager is global so that it can be accessed by individual tests.
string str(int value)
Convert int to std::string.
void commit()
Commit any pending modifications made to the database.
DEFINE_TESTCASE(queries1, writable &&!remote &&!inmemory)
static void combine_AND(QueryBuilderEnv &env)
Combine some queries with AND.
void set_query(const Xapian::Query &query, Xapian::termcount qlen=0)
Set the query to run.
static void builddb_queries1(Xapian::WritableDatabase &db, const string &arg)
Make a database in which docs have the fields:
static void push_leaf_N(QueryBuilderEnv &env)
Push a leaf query on field N onto the list of query pieces.
Match only documents which all subqueries match.
static Xapian::Query query(Xapian::Query::op op, const string &t1=string(), const string &t2=string(), const string &t3=string(), const string &t4=string(), const string &t5=string(), const string &t6=string(), const string &t7=string(), const string &t8=string(), const string &t9=string(), const string &t10=string())
QueryBuilderEnv env
The environment for the build steps.
This class provides an interface to the information retrieval system for the purpose of searching...
unsigned XAPIAN_DOCID_BASE_TYPE doccount
A count of documents.
Match documents which the first subquery matches but no others do.
Match documents which at least one subquery matches.
Xapian-specific test helper functions and macros.
static void combine_NOT(QueryBuilderEnv &env)
Combine some queries with AND_NOT.
static void combine_OR(QueryBuilderEnv &env)
Combine some queries with OR.
unsigned int randint(unsigned int s)
Return a random integer in the range 0 to s-1.
Class representing a query.
Long-running "soak" tests for Xapian.
unsigned int maxsteps
Maximum number of steps to take when building a query.
A handle representing a document in a Xapian database.
unsigned int initrand()
Initialise the random number generator with the seed.
void add_term(const std::string &tname, Xapian::termcount wdfinc=1)
Add a term to the document, without positional information.