38 static const int keys[] = { 3, 1 };
45 for (
auto m = mset.
begin(); m != mset.
end(); ++m) {
46 const string& data = m.get_document().get_data();
49 exp += string(2,
'\0');
64 for (
auto m = mset.
begin(); m != mset.
end(); ++m) {
65 const string& data = m.get_document().get_data();
68 exp += string(2,
'\0');
69 exp += char(0xff - data[1]);
70 exp += string(2,
'\xff');
85 for (
auto m = mset.
begin(); m != mset.
end(); ++m) {
86 const string& data = m.get_document().get_data();
88 exp += string(2,
'\0');
90 exp += string(2,
'\0');
91 exp += char(0xff - data[1]);
92 exp += string(2,
'\xff');
106 for (
auto m = mset.
begin(); m != mset.
end(); ++m) {
107 const string& data = m.get_document().get_data();
109 if (data.size() > 10) exp += data[10];
110 exp += string(2,
'\0');
111 exp += char(0xff - data[1]);
112 exp += string(2,
'\xff');
143 enquire.set_sort_by_key(&sorter,
true);
151 enquire.set_sort_by_key(&sorter,
true);
160 enquire.set_sort_by_key(&sorter,
true);
169 enquire.set_sort_by_key(&sorter,
true);
178 enquire.set_sort_by_key(&sorter,
true);
187 enquire.set_sort_by_key(&sorter,
true);
255 FAIL_TEST(
"NeverUseMeKeyMaker was called");
289 FAIL_TEST(
"NeverUseMeKeyMaker::operator() didn't throw TestFail");
310 static const int keys[] = { 0, 1, 2, 3 };
314 TEST(sorter(doc).empty());
317 TEST_EQUAL(sorter(doc),
string(
"\0\0foo", 5));
319 TEST_EQUAL(sorter(doc),
string(
"\0\0f\0\xffo", 6));
321 TEST_EQUAL(sorter(doc),
string(
"\0\0f\0\xffo\0\0\0\0xyz", 13));
325 TEST_EQUAL(sorter(doc),
string(
"\0\0f\0\xffo\0\0\0\0xyz\0\0\xff\xff", 17));
329 TEST_EQUAL(sorter(doc),
string(
"\0\0f\0\xffo\0\0\0\0xyz\0\0\xff\xff", 17));
333 TEST_EQUAL(sorter(doc),
string(
"\0\0f\0\xffo\0\0\0\0xyz\0\0\xff\xff\0\0hi",
338 TEST_EQUAL(sorter(doc),
string(
"\0\0f\0\xffo\0\0\0\0xyz\0\0\xff\xff\0\0hi" 339 "\0\0\x97\x96\xff\xff", 27));
Xapian::doccount size() const
Return number of items in this MSet object.
Xapian::docid add_document(const Xapian::Document &document)
Add a new document to the database.
void add_value(Xapian::valueno slot, const std::string &value)
Add a new value.
void set_sort_by_value_then_relevance(Xapian::valueno sort_key, bool reverse)
Set the sorting to be by value, then by relevance for documents with the same value.
void set_sort_by_relevance()
Set the sorting to be by relevance only.
#define TEST(a)
Test a condition, without an additional explanation for failure.
Class which is thrown when a test case fails.
This class is used to access a database, or a group of databases.
void set_sort_by_value(Xapian::valueno sort_key, bool reverse)
Set the sorting to be by value only.
void add_value(Xapian::valueno slot, bool reverse=false, const std::string &defvalue=std::string())
Add a value slot to the list to build a key from.
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.
std::string get_value_upper_bound(Xapian::valueno slot) const
Get an upper bound on the values stored in the given value slot.
test functionality of the Xapian API
KeyMaker subclass which combines several values.
This class provides read/write access to a database.
Public interfaces for the Xapian library.
void set_sort_by_relevance_then_value(Xapian::valueno sort_key, bool reverse)
Set the sorting to be by relevance then value.
#define TEST_EXCEPTION(TYPE, CODE)
Check that CODE throws exactly Xapian exception TYPE.
MSetIterator begin() const
Return iterator pointing to the first item in this MSet.
MSetIterator end() const
Return iterator pointing to just after the last item in this MSet.
void set_query(const Xapian::Query &query, Xapian::termcount qlen=0)
Set the query to run.
#define FAIL_TEST(MSG)
Fail the current testcase with message MSG.
Xapian::Database get_database(const string &dbname)
This class provides an interface to the information retrieval system for the purpose of searching...
Xapian-specific test helper functions and macros.
void mset_expect_order(const Xapian::MSet &A, Xapian::docid d1, Xapian::docid d2, Xapian::docid d3, Xapian::docid d4, Xapian::docid d5, Xapian::docid d6, Xapian::docid d7, Xapian::docid d8, Xapian::docid d9, Xapian::docid d10, Xapian::docid d11, Xapian::docid d12)
DEFINE_TESTCASE(sortfunctor1, backend &&!remote)
Class representing a query.
#define TEST_EQUAL(a, b)
Test for equality of two things.
A handle representing a document in a Xapian database.
void set_sort_by_key(Xapian::KeyMaker *sorter, bool reverse)
Set the sorting to be by key generated from values only.
Virtual base class for key making functors.
UnimplementedError indicates an attempt to use an unimplemented feature.
void add_term(const std::string &tname, Xapian::termcount wdfinc=1)
Add a term to the document, without positional information.