tests/api_db.cc File Reference

#include <config.h>
#include "api_db.h"
#include <algorithm>
#include <fstream>
#include <map>
#include <string>
#include <vector>
#include <xapian.h>
#include "backendmanager.h"
#include "backendmanager_local.h"
#include "testsuite.h"
#include "testutils.h"
#include "unixcmds.h"
#include "utils.h"
#include "apitest.h"
#include <list>

Include dependency graph for api_db.cc:

Go to the source code of this file.

Classes

class  myMatchDecider
class  myMatchDecider2
class  MyWeight

Defines

#define XAPIAN_DEPRECATED(D)   D

Functions

static Xapian::Query query (const string &t)
 DEFINE_TESTCASE (termstats, backend)
 DEFINE_TESTCASE (stubdb1, flint)
 DEFINE_TESTCASE (matchfunctor1, backend &&!remote)
 DEFINE_TESTCASE (matchfunctor2, backend &&!remote)
 DEFINE_TESTCASE (matchfunctor3, backend)
 DEFINE_TESTCASE (msetiterator1, backend)
 DEFINE_TESTCASE (msetiterator2, backend)
 DEFINE_TESTCASE (msetiterator3, backend)
 DEFINE_TESTCASE (esetiterator1, backend)
 DEFINE_TESTCASE (esetiterator2, backend)
 DEFINE_TESTCASE (collapsekey1, backend)
 DEFINE_TESTCASE (collapsekey2, backend)
 DEFINE_TESTCASE (collapsekey3, backend)
 DEFINE_TESTCASE (collapsekey4, backend)
 DEFINE_TESTCASE (keepalive1, remote)
 DEFINE_TESTCASE (allterms1, backend)
 DEFINE_TESTCASE (allterms2, backend)
 DEFINE_TESTCASE (allterms3, backend)
 DEFINE_TESTCASE (allterms4, backend)
 DEFINE_TESTCASE (allterms5, backend)
 DEFINE_TESTCASE (allterms6, backend)
 DEFINE_TESTCASE (specialterms1, backend)
 DEFINE_TESTCASE (specialterms2, backend)
 DEFINE_TESTCASE (rsetmultidb2, backend &&!multi)
 DEFINE_TESTCASE (multiexpand1, backend &&!multi)
 DEFINE_TESTCASE (postlist1, backend)
 DEFINE_TESTCASE (postlist2, backend)
 DEFINE_TESTCASE (postlist3, backend)
 DEFINE_TESTCASE (postlist4, backend)
 DEFINE_TESTCASE (postlist5, backend)
 DEFINE_TESTCASE (postlist6, backend)
 DEFINE_TESTCASE (collfreq1, backend)
 DEFINE_TESTCASE (sortvalue1, backend)
 DEFINE_TESTCASE (consistency1, backend &&!remote)
 DEFINE_TESTCASE (quartzdatabaseopeningerror1, quartz)
 DEFINE_TESTCASE (quartzdatabaseopen1, quartz)
 Test opening of a quartz database.
 DEFINE_TESTCASE (flintdatabaseopeningerror1, flint)
 DEFINE_TESTCASE (flintdatabaseformaterror1, flint)
 Tests that appropriate error is thrown for database format change.
 DEFINE_TESTCASE (flintdatabaseformaterror2, flint)
 Test that an old database can be successfully overwritten when using.
 DEFINE_TESTCASE (flintdatabaseformaterror3, flint)
 DEFINE_TESTCASE (flintbackwardcompat1, flint)
 DEFINE_TESTCASE (flintbackwardcompat2, flint)
 DEFINE_TESTCASE (flintdatabaseopen1, flint)
 Test opening of a flint database.
 DEFINE_TESTCASE (sortrel1, backend)
 DEFINE_TESTCASE (netstats1, remote)
 DEFINE_TESTCASE (userweight1, backend &&!remote)
 DEFINE_TESTCASE (matchall1, backend)


Define Documentation

#define XAPIAN_DEPRECATED (  )     D

Definition at line 35 of file api_db.cc.


Function Documentation

static Xapian::Query query ( const string &  t  )  [static]

Definition at line 52 of file api_db.cc.

DEFINE_TESTCASE ( termstats  ,
backend   
)

Definition at line 61 of file api_db.cc.

References get_database(), Xapian::Database::get_termfreq(), Xapian::Database::term_exists(), TEST, and TEST_EQUAL.

DEFINE_TESTCASE ( stubdb1  ,
flint   
)

