35 #define COUNT_EXCEPTION(CODE, EXCEPTION) \
38 } catch (const Xapian::EXCEPTION&) { \
42 #define COUNT_CLOSED(CODE) COUNT_EXCEPTION(CODE, DatabaseClosedError)
77 int exception_count = 0;
84 "This is a test document used with"));
168 return exception_count;
179 int exception_count = iters.
perform();
192 for (
int i = 0; i != 6; ++i) {
193 fds.push_back(dup(1));
200 exception_count = iters.
perform();
232 const string & uuid = db.
get_uuid();
351 FAIL_TEST(
"Expected DatabaseClosedError wasn't thrown");
434 #define COUNT_NETWORK(CODE) COUNT_EXCEPTION(CODE, NetworkError)
469 int exception_count = 0;
476 "This is a test document used with"));
559 return exception_count;
569 if (getenv(
"XAPIAN_TESTSUITE_RUNNING_UNDER_WINE"))
570 SKIP_TEST(
"This testcase doesn't work under Wine");
577 int exception_count = iters.
perform();
589 for (
int i = 0; i != 6; ++i) {
590 fds.push_back(dup(1));
594 exception_count = iters.
perform();
614 if (getenv(
"XAPIAN_TESTSUITE_RUNNING_UNDER_WINE"))
615 SKIP_TEST(
"This testcase doesn't work under Wine");
618 const string & uuid = db.
get_uuid();
654 if (getenv(
"XAPIAN_TESTSUITE_RUNNING_UNDER_WINE"))
655 SKIP_TEST(
"This testcase doesn't work under Wine");
707 if (getenv(
"XAPIAN_TESTSUITE_RUNNING_UNDER_WINE"))
708 SKIP_TEST(
"This testcase doesn't work under Wine");
732 if (getenv(
"XAPIAN_TESTSUITE_RUNNING_UNDER_WINE"))
733 SKIP_TEST(
"This testcase doesn't work under Wine");
756 if (getenv(
"XAPIAN_TESTSUITE_RUNNING_UNDER_WINE"))
757 SKIP_TEST(
"This testcase doesn't work under Wine");
779 if (getenv(
"XAPIAN_TESTSUITE_RUNNING_UNDER_WINE"))
780 SKIP_TEST(
"This testcase doesn't work under Wine");
#define COUNT_NETWORK(CODE)
DEFINE_TESTCASE(closedb1, backend)
#define COUNT_CLOSED(CODE)
Xapian::Database get_writable_database_as_database()
Xapian::WritableDatabase get_writable_database(const string &dbname)
std::string get_named_writable_database_path(const std::string &name)
Xapian::Database get_database(const string &dbname)
Xapian::WritableDatabase get_named_writable_database(const std::string &name, const std::string &source)
void kill_remote(const Xapian::Database &db)
Kill the server associated with remote database db.
test functionality of the Xapian API
Indicates an attempt to access a closed database.
DatabaseLockError indicates failure to lock a database.
An indexed database of documents.
Xapian::TermIterator metadata_keys_begin(std::string_view prefix={}) const
An iterator which returns all user-specified metadata keys.
ValueIterator valuestream_begin(Xapian::valueno slot) const
Return an iterator over the value in slot slot for each document.
Xapian::doccount get_termfreq(std::string_view term) const
Get the number of documents indexed by a specified term.
Xapian::TermIterator synonym_keys_begin(std::string_view prefix={}) const
An iterator which returns all terms which have synonyms.
void close()
Close the database.
Xapian::TermIterator spellings_begin() const
An iterator which returns all the spelling correction targets.
PositionIterator positionlist_end(Xapian::docid, std::string_view) const noexcept
End iterator corresponding to positionlist_begin().
Xapian::termcount get_doclength_lower_bound() const
Get a lower bound on the length of a document in this DB.
PostingIterator postlist_begin(std::string_view term) const
Start iterating the postings of a term.
TermIterator termlist_begin(Xapian::docid did) const
Start iterating the terms in a document.
void keep_alive()
Send a keep-alive message.
double get_avlength() const
Old name for get_average_length() for backward compatibility.
Xapian::termcount get_wdf_upper_bound(std::string_view term) const
Get an upper bound on the wdf of term term.
PositionIterator positionlist_begin(Xapian::docid did, std::string_view term) const
Start iterating positions for a term in a document.
std::string get_value_upper_bound(Xapian::valueno slot) const
Get an upper bound on the values stored in the given value slot.
virtual std::string get_description() const
Return a string describing this object.
Xapian::termcount get_doclength(Xapian::docid did) const
Get the length of a specified document.
bool term_exists(std::string_view term) const
Test is a particular term is present in any document.
std::string get_value_lower_bound(Xapian::valueno slot) const
Get a lower bound on the values stored in the given value slot.
TermIterator allterms_end(std::string_view={}) const noexcept
End iterator corresponding to allterms_begin(prefix).
bool has_positions() const
Does this database have any positional information?
Xapian::termcount get_collection_freq(std::string_view term) const
Get the total number of occurrences of a specified term.
Xapian::doccount get_doccount() const
Get the number of documents in the database.
PostingIterator postlist_end(std::string_view) const noexcept
End iterator corresponding to postlist_begin().
TermIterator termlist_end(Xapian::docid) const noexcept
End iterator corresponding to termlist_begin().
Xapian::docid get_lastdocid() const
Get the highest document id which has been used in the database.
Xapian::doccount get_value_freq(Xapian::valueno slot) const
Return the frequency of a given value slot.
TermIterator allterms_begin(std::string_view prefix={}) const
Start iterating all terms in the database with a given prefix.
Xapian::TermIterator synonyms_begin(std::string_view term) const
An iterator which returns all the synonyms for a given term.
bool reopen()
Reopen the database at the latest available revision.
Xapian::termcount get_doclength_upper_bound() const
Get an upper bound on the length of a document in this DB.
std::string get_spelling_suggestion(std::string_view word, unsigned max_edit_distance=2) const
Suggest a spelling correction.
Xapian::Document get_document(Xapian::docid did, unsigned flags=0) const
Get a document from the database.
std::string get_uuid() const
Get the UUID for the database.
std::string get_metadata(std::string_view key) const
Get the user-specified metadata associated with a given key.
Xapian::termcount get_unique_terms(Xapian::docid did) const
Get the number of unique terms in a specified document.
Class representing a document.
std::string get_data() const
Get the document data.
std::string get_value(Xapian::valueno slot) const
Read a value slot in this document.
TermIterator termlist_begin() const
Start iterating the terms in this document.
InvalidOperationError indicates the API was used in an invalid way.
Indicates a problem communicating with a remote database.
Class for iterating over term positions.
Class for iterating over a list of terms.
Xapian::termcount get_doclength() const
Return the length of the document at the current position.
Xapian::termcount get_unique_terms() const
Return the number of unique terms in the current document.
Class for iterating over a list of terms.
Xapian::doccount get_termfreq() const
Return the term frequency for the term at the current position.
Xapian::termcount get_wdf() const
Return the wdf for the term at the current position.
This class provides read/write access to a database.
void delete_document(Xapian::docid did)
Delete a document from the database.
void clear_synonyms(std::string_view term) const
Remove all synonyms for a term.
void begin_transaction(bool flushed=true)
Begin a transaction.
void add_synonym(std::string_view term, std::string_view synonym) const
Add a synonym for a term.
void replace_document(Xapian::docid did, const Xapian::Document &document)
Replace a document in the database.
void set_metadata(std::string_view key, std::string_view metadata)
Set the user-specified metadata associated with a given key.
void commit_transaction()
Complete the transaction currently in progress.
void cancel_transaction()
Abort the transaction currently in progress.
void add_spelling(std::string_view word, Xapian::termcount freqinc=1) const
Add a word to the spelling dictionary.
termcount remove_spelling(std::string_view word, termcount freqdec=1) const
Remove a word from the spelling dictionary.
void commit()
Commit pending modifications.
Xapian::docid add_document(const Xapian::Document &doc)
Add a document to the database.
void remove_synonym(std::string_view term, std::string_view synonym) const
Remove a synonym for a term.
const int DB_OPEN
Open an existing database.
<unistd.h>, but with compat.
Xapian::PostingIterator pl1end
Xapian::TermIterator atl1
Xapian::PostingIterator pl1
Xapian::PositionIterator pil1
Xapian::TermIterator atlend
void setup(Xapian::Database db_)
Xapian::TermIterator tlend
Xapian::PostingIterator pl2end
Xapian::PostingIterator pl2
Xapian::PositionIterator pilend
Xapian::TermIterator atlend
Xapian::PositionIterator pilend
Xapian::TermIterator atl1
Xapian::TermIterator tlend
void setup(Xapian::Database db_)
Xapian::PostingIterator pl1
Xapian::PostingIterator pl2end
Xapian::PostingIterator pl2
Xapian::PositionIterator pil1
Xapian::PostingIterator pl1end
#define TEST_REL(A, REL, B)
Test a relation holds,e.g. TEST_REL(a,>,b);.
#define FAIL_TEST(MSG)
Fail the current testcase with message MSG.
#define SKIP_TEST(MSG)
Skip the current testcase with message MSG.
#define TEST_EQUAL(a, b)
Test for equality of two things.
#define TEST(a)
Test a condition, without an additional explanation for failure.
#define TEST_NOT_EQUAL(a, b)
Test for non-equality of two things.
Xapian-specific test helper functions and macros.
#define TEST_EXCEPTION(TYPE, CODE)
Check that CODE throws exactly Xapian exception TYPE.
Public interfaces for the Xapian library.