xapian-core  2.0.0
Classes | Macros | Functions
api_weight.cc File Reference

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)
 

Detailed Description

tests of Xapian::Weight subclasses

Definition in file api_weight.cc.

Macro Definition Documentation

◆ TEST_WEIGHT_CLASS

#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.

◆ TEST_WEIGHT_CLASS_NO_PARAMS

#define TEST_WEIGHT_CLASS_NO_PARAMS (   W,
 
)    test_weight_class_no_params<W>(#W, N)

Definition at line 66 of file api_weight.cc.

◆ TEST_WEIGHTING_SCHEME

#define TEST_WEIGHTING_SCHEME (   W,
  ... 
)     helper(W(__VA_ARGS__), #W, "" #__VA_ARGS__)

◆ XAPIAN_DEPRECATED

#define XAPIAN_DEPRECATED (   D)    D

Definition at line 29 of file api_weight.cc.

Function Documentation

◆ DEFINE_TESTCASE() [1/42]

DEFINE_TESTCASE ( bb2weight2  ,
backend 
)

Definition at line 459 of file api_weight.cc.

References TEST_EXCEPTION.

◆ DEFINE_TESTCASE() [2/42]

DEFINE_TESTCASE ( bb2weight3  ,
backend   
)

◆ DEFINE_TESTCASE() [3/42]

DEFINE_TESTCASE ( bb2weight4  ,
backend   
)

◆ DEFINE_TESTCASE() [4/42]

DEFINE_TESTCASE ( bm25plusweight2  ,
backend   
)

◆ DEFINE_TESTCASE() [5/42]

DEFINE_TESTCASE ( bm25plusweight3  ,
backend   
)

◆ DEFINE_TESTCASE() [6/42]

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() [7/42]

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() [8/42]

DEFINE_TESTCASE ( bm25weight4  ,
backend   
)

◆ DEFINE_TESTCASE() [9/42]

DEFINE_TESTCASE ( bm25weight5  ,
backend   
)

◆ DEFINE_TESTCASE() [10/42]

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() [11/42]

DEFINE_TESTCASE ( checkstatsweight1  ,
backend &&!  remote 
)

◆ DEFINE_TESTCASE() [12/42]

DEFINE_TESTCASE ( checkstatsweight2  ,
backend &&!  remote 
)

◆ DEFINE_TESTCASE() [13/42]

DEFINE_TESTCASE ( checkstatsweight3  ,
backend &&!  remote 
)

◆ DEFINE_TESTCASE() [14/42]

DEFINE_TESTCASE ( checkstatsweight4  ,
backend &&!remote &&!  multi 
)

◆ DEFINE_TESTCASE() [15/42]

DEFINE_TESTCASE ( checkstatsweight5  ,
backend &&!multi &&!  remote 
)

◆ DEFINE_TESTCASE() [16/42]

DEFINE_TESTCASE ( checkstatsweight6  ,
backend &&!  remote 
)

◆ DEFINE_TESTCASE() [17/42]

DEFINE_TESTCASE ( coordweight1  ,
backend   
)

◆ DEFINE_TESTCASE() [18/42]

DEFINE_TESTCASE ( diceweight2  ,
backend   
)

◆ DEFINE_TESTCASE() [19/42]

DEFINE_TESTCASE ( diceweight3  ,
backend   
)

◆ DEFINE_TESTCASE() [20/42]

DEFINE_TESTCASE ( dlhweight1  ,
backend   
)

◆ DEFINE_TESTCASE() [21/42]

DEFINE_TESTCASE ( dlhweight3  ,
backend   
)

◆ DEFINE_TESTCASE() [22/42]

DEFINE_TESTCASE ( dphweight1  ,
backend   
)

◆ DEFINE_TESTCASE() [23/42]

DEFINE_TESTCASE ( dphweight3  ,
backend   
)

◆ DEFINE_TESTCASE() [24/42]

DEFINE_TESTCASE ( ifb2weight2  ,
backend 
)

Definition at line 403 of file api_weight.cc.

References TEST_EXCEPTION.

◆ DEFINE_TESTCASE() [25/42]

DEFINE_TESTCASE ( ifb2weight3  ,
backend   
)

◆ DEFINE_TESTCASE() [26/42]

DEFINE_TESTCASE ( ineb2weight2  ,
backend 
)

Definition at line 431 of file api_weight.cc.

References TEST_EXCEPTION.

◆ DEFINE_TESTCASE() [27/42]

DEFINE_TESTCASE ( ineb2weight3  ,
backend   
)

◆ DEFINE_TESTCASE() [28/42]

DEFINE_TESTCASE ( inl2weight2  ,
backend 
)

Definition at line 374 of file api_weight.cc.

References TEST_EXCEPTION.

◆ DEFINE_TESTCASE() [29/42]

DEFINE_TESTCASE ( inl2weight3  ,
backend   
)

◆ DEFINE_TESTCASE() [30/42]

DEFINE_TESTCASE ( lmdirichletweight1  ,
backend   
)

◆ DEFINE_TESTCASE() [31/42]

DEFINE_TESTCASE ( pl2plusweight2  ,
backend 
)

Definition at line 583 of file api_weight.cc.

References TEST_EXCEPTION.

◆ DEFINE_TESTCASE() [32/42]

DEFINE_TESTCASE ( pl2plusweight4  ,
backend   
)

◆ DEFINE_TESTCASE() [33/42]

DEFINE_TESTCASE ( pl2plusweight5  ,
backend   
)

◆ DEFINE_TESTCASE() [34/42]

DEFINE_TESTCASE ( pl2weight2  ,
backend 
)

Definition at line 559 of file api_weight.cc.

References TEST_EXCEPTION.

◆ DEFINE_TESTCASE() [35/42]

DEFINE_TESTCASE ( pl2weight3  ,
backend   
)

◆ DEFINE_TESTCASE() [36/42]

DEFINE_TESTCASE ( tfidfweight1  ,
backend 
)

Definition at line 660 of file api_weight.cc.

References Xapian::Weight::create(), and TEST_EXCEPTION.

◆ DEFINE_TESTCASE() [37/42]

DEFINE_TESTCASE ( tfidfweight3  ,
backend   
)

◆ DEFINE_TESTCASE() [38/42]

DEFINE_TESTCASE ( tfidfweight4  ,
backend   
)

◆ DEFINE_TESTCASE() [39/42]

DEFINE_TESTCASE ( tfidfweight5  ,
backend 
)

◆ DEFINE_TESTCASE() [40/42]

DEFINE_TESTCASE ( weight1  ,
backend   
)

◆ DEFINE_TESTCASE() [41/42]

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() [42/42]

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.

◆ gen_wdf_eq_doclen_db()

static void gen_wdf_eq_doclen_db ( Xapian::WritableDatabase db,
const string &   
)
static

◆ test_weight_class()

template<class W >
static void test_weight_class ( const char *  classname,
const char *  name,
const W &  obj_default,
const W &  obj_other 
)
inlinestatic

◆ test_weight_class_no_params()

template<class W >
static void test_weight_class_no_params ( const char *  classname,
const char *  name 
)
inlinestatic

Definition at line 40 of file api_weight.cc.

References CONST_STRLEN, FAIL_TEST, Xapian::Error::get_msg(), TEST, TEST_EQUAL, and tout.