Definition at line 75 of file api_db.cc.

References get_database(), Xapian::Enquire::get_mset(), BackendManager::get_xapian_progsrv_command(), Xapian::Auto::open_stub(), Xapian::Enquire::set_query(), TEST, and unlink().

DEFINE_TESTCASE ( matchfunctor1  ,
backend &&!  remote 
)

Definition at line 255 of file api_db.cc.

References Xapian::BAD_VALUENO, Xapian::MSet::begin(), Xapian::MSet::end(), get_database(), Xapian::Database::get_document(), Xapian::Database::get_lastdocid(), Xapian::MSet::get_matches_estimated(), Xapian::MSet::get_matches_lower_bound(), Xapian::MSet::get_matches_upper_bound(), Xapian::Enquire::get_mset(), Xapian::Enquire::set_collapse_key(), Xapian::Enquire::set_cutoff(), Xapian::Enquire::set_query(), Xapian::MSet::size(), TEST, and TEST_EQUAL.

DEFINE_TESTCASE ( matchfunctor2  ,
backend &&!  remote 
)

Definition at line 353 of file api_db.cc.

References Xapian::MSet::begin(), Xapian::MSet::end(), get_database(), Xapian::Database::get_document(), Xapian::Database::get_lastdocid(), Xapian::Enquire::get_mset(), Xapian::Enquire::set_query(), Xapian::MSet::size(), TEST, and TEST_EQUAL.

DEFINE_TESTCASE ( matchfunctor3  ,
backend   
)

Definition at line 395 of file api_db.cc.

References get_database(), Xapian::MSet::get_matches_estimated(), Xapian::MSet::get_matches_lower_bound(), Xapian::MSet::get_matches_upper_bound(), Xapian::Enquire::get_mset(), Xapian::Enquire::set_collapse_key(), Xapian::Enquire::set_query(), Xapian::Enquire::set_sort_by_value(), Xapian::MSet::size(), TEST_EQUAL, and TEST_LESSER_OR_EQUAL.

DEFINE_TESTCASE ( msetiterator1  ,
backend   
)

Definition at line 429 of file api_db.cc.

References Xapian::MSet::begin(), Xapian::MSet::end(), get_database(), Xapian::Enquire::get_mset(), Xapian::Enquire::set_query(), TEST_EQUAL, and TEST_NOT_EQUAL.

DEFINE_TESTCASE ( msetiterator2  ,
backend   
)

Definition at line 474 of file api_db.cc.

References Xapian::MSet::begin(), Xapian::MSet::end(), get_database(), Xapian::Enquire::get_mset(), Xapian::Enquire::set_query(), and TEST_EQUAL.

DEFINE_TESTCASE ( msetiterator3  ,
backend   
)

Definition at line 494 of file api_db.cc.

References Xapian::MSet::begin(), Xapian::MSet::empty(), get_database(), Xapian::Enquire::get_mset(), Xapian::Enquire::set_query(), and TEST.

DEFINE_TESTCASE ( esetiterator1  ,
backend   
)

Definition at line 509 of file api_db.cc.

References Xapian::ESet::begin(), Xapian::MSet::begin(), Xapian::ESet::end(), get_database(), Xapian::Enquire::get_eset(), Xapian::Enquire::get_mset(), Xapian::Enquire::set_query(), Xapian::MSet::size(), TEST, TEST_EQUAL, and TEST_NOT_EQUAL.

DEFINE_TESTCASE ( esetiterator2  ,
backend   
)

Definition at line 558 of file api_db.cc.

References Xapian::ESet::begin(), Xapian::MSet::begin(), Xapian::ESet::end(), get_database(), Xapian::Enquire::get_eset(), Xapian::Enquire::get_mset(), Xapian::Enquire::set_query(), Xapian::MSet::size(), TEST, and TEST_EQUAL.

DEFINE_TESTCASE ( collapsekey1  ,
backend   
)

Definition at line 586 of file api_db.cc.

References Xapian::MSet::begin(), Xapian::MSet::end(), get_database(), Xapian::MSetIterator::get_document(), Xapian::Enquire::get_mset(), Xapian::Document::get_value(), Xapian::Enquire::set_collapse_key(), Xapian::Enquire::set_query(), Xapian::MSet::size(), TEST, and TEST_AND_EXPLAIN.

DEFINE_TESTCASE ( collapsekey2  ,
backend   
)

Definition at line 614 of file api_db.cc.

