xapian-core
1.4.26
|
tests of Xapian::Weight subclasses More...
#include <config.h>
#include "api_weight.h"
#include <cmath>
#include <memory>
#include <xapian.h>
#include "apitest.h"
#include "testutils.h"
Go to the source code of this file.
Classes | |
class | CheckInitWeight |
class | CheckStatsWeight |
Macros | |
#define | TEST_WEIGHT_CLASS_NO_PARAMS(W) test_weight_class_no_params<W>(#W) |
#define | TEST_WEIGHT_CLASS(W, DEFAULT, OTHER) test_weight_class<W>(#W, W DEFAULT, W OTHER) |
#define | TEST_WEIGHTING_SCHEME(W, ...) helper(W(__VA_ARGS__), #W, "" #__VA_ARGS__) |
Functions | |
template<class W > | |
static void | test_weight_class_no_params (const char *name) |
template<class W > | |
static void | test_weight_class (const char *name, const W &obj_default, const W &obj_other) |
DEFINE_TESTCASE (weightserialisation1, !backend) | |
Test serialisation and introspection of built-in weighting schemes. More... | |
DEFINE_TESTCASE (weight1, backend) | |
Basic test of using weighting schemes. More... | |
DEFINE_TESTCASE (bm25weight1, backend) | |
Regression test for bug fixed in 1.0.5. More... | |
DEFINE_TESTCASE (bm25weight4, backend) | |
DEFINE_TESTCASE (bm25weight5, backend) | |
Test non-zero k2 with zero k1. More... | |
DEFINE_TESTCASE (bm25plusweight2, backend) | |
DEFINE_TESTCASE (bm25plusweight3, backend) | |
DEFINE_TESTCASE (inl2weight2, !backend) | |
DEFINE_TESTCASE (inl2weight3, backend) | |
DEFINE_TESTCASE (ifb2weight2, !backend) | |
DEFINE_TESTCASE (ifb2weight3, backend) | |
DEFINE_TESTCASE (ineb2weight2, !backend) | |
DEFINE_TESTCASE (ineb2weight3, backend) | |
DEFINE_TESTCASE (bb2weight2, !backend) | |
DEFINE_TESTCASE (bb2weight3, backend) | |
DEFINE_TESTCASE (bb2weight4, backend) | |
DEFINE_TESTCASE (dlhweight1, backend) | |
static void | gen_wdf_eq_doclen_db (Xapian::WritableDatabase &db, const string &) |
DEFINE_TESTCASE (dlhweight3, backend) | |
DEFINE_TESTCASE (pl2weight2, !backend) | |
DEFINE_TESTCASE (pl2weight3, backend) | |
DEFINE_TESTCASE (pl2plusweight2, !backend) | |
DEFINE_TESTCASE (pl2plusweight4, backend) | |
DEFINE_TESTCASE (pl2plusweight5, backend) | |
DEFINE_TESTCASE (dphweight1, backend) | |
DEFINE_TESTCASE (dphweight3, backend) | |
DEFINE_TESTCASE (tfidfweight1, !backend) | |
DEFINE_TESTCASE (tfidfweight3, backend) | |
DEFINE_TESTCASE (checkinitweight1, backend &&!multi &&!remote) | |
Regression test - check init() is called for the term-indep Weight obj. More... | |
DEFINE_TESTCASE (checkstatsweight1, backend &&!remote) | |
Check the weight subclass gets the correct stats. More... | |
DEFINE_TESTCASE (checkstatsweight2, backend &&!remote) | |
Check the weight subclass gets the correct stats with OP_SYNONYM. More... | |
DEFINE_TESTCASE (checkstatsweight3, backend &&!remote) | |
Check the weight subclass gets the correct stats with OP_WILDCARD. More... | |
DEFINE_TESTCASE (checkstatsweight4, backend &&!remote &&!multi) | |
Check the stats for a repeated term are correct. More... | |
DEFINE_TESTCASE (unigramlmweight4, backend) | |
DEFINE_TESTCASE (unigramlmweight5, backend) | |
DEFINE_TESTCASE (unigramlmweight7, backend) | |
DEFINE_TESTCASE (unigramlmweight8, backend) | |
DEFINE_TESTCASE (coordweight1, backend) | |
tests of Xapian::Weight subclasses
Definition in file api_weight.cc.
#define TEST_WEIGHT_CLASS | ( | W, | |
DEFAULT, | |||
OTHER | |||
) | test_weight_class<W>(#W, W DEFAULT, W OTHER) |
Definition at line 108 of file api_weight.cc.
Referenced by DEFINE_TESTCASE().
#define TEST_WEIGHT_CLASS_NO_PARAMS | ( | W | ) | test_weight_class_no_params<W>(#W) |
Definition at line 63 of file api_weight.cc.
Referenced by DEFINE_TESTCASE().
#define TEST_WEIGHTING_SCHEME | ( | W, | |
... | |||
) | helper(W(__VA_ARGS__), #W, "" #__VA_ARGS__) |
Referenced by DEFINE_TESTCASE().
DEFINE_TESTCASE | ( | weightserialisation1 | , |
! | backend | ||
) |
Test serialisation and introspection of built-in weighting schemes.
Definition at line 112 of file api_weight.cc.
References Xapian::Weight::JELINEK_MERCER_SMOOTHING, TEST_WEIGHT_CLASS, TEST_WEIGHT_CLASS_NO_PARAMS, and Xapian::Weight::TWO_STAGE_SMOOTHING.
DEFINE_TESTCASE | ( | weight1 | , |
backend | |||
) |
Basic test of using weighting schemes.
Definition at line 142 of file api_weight.cc.
References Xapian::MSet::back(), get_database(), Xapian::Enquire::get_mset(), Xapian::Database::get_termfreq(), Xapian::MSetIterator::get_weight(), name, Xapian::Enquire::set_query(), Xapian::Enquire::set_weighting_scheme(), Xapian::MSet::size(), TEST_EQUAL, TEST_EQUAL_DOUBLE, TEST_NOT_EQUAL, TEST_WEIGHTING_SCHEME, and tout.
DEFINE_TESTCASE | ( | bm25weight1 | , |
backend | |||
) |
Regression test for bug fixed in 1.0.5.
This test would fail under valgrind because it used an uninitialised value.
Definition at line 216 of file api_weight.cc.
References get_database(), Xapian::Enquire::get_mset(), Xapian::Enquire::set_query(), and Xapian::Enquire::set_weighting_scheme().
DEFINE_TESTCASE | ( | bm25weight4 | , |
backend | |||
) |
Definition at line 225 of file api_weight.cc.
References get_database(), Xapian::Enquire::get_mset(), Xapian::Enquire::set_query(), Xapian::Enquire::set_weighting_scheme(), Xapian::MSet::size(), TEST_EQUAL, TEST_EQUAL_DOUBLE, and TEST_REL.
DEFINE_TESTCASE | ( | bm25weight5 | , |
backend | |||
) |
Test non-zero k2 with zero k1.
Definition at line 249 of file api_weight.cc.
References get_database(), Xapian::Enquire::get_mset(), mset_expect_order(), Xapian::Enquire::set_query(), Xapian::Enquire::set_weighting_scheme(), Xapian::MSet::size(), TEST_EQUAL, TEST_EQUAL_DOUBLE, and TEST_REL.
DEFINE_TESTCASE | ( | bm25plusweight2 | , |
backend | |||
) |
Definition at line 267 of file api_weight.cc.
References get_database(), Xapian::Enquire::get_mset(), Xapian::Enquire::set_query(), Xapian::Enquire::set_weighting_scheme(), Xapian::MSet::size(), TEST_EQUAL, TEST_EQUAL_DOUBLE, and TEST_REL.
DEFINE_TESTCASE | ( | bm25plusweight3 | , |
backend | |||
) |
Definition at line 290 of file api_weight.cc.
References get_database(), Xapian::Enquire::get_mset(), Xapian::Enquire::set_query(), Xapian::Enquire::set_weighting_scheme(), Xapian::MSet::size(), TEST_EQUAL, and TEST_EQUAL_DOUBLE.
DEFINE_TESTCASE | ( | inl2weight2 | , |
! | backend | ||
) |
Definition at line 311 of file api_weight.cc.
References TEST_EXCEPTION.
DEFINE_TESTCASE | ( | inl2weight3 | , |
backend | |||
) |
Definition at line 321 of file api_weight.cc.
References get_database(), Xapian::Enquire::get_mset(), mset_expect_order(), query(), Xapian::Enquire::set_query(), Xapian::Enquire::set_weighting_scheme(), Xapian::MSet::size(), TEST_EQUAL, and TEST_EQUAL_DOUBLE.
DEFINE_TESTCASE | ( | ifb2weight2 | , |
! | backend | ||
) |
Definition at line 340 of file api_weight.cc.
References TEST_EXCEPTION.
DEFINE_TESTCASE | ( | ifb2weight3 | , |
backend | |||
) |
Definition at line 350 of file api_weight.cc.
References get_database(), Xapian::Enquire::get_mset(), query(), Xapian::Enquire::set_query(), Xapian::Enquire::set_weighting_scheme(), Xapian::MSet::size(), TEST_EQUAL, and TEST_EQUAL_DOUBLE.
DEFINE_TESTCASE | ( | ineb2weight2 | , |
! | backend | ||
) |
Definition at line 368 of file api_weight.cc.
References TEST_EXCEPTION.
DEFINE_TESTCASE | ( | ineb2weight3 | , |
backend | |||
) |
Definition at line 378 of file api_weight.cc.
References get_database(), Xapian::Enquire::get_mset(), query(), Xapian::Enquire::set_query(), Xapian::Enquire::set_weighting_scheme(), Xapian::MSet::size(), TEST_EQUAL, and TEST_EQUAL_DOUBLE.
DEFINE_TESTCASE | ( | bb2weight2 | , |
! | backend | ||
) |
Definition at line 396 of file api_weight.cc.
References TEST_EXCEPTION.
DEFINE_TESTCASE | ( | bb2weight3 | , |
backend | |||
) |
Definition at line 406 of file api_weight.cc.
References get_database(), Xapian::Enquire::get_mset(), Xapian::Query::OP_SCALE_WEIGHT, query(), Xapian::Enquire::set_query(), Xapian::Enquire::set_weighting_scheme(), Xapian::MSet::size(), TEST_EQUAL, and TEST_EQUAL_DOUBLE.
DEFINE_TESTCASE | ( | bb2weight4 | , |
backend | |||
) |
Definition at line 437 of file api_weight.cc.
References get_database(), Xapian::Enquire::get_mset(), query(), Xapian::Enquire::set_query(), Xapian::Enquire::set_weighting_scheme(), Xapian::MSet::size(), TEST_EQUAL, and TEST_EQUAL_DOUBLE.
DEFINE_TESTCASE | ( | dlhweight1 | , |
backend | |||
) |
Definition at line 452 of file api_weight.cc.
References get_database(), Xapian::Enquire::get_mset(), mset_expect_order(), query(), Xapian::Enquire::set_query(), Xapian::Enquire::set_weighting_scheme(), Xapian::MSet::size(), TEST_EQUAL, and TEST_EQUAL_DOUBLE.
DEFINE_TESTCASE | ( | dlhweight3 | , |
backend | |||
) |
Definition at line 480 of file api_weight.cc.
References gen_wdf_eq_doclen_db(), get_database(), Xapian::Enquire::get_mset(), query(), Xapian::Enquire::set_query(), Xapian::Enquire::set_weighting_scheme(), Xapian::MSet::size(), TEST_EQUAL, and TEST_EQUAL_DOUBLE.
DEFINE_TESTCASE | ( | pl2weight2 | , |
! | backend | ||
) |
Definition at line 496 of file api_weight.cc.
References TEST_EXCEPTION.
DEFINE_TESTCASE | ( | pl2weight3 | , |
backend | |||
) |
Definition at line 503 of file api_weight.cc.
References get_database(), Xapian::Enquire::get_mset(), query(), Xapian::Enquire::set_query(), Xapian::Enquire::set_weighting_scheme(), Xapian::MSet::size(), TEST_EQUAL, and TEST_EQUAL_DOUBLE.
DEFINE_TESTCASE | ( | pl2plusweight2 | , |
! | backend | ||
) |
Definition at line 520 of file api_weight.cc.
References TEST_EXCEPTION.
DEFINE_TESTCASE | ( | pl2plusweight4 | , |
backend | |||
) |
Definition at line 531 of file api_weight.cc.
References get_database(), Xapian::Enquire::get_mset(), Xapian::Enquire::set_query(), Xapian::Enquire::set_weighting_scheme(), Xapian::MSet::size(), TEST_EQUAL, and TEST_EQUAL_DOUBLE.
DEFINE_TESTCASE | ( | pl2plusweight5 | , |
backend | |||
) |
Definition at line 547 of file api_weight.cc.
References get_database(), Xapian::Enquire::get_mset(), mset_expect_order(), query(), Xapian::Enquire::set_query(), Xapian::Enquire::set_weighting_scheme(), Xapian::MSet::size(), and TEST_EQUAL.
DEFINE_TESTCASE | ( | dphweight1 | , |
backend | |||
) |
Definition at line 564 of file api_weight.cc.
References get_database(), Xapian::Enquire::get_mset(), query(), Xapian::Enquire::set_query(), Xapian::Enquire::set_weighting_scheme(), Xapian::MSet::size(), TEST_EQUAL, and TEST_EQUAL_DOUBLE.
DEFINE_TESTCASE | ( | dphweight3 | , |
backend | |||
) |
Definition at line 581 of file api_weight.cc.
References gen_wdf_eq_doclen_db(), get_database(), Xapian::Enquire::get_mset(), query(), Xapian::Enquire::set_query(), Xapian::Enquire::set_weighting_scheme(), Xapian::MSet::size(), TEST_EQUAL, and TEST_EQUAL_DOUBLE.
DEFINE_TESTCASE | ( | tfidfweight1 | , |
! | backend | ||
) |
Definition at line 597 of file api_weight.cc.
References TEST_EXCEPTION.
DEFINE_TESTCASE | ( | tfidfweight3 | , |
backend | |||
) |
Definition at line 607 of file api_weight.cc.
References get_database(), Xapian::Enquire::get_mset(), mset_expect_order(), query(), Xapian::Enquire::set_query(), Xapian::Enquire::set_weighting_scheme(), Xapian::MSet::size(), TEST_EQUAL, and TEST_EQUAL_DOUBLE.
DEFINE_TESTCASE | ( | checkinitweight1 | , |
backend &&!multi &&! | remote | ||
) |
Regression test - check init() is called for the term-indep Weight obj.
Definition at line 750 of file api_weight.cc.
References get_database(), Xapian::Enquire::get_mset(), Xapian::Query::OP_AND, Xapian::Enquire::set_query(), Xapian::Enquire::set_weighting_scheme(), and TEST_EQUAL.
DEFINE_TESTCASE | ( | checkstatsweight1 | , |
backend &&! | remote | ||
) |
Check the weight subclass gets the correct stats.
Definition at line 925 of file api_weight.cc.
References Xapian::Database::allterms_begin(), Xapian::Database::allterms_end(), get_database(), Xapian::Database::get_doccount(), Xapian::Enquire::get_mset(), Xapian::PostingIterator::get_wdf(), Xapian::Database::postlist_begin(), Xapian::Database::postlist_end(), Xapian::Enquire::set_query(), Xapian::Enquire::set_weighting_scheme(), and TEST_EQUAL.
DEFINE_TESTCASE | ( | checkstatsweight2 | , |
backend &&! | remote | ||
) |
Check the weight subclass gets the correct stats with OP_SYNONYM.
Definition at line 959 of file api_weight.cc.
References Xapian::Database::allterms_begin(), Xapian::Database::allterms_end(), get_database(), Xapian::Query::get_description(), Xapian::Database::get_doccount(), Xapian::Enquire::get_mset(), Xapian::PostingIterator::get_wdf(), Xapian::Query::OP_SYNONYM, Xapian::Database::postlist_begin(), Xapian::Database::postlist_end(), Xapian::Enquire::set_query(), Xapian::Enquire::set_weighting_scheme(), TEST_EQUAL, and tout.
DEFINE_TESTCASE | ( | checkstatsweight3 | , |
backend &&! | remote | ||
) |
Check the weight subclass gets the correct stats with OP_WILDCARD.
Definition at line 1031 of file api_weight.cc.
References Xapian::Database::allterms_begin(), Xapian::Database::allterms_end(), get_database(), Xapian::Query::get_description(), Xapian::Database::get_doccount(), Xapian::Enquire::get_mset(), Xapian::Query::OP_WILDCARD, Xapian::Database::postlist_begin(), Xapian::Enquire::set_query(), Xapian::Enquire::set_weighting_scheme(), TEST_EQUAL, TEST_REL, testcases, tout, and XFAIL_FOR_BACKEND().
DEFINE_TESTCASE | ( | checkstatsweight4 | , |
backend &&!remote &&! | multi | ||
) |
Check the stats for a repeated term are correct.
Definition at line 1109 of file api_weight.cc.
References Xapian::Database::allterms_begin(), Xapian::Database::allterms_end(), get_database(), Xapian::Database::get_doccount(), Xapian::Enquire::get_mset(), Xapian::PostingIterator::get_wdf(), Xapian::Database::postlist_begin(), Xapian::Database::postlist_end(), Xapian::Enquire::set_query(), Xapian::Enquire::set_weighting_scheme(), and TEST_EQUAL.
DEFINE_TESTCASE | ( | unigramlmweight4 | , |
backend | |||
) |
Definition at line 1143 of file api_weight.cc.
References get_database(), Xapian::Enquire::get_mset(), Xapian::Weight::JELINEK_MERCER_SMOOTHING, Xapian::Enquire::set_query(), Xapian::Enquire::set_weighting_scheme(), Xapian::MSet::size(), TEST_EQUAL, TEST_EQUAL_DOUBLE, and Xapian::Weight::TWO_STAGE_SMOOTHING.
DEFINE_TESTCASE | ( | unigramlmweight5 | , |
backend | |||
) |
Definition at line 1163 of file api_weight.cc.
References Xapian::Weight::ABSOLUTE_DISCOUNT_SMOOTHING, Xapian::Weight::DIRICHLET_SMOOTHING, get_database(), Xapian::Enquire::get_mset(), Xapian::Weight::JELINEK_MERCER_SMOOTHING, Xapian::Enquire::set_query(), Xapian::Enquire::set_weighting_scheme(), Xapian::MSet::size(), TEST_EQUAL, TEST_EQUAL_DOUBLE, and Xapian::Weight::TWO_STAGE_SMOOTHING.
DEFINE_TESTCASE | ( | unigramlmweight7 | , |
backend | |||
) |
Definition at line 1203 of file api_weight.cc.
References Xapian::Weight::DIRICHLET_PLUS_SMOOTHING, Xapian::Weight::DIRICHLET_SMOOTHING, get_database(), Xapian::Enquire::get_mset(), Xapian::Enquire::set_query(), Xapian::Enquire::set_weighting_scheme(), Xapian::MSet::size(), TEST_EQUAL, and TEST_REL.
DEFINE_TESTCASE | ( | unigramlmweight8 | , |
backend | |||
) |
Definition at line 1232 of file api_weight.cc.
References Xapian::Weight::DIRICHLET_SMOOTHING, get_database(), Xapian::Enquire::get_mset(), Xapian::Query::OP_SCALE_WEIGHT, query(), Xapian::Enquire::set_query(), Xapian::Enquire::set_weighting_scheme(), Xapian::MSet::size(), TEST_EQUAL, TEST_EQUAL_DOUBLE, and TEST_NOT_EQUAL_DOUBLE.
DEFINE_TESTCASE | ( | coordweight1 | , |
backend | |||
) |
Definition at line 1257 of file api_weight.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.
|
static |
Definition at line 472 of file api_weight.cc.
References Xapian::WritableDatabase::add_document(), and Xapian::Document::add_term().
Referenced by DEFINE_TESTCASE().
|
inlinestatic |
Definition at line 67 of file api_weight.cc.
References CONST_STRLEN, FAIL_TEST, Xapian::Error::get_msg(), name, Xapian::Weight::serialise(), TEST, TEST_EQUAL, TEST_NOT_EQUAL, and tout.
|
inlinestatic |
Definition at line 38 of file api_weight.cc.
References CONST_STRLEN, FAIL_TEST, Xapian::Error::get_msg(), name, TEST, TEST_EQUAL, and tout.