|
xapian-core
2.0.0
|
tests of Xapian::Weight subclasses More...
#include <config.h>#include "api_weight.h"#include <cmath>#include <memory>#include <xapian.h>#include "apitest.h"#include "heap.h"#include "testutils.h"
Include dependency graph for api_weight.cc:Go to the source code of this file.
Classes | |
| class | CheckInitWeight |
| class | CheckStatsWeight |
| class | CheckStatsWeight5 |
Macros | |
| #define | XAPIAN_DEPRECATED(D) D |
| #define | TEST_WEIGHT_CLASS_NO_PARAMS(W, N) test_weight_class_no_params<W>(#W, N) |
| #define | TEST_WEIGHT_CLASS(W, N, DEFAULT, OTHER) test_weight_class<W>(#W, N, 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 *classname, const char *name) |
| template<class W > | |
| static void | test_weight_class (const char *classname, 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 (weightcreate1, !backend) | |
| Feature tests for Weight::create(). More... | |
| DEFINE_TESTCASE (bm25weight1, backend) | |
| Regression test for bug fixed in 1.0.5. More... | |
| DEFINE_TESTCASE (bm25weight2, !backend) | |
| Test Weight::create() for BM25Weight. 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 (tfidfweight4, backend) | |
| DEFINE_TESTCASE (tfidfweight5, !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 (checkstatsweight6, 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 (checkstatsweight5, backend &&!multi &&!remote) | |
| Check wdfdocmax is clamped to doclen even if wdf and doclen aren't wanted. More... | |
| DEFINE_TESTCASE (lmdirichletweight1, backend) | |
| DEFINE_TESTCASE (coordweight1, backend) | |
| DEFINE_TESTCASE (diceweight2, backend) | |
| DEFINE_TESTCASE (diceweight3, backend) | |
tests of Xapian::Weight subclasses
Definition in file api_weight.cc.
| #define TEST_WEIGHT_CLASS | ( | W, | |
| N, | |||
| DEFAULT, | |||
| OTHER | |||
| ) | test_weight_class<W>(#W, N, W DEFAULT, W OTHER) |
Definition at line 116 of file api_weight.cc.
| #define TEST_WEIGHT_CLASS_NO_PARAMS | ( | W, | |
| N | |||
| ) | test_weight_class_no_params<W>(#W, N) |
Definition at line 66 of file api_weight.cc.
| #define TEST_WEIGHTING_SCHEME | ( | W, | |
| ... | |||
| ) | helper(W(__VA_ARGS__), #W, "" #__VA_ARGS__) |
| #define XAPIAN_DEPRECATED | ( | D | ) | D |
Definition at line 29 of file api_weight.cc.
| DEFINE_TESTCASE | ( | bb2weight2 | , |
| ! | backend | ||
| ) |
Definition at line 459 of file api_weight.cc.
References TEST_EXCEPTION.
| DEFINE_TESTCASE | ( | bb2weight3 | , |
| backend | |||
| ) |
Definition at line 469 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 500 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 | ( | bm25plusweight2 | , |
| backend | |||
| ) |
Definition at line 331 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 354 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 | ( | 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 263 of file api_weight.cc.
References get_database(), Xapian::Enquire::get_mset(), Xapian::Enquire::set_query(), and Xapian::Enquire::set_weighting_scheme().
| DEFINE_TESTCASE | ( | bm25weight2 | , |
| ! | backend | ||
| ) |
Test Weight::create() for BM25Weight.
Definition at line 272 of file api_weight.cc.
References Xapian::Weight::create(), and TEST_EQUAL.
| DEFINE_TESTCASE | ( | bm25weight4 | , |
| backend | |||
| ) |
Definition at line 289 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 313 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 | ( | checkinitweight1 | , |
| backend &&!multi &&! | remote | ||
| ) |
Regression test - check init() is called for the term-indep Weight obj.
Definition at line 1203 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 1419 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(), term, and TEST_EQUAL.
| DEFINE_TESTCASE | ( | checkstatsweight2 | , |
| backend &&! | remote | ||
| ) |
Check the weight subclass gets the correct stats with OP_SYNONYM.
Definition at line 1453 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 1569 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(), Heap::make(), Xapian::Query::OP_WILDCARD, Heap::pop(), Xapian::Database::postlist_begin(), Heap::replace(), 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 1647 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(), term, and TEST_EQUAL.
| DEFINE_TESTCASE | ( | checkstatsweight5 | , |
| backend &&!multi &&! | remote | ||
| ) |
Check wdfdocmax is clamped to doclen even if wdf and doclen aren't wanted.
Definition at line 1729 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::Query::OP_SYNONYM, Xapian::Enquire::set_query(), and Xapian::Enquire::set_weighting_scheme().
| DEFINE_TESTCASE | ( | checkstatsweight6 | , |
| backend &&! | remote | ||
| ) |
Check the weight subclass gets the correct stats with OP_SYNONYM.
Definition at line 1525 of file api_weight.cc.
References Xapian::WritableDatabase::add_document(), Xapian::Document::add_term(), get_database(), Xapian::Query::get_description(), Xapian::Database::get_doccount(), Xapian::Database::get_doclength(), Xapian::Query::OP_SYNONYM, Xapian::Database::postlist_begin(), Xapian::Database::postlist_end(), term, TEST_EQUAL, and tout.
| DEFINE_TESTCASE | ( | coordweight1 | , |
| backend | |||
| ) |
Definition at line 1774 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.
| DEFINE_TESTCASE | ( | diceweight2 | , |
| backend | |||
| ) |
Definition at line 1797 of file api_weight.cc.
References get_database(), Xapian::Enquire::get_mset(), Xapian::Query::OP_OR, query(), Xapian::Enquire::set_query(), Xapian::Enquire::set_weighting_scheme(), Xapian::MSet::size(), TEST_EQUAL, and TEST_EQUAL_DOUBLE.
| DEFINE_TESTCASE | ( | diceweight3 | , |
| backend | |||
| ) |
Definition at line 1820 of file api_weight.cc.
References Xapian::Document::add_boolean_term(), Xapian::WritableDatabase::add_document(), Xapian::Document::add_term(), get_database(), Xapian::Query::OP_SCALE_WEIGHT, Xapian::Query::OP_SYNONYM, Xapian::MSet::size(), TEST_EQUAL, and TEST_EQUAL_DOUBLE.
| DEFINE_TESTCASE | ( | dlhweight1 | , |
| backend | |||
| ) |
Definition at line 515 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 543 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 | ( | dphweight1 | , |
| backend | |||
| ) |
Definition at line 627 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 644 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 | ( | ifb2weight2 | , |
| ! | backend | ||
| ) |
Definition at line 403 of file api_weight.cc.
References TEST_EXCEPTION.
| DEFINE_TESTCASE | ( | ifb2weight3 | , |
| backend | |||
| ) |
Definition at line 413 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 431 of file api_weight.cc.
References TEST_EXCEPTION.
| DEFINE_TESTCASE | ( | ineb2weight3 | , |
| backend | |||
| ) |
Definition at line 441 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 | ( | inl2weight2 | , |
| ! | backend | ||
| ) |
Definition at line 374 of file api_weight.cc.
References TEST_EXCEPTION.
| DEFINE_TESTCASE | ( | inl2weight3 | , |
| backend | |||
| ) |
Definition at line 384 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 | ( | lmdirichletweight1 | , |
| backend | |||
| ) |
Definition at line 1745 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_REL.
| DEFINE_TESTCASE | ( | pl2plusweight2 | , |
| ! | backend | ||
| ) |
Definition at line 583 of file api_weight.cc.
References TEST_EXCEPTION.
| DEFINE_TESTCASE | ( | pl2plusweight4 | , |
| backend | |||
| ) |
Definition at line 594 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 610 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 | ( | pl2weight2 | , |
| ! | backend | ||
| ) |
Definition at line 559 of file api_weight.cc.
References TEST_EXCEPTION.
| DEFINE_TESTCASE | ( | pl2weight3 | , |
| backend | |||
| ) |
Definition at line 566 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 | ( | tfidfweight1 | , |
| ! | backend | ||
| ) |
Definition at line 660 of file api_weight.cc.
References Xapian::Weight::create(), and TEST_EXCEPTION.
| DEFINE_TESTCASE | ( | tfidfweight3 | , |
| backend | |||
| ) |
Definition at line 685 of file api_weight.cc.
References Xapian::TfIdfWeight::AUG, Xapian::TfIdfWeight::AUG_AVERAGE, Xapian::TfIdfWeight::AUG_LOG, Xapian::TfIdfWeight::BOOLEAN, Xapian::TfIdfWeight::FREQ, get_database(), Xapian::Enquire::get_mset(), Xapian::TfIdfWeight::GLOBAL_FREQ, Xapian::TfIdfWeight::INCREMENTED_GLOBAL_FREQ, Xapian::TfIdfWeight::LOG, Xapian::TfIdfWeight::LOG_AVERAGE, Xapian::TfIdfWeight::LOG_GLOBAL_FREQ, Xapian::TfIdfWeight::MAX, mset_expect_order(), Xapian::TfIdfWeight::NONE, Xapian::TfIdfWeight::PROB, query(), Xapian::Enquire::set_query(), Xapian::Enquire::set_weighting_scheme(), Xapian::MSet::size(), Xapian::TfIdfWeight::SQRT, Xapian::TfIdfWeight::SQRT_GLOBAL_FREQ, Xapian::TfIdfWeight::SQUARE, TEST_EQUAL, TEST_EQUAL_DOUBLE, and Xapian::TfIdfWeight::TFIDF.
| DEFINE_TESTCASE | ( | tfidfweight4 | , |
| backend | |||
| ) |
Definition at line 1060 of file api_weight.cc.
References get_database(), Xapian::Enquire::get_mset(), mset_expect_order(), Xapian::TfIdfWeight::NONE, Xapian::TfIdfWeight::PIVOTED, query(), Xapian::Enquire::set_query(), Xapian::Enquire::set_weighting_scheme(), Xapian::MSet::size(), TEST_EQUAL, TEST_EQUAL_DOUBLE, TEST_REL, and Xapian::TfIdfWeight::TFIDF.
| DEFINE_TESTCASE | ( | tfidfweight5 | , |
| ! | backend | ||
| ) |
Definition at line 1147 of file api_weight.cc.
References Xapian::Weight::create(), Xapian::TfIdfWeight::NONE, Xapian::TfIdfWeight::PIVOTED, Xapian::TfIdfWeight::SQRT, TEST_EQUAL, and Xapian::TfIdfWeight::TFIDF.
| DEFINE_TESTCASE | ( | weight1 | , |
| backend | |||
| ) |
Basic test of using weighting schemes.
Definition at line 158 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(), term, TEST_EQUAL, TEST_EQUAL_DOUBLE, TEST_NOT_EQUAL, TEST_NOT_EQUAL_DOUBLE, TEST_REL, TEST_WEIGHTING_SCHEME, and tout.
| DEFINE_TESTCASE | ( | weightcreate1 | , |
| ! | backend | ||
| ) |
Feature tests for Weight::create().
Definition at line 250 of file api_weight.cc.
References Xapian::Weight::create(), and TEST_EXCEPTION.
| DEFINE_TESTCASE | ( | weightserialisation1 | , |
| ! | backend | ||
| ) |
Test serialisation and introspection of built-in weighting schemes.
Definition at line 120 of file api_weight.cc.
References TEST_WEIGHT_CLASS, and TEST_WEIGHT_CLASS_NO_PARAMS.
|
static |
Definition at line 535 of file api_weight.cc.
References Xapian::WritableDatabase::add_document(), and Xapian::Document::add_term().
Referenced by DEFINE_TESTCASE().
|
inlinestatic |
Definition at line 70 of file api_weight.cc.
References CONST_STRLEN, FAIL_TEST, Xapian::Error::get_msg(), TEST, TEST_EQUAL, TEST_NOT_EQUAL, and tout.
|
inlinestatic |
Definition at line 40 of file api_weight.cc.
References CONST_STRLEN, FAIL_TEST, Xapian::Error::get_msg(), TEST, TEST_EQUAL, and tout.