References get_database(), Xapian::MSet::get_matches_lower_bound(), Xapian::MSet::get_matches_upper_bound(), Xapian::Enquire::get_mset(), Xapian::Enquire::set_collapse_key(), Xapian::Enquire::set_query(), SKIP_TEST, TEST, and TEST_EQUAL.

DEFINE_TESTCASE ( collapsekey3  ,
backend   
)

Definition at line 640 of file api_db.cc.

References Xapian::MSet::begin(), Xapian::MSet::end(), get_database(), Xapian::MSetIterator::get_document(), Xapian::MSet::get_matches_lower_bound(), Xapian::MSet::get_matches_upper_bound(), Xapian::Enquire::get_mset(), Xapian::Document::get_value(), Xapian::Enquire::set_collapse_key(), Xapian::Enquire::set_query(), TEST, TEST_AND_EXPLAIN, and TEST_EQUAL.

DEFINE_TESTCASE ( collapsekey4  ,
backend   
)

Definition at line 691 of file api_db.cc.

References Xapian::MSet::begin(), Xapian::MSet::end(), get_database(), Xapian::MSetIterator::get_document(), Xapian::MSet::get_matches_lower_bound(), Xapian::MSet::get_matches_upper_bound(), Xapian::Enquire::get_mset(), Xapian::Document::get_value(), Xapian::Enquire::set_collapse_key(), Xapian::Enquire::set_query(), TEST, and TEST_AND_EXPLAIN.

DEFINE_TESTCASE ( keepalive1  ,
remote   
)

Definition at line 719 of file api_db.cc.

References Xapian::Enquire::get_mset(), get_remote_database(), Xapian::Database::keep_alive(), Xapian::Enquire::set_query(), and TEST_EXCEPTION.

DEFINE_TESTCASE ( allterms1  ,
backend   
)

Definition at line 741 of file api_db.cc.

References Xapian::Database::allterms_begin(), Xapian::Database::allterms_end(), get_database(), Xapian::TermIterator::get_termfreq(), TEST, TEST_EQUAL, tout, and verbose.

DEFINE_TESTCASE ( allterms2  ,
backend   
)

Definition at line 789 of file api_db.cc.

References Xapian::Database::add_database(), Xapian::Database::allterms_begin(), Xapian::Database::allterms_end(), get_database(), Xapian::TermIterator::get_termfreq(), and TEST.

DEFINE_TESTCASE ( allterms3  ,
backend   
)

Definition at line 831 of file api_db.cc.

References Xapian::Database::add_database(), Xapian::Database::allterms_begin(), Xapian::Database::allterms_end(), get_database(), Xapian::TermIterator::skip_to(), and TEST.

DEFINE_TESTCASE ( allterms4  ,
backend   
)

Definition at line 844 of file api_db.cc.

References Xapian::Database::allterms_begin(), Xapian::Database::allterms_end(), get_database(), Xapian::TermIterator::get_termfreq(), and TEST.

DEFINE_TESTCASE ( allterms5  ,
backend   
)

Definition at line 861 of file api_db.cc.

References Xapian::Database::add_database(), Xapian::Database::allterms_begin(), Xapian::Database::allterms_end(), get_database(), Xapian::TermIterator::skip_to(), TEST, and TEST_EQUAL.

DEFINE_TESTCASE ( allterms6  ,
backend   
)

Definition at line 873 of file api_db.cc.

References Xapian::Database::add_database(), Xapian::Database::allterms_begin(), Xapian::Database::allterms_end(), get_database(), Xapian::TermIterator::skip_to(), TEST, and TEST_EQUAL.

DEFINE_TESTCASE ( specialterms1  ,
backend   
)

Definition at line 919 of file api_db.cc.

References Xapian::MSet::begin(), Xapian::MSet::end(), get_database(), Xapian::Enquire::get_mset(), Xapian::Enquire::set_query(), stemmer, TEST, TEST_EQUAL, TEST_MSET_SIZE, and TEST_NOT_EQUAL.

DEFINE_TESTCASE ( specialterms2  ,
backend   
)

Definition at line 956 of file api_db.cc.

References Xapian::Database::allterms_begin(), Xapian::Database::allterms_end(), get_database(), TEST_EQUAL, and TEST_NOT_EQUAL.

DEFINE_TESTCASE ( rsetmultidb2  ,
backend &&!  multi 
)

Definition at line 984 of file api_db.cc.

References Xapian::Database::add_database(), Xapian::RSet::add_document(), get_database(), Xapian::Enquire::get_mset(), mset_expect_order(), mset_range_is_same_weights(), query(), Xapian::Enquire::set_query(), TEST, and TEST_NOT_EQUAL.

DEFINE_TESTCASE ( multiexpand1  ,
backend &&!  multi 
)

Definition at line 1021 of file api_db.cc.

References Xapian::Database::add_database(), Xapian::RSet::add_document(), Xapian::ESet::begin(), Xapian::ESet::end(), get_database(), Xapian::Enquire::get_eset(), Xapian::ESetIterator::get_weight(), Xapian::ESet::size(), TEST, TEST_EQUAL, and Xapian::Enquire::USE_EXACT_TERMFREQ.

DEFINE_TESTCASE ( postlist1  ,
backend   
)

Definition at line 1072 of file api_db.cc.

References get_database(), Xapian::Database::postlist_begin(), Xapian::Database::postlist_end(), TEST_EQUAL, and TEST_NOT_EQUAL.

DEFINE_TESTCASE ( postlist2  ,
backend   
)

Definition at line 1090 of file api_db.cc.

References get_database(), Xapian::Database::postlist_begin(), Xapian::Database::postlist_end(), TEST_EQUAL, and TEST_NOT_EQUAL.

DEFINE_TESTCASE ( postlist3  ,
backend   
)

Definition at line 1119 of file api_db.cc.

References get_database(), Xapian::Database::postlist_begin(), Xapian::Database::postlist_end(), and TEST_EQUAL.

DEFINE_TESTCASE ( postlist4  ,
backend   
)

Definition at line 1139 of file api_db.cc.

References get_database(), Xapian::Database::postlist_begin(), Xapian::Database::postlist_end(), Xapian::PostingIterator::skip_to(), and TEST.

DEFINE_TESTCASE ( postlist5  ,
backend   
)

Definition at line 1149 of file api_db.cc.

References Xapian::Database::get_avlength(), get_database(), Xapian::Database::postlist_begin(), Xapian::Database::postlist_end(), TEST_EQUAL, and TEST_EQUAL_DOUBLE.

DEFINE_TESTCASE ( postlist6  ,
backend   
)

Definition at line 1166 of file api_db.cc.

References get_database(), Xapian::Database::get_doclength(), Xapian::PostingIterator::get_doclength(), Xapian::Database::postlist_begin(), Xapian::Database::postlist_end(), TEST, and TEST_EQUAL.

DEFINE_TESTCASE ( collfreq1  ,
backend   
)

Definition at line 1178 of file api_db.cc.

References Xapian::Database::add_database(), Xapian::Database::get_collection_freq(), get_database(), and TEST_EQUAL.

DEFINE_TESTCASE ( sortvalue1  ,
backend   
)

Definition at line 1203 of file api_db.cc.

References Xapian::MSet::begin(), Xapian::Enquire::DESCENDING, Xapian::MSet::end(), FAIL_TEST, get_database(), Xapian::Enquire::get_mset(), Xapian::Enquire::set_docid_order(), Xapian::Enquire::set_query(), Xapian::Enquire::set_sort_by_value(), Xapian::MSet::size(), TEST, TEST_EQUAL, and tout.

DEFINE_TESTCASE ( consistency1  ,
backend &&!  remote 
)

Definition at line 1249 of file api_db.cc.

References get_database(), Xapian::Enquire::get_mset(), Xapian::Query::OP_OR, Xapian::Enquire::set_query(), size, Xapian::MSet::size(), SKIP_TEST, TEST, TEST_EQUAL, and TEST_EQUAL_DOUBLE.

DEFINE_TESTCASE ( quartzdatabaseopeningerror1  ,
quartz   
)

Definition at line 1283 of file api_db.cc.

References Xapian::DB_CREATE, Xapian::DB_CREATE_OR_OPEN, Xapian::DB_CREATE_OR_OVERWRITE, Xapian::DB_OPEN, mkdir(), Xapian::Quartz::open(), TEST_EXCEPTION, and touch().

DEFINE_TESTCASE ( quartzdatabaseopen1  ,
quartz   
)

Test opening of a quartz database.

Definition at line 1311 of file api_db.cc.

References Xapian::DB_CREATE, Xapian::DB_CREATE_OR_OPEN, Xapian::DB_CREATE_OR_OVERWRITE, Xapian::DB_OPEN, mkdir(), Xapian::Quartz::open(), rm_rf(), and TEST_EXCEPTION.

DEFINE_TESTCASE ( flintdatabaseopeningerror1  ,
flint   
)

Definition at line 1376 of file api_db.cc.

References Xapian::DB_CREATE, Xapian::DB_CREATE_OR_OPEN, Xapian::DB_CREATE_OR_OVERWRITE, Xapian::DB_OPEN, mkdir(), Xapian::Flint::open(), TEST_EXCEPTION, and touch().

DEFINE_TESTCASE ( flintdatabaseformaterror1  ,
flint   
)

Tests that appropriate error is thrown for database format change.

Definition at line 1404 of file api_db.cc.

References test_driver::get_srcdir(), Xapian::Flint::open(), TEST_EXCEPTION, and unlink().

DEFINE_TESTCASE ( flintdatabaseformaterror2  ,
flint   
)

Test that an old database can be successfully overwritten when using.

Definition at line 1426 of file api_db.cc.

References cp_R(), Xapian::DB_CREATE_OR_OVERWRITE, test_driver::get_srcdir(), mkdir(), Xapian::Flint::open(), and rm_rf().

DEFINE_TESTCASE ( flintdatabaseformaterror3  ,
flint   
)

Definition at line 1448 of file api_db.cc.

References cp_R(), Xapian::DB_CREATE_OR_OPEN, Xapian::DB_CREATE_OR_OVERWRITE, test_driver::get_srcdir(), mkdir(), rm_rf(), and TEST_EXCEPTION.

DEFINE_TESTCASE ( flintbackwardcompat1  ,
flint   
)

Definition at line 1469 of file api_db.cc.

References cp_R(), Xapian::DB_OPEN, Xapian::Database::get_doccount(), test_driver::get_srcdir(), mkdir(), rm_rf(), and TEST_EQUAL.

DEFINE_TESTCASE ( flintbackwardcompat2  ,
flint   
)

Definition at line 1495 of file api_db.cc.

References cp_R(), Xapian::DB_OPEN, Xapian::Database::get_doccount(), test_driver::get_srcdir(), mkdir(), rm_rf(), and TEST_EQUAL.

DEFINE_TESTCASE ( flintdatabaseopen1  ,
flint   
)

Test opening of a flint database.

Definition at line 1521 of file api_db.cc.

References Xapian::DB_CREATE, Xapian::DB_CREATE_OR_OPEN, Xapian::DB_CREATE_OR_OVERWRITE, Xapian::DB_OPEN, mkdir(), Xapian::Flint::open(), rm_rf(), and TEST_EXCEPTION.

DEFINE_TESTCASE ( sortrel1  ,
backend   
)

Definition at line 1579 of file api_db.cc.

References Xapian::Enquire::ASCENDING, Xapian::Enquire::DESCENDING, get_database(), Xapian::Enquire::get_mset(), Xapian::Enquire::set_docid_order(), Xapian::Enquire::set_query(), Xapian::Enquire::set_sort_by_relevance_then_value(), Xapian::Enquire::set_sort_by_value(), Xapian::Enquire::set_sort_by_value_then_relevance(), Xapian::MSet::size(), and TEST_EQUAL.

DEFINE_TESTCASE ( netstats1  ,
remote   
)

Definition at line 1705 of file api_db.cc.

References Xapian::Database::add_database(), Xapian::RSet::add_document(), BackendManagerLocal, get_database(), Xapian::Enquire::get_mset(), test_driver::get_srcdir(), Xapian::Query::OP_OR, query(), Xapian::Enquire::set_query(), and TEST_EQUAL.

DEFINE_TESTCASE ( userweight1  ,
backend &&!  remote 
)

Definition at line 1789 of file api_db.cc.

References Xapian::MSet::begin(), Xapian::MSet::end(), get_database(), Xapian::Enquire::get_matching_terms_begin(), Xapian::Enquire::get_matching_terms_end(), Xapian::Enquire::get_mset(), Xapian::Query::OP_OR, query(), Xapian::Enquire::set_query(), Xapian::Enquire::set_weighting_scheme(), and TEST_EQUAL.

DEFINE_TESTCASE ( matchall1  ,
backend   
)

Definition at line 1815 of file api_db.cc.

References get_database(), Xapian::Database::get_doccount(), Xapian::MSet::get_matches_lower_bound(), Xapian::Enquire::get_mset(), Xapian::Query::MatchAll, Xapian::Query::OP_OR, Xapian::Enquire::set_query(), Xapian::MSet::size(), TEST, and TEST_EQUAL.


Documentation for Xapian (version 1.0.10).
Generated on 24 Dec 2008 by Doxygen 1.5.2.