xapian-core  1.4.27
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 "testutils.h"
+ Include dependency graph for api_weight.cc:

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)
 

Detailed Description

tests of Xapian::Weight subclasses

Definition in file api_weight.cc.

Macro Definition Documentation

◆ TEST_WEIGHT_CLASS

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

◆ TEST_WEIGHT_CLASS_NO_PARAMS

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

◆ TEST_WEIGHTING_SCHEME

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

Referenced by DEFINE_TESTCASE().

Function Documentation

◆ DEFINE_TESTCASE() [1/37]

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

DEFINE_TESTCASE ( weight1  ,
backend   
)

◆ DEFINE_TESTCASE() [3/37]

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

DEFINE_TESTCASE ( bm25weight4  ,
backend   
)

◆ DEFINE_TESTCASE() [5/37]

DEFINE_TESTCASE ( bm25weight5  ,
backend   
)

◆ DEFINE_TESTCASE() [6/37]

DEFINE_TESTCASE ( bm25plusweight2  ,
backend   
)

◆ DEFINE_TESTCASE() [7/37]

DEFINE_TESTCASE ( bm25plusweight3  ,
backend   
)

◆ DEFINE_TESTCASE() [8/37]

DEFINE_TESTCASE ( inl2weight2  ,
backend 
)

Definition at line 311 of file api_weight.cc.

References TEST_EXCEPTION.

◆ DEFINE_TESTCASE() [9/37]

DEFINE_TESTCASE ( inl2weight3  ,
backend   
)

◆ DEFINE_TESTCASE() [10/37]

DEFINE_TESTCASE ( ifb2weight2  ,
backend 
)

Definition at line 340 of file api_weight.cc.

References TEST_EXCEPTION.

◆ DEFINE_TESTCASE() [11/37]

DEFINE_TESTCASE ( ifb2weight3  ,
backend   
)

◆ DEFINE_TESTCASE() [12/37]

DEFINE_TESTCASE ( ineb2weight2  ,
backend 
)

Definition at line 368 of file api_weight.cc.

References TEST_EXCEPTION.

◆ DEFINE_TESTCASE() [13/37]

DEFINE_TESTCASE ( ineb2weight3  ,
backend   
)

◆ DEFINE_TESTCASE() [14/37]

DEFINE_TESTCASE ( bb2weight2  ,
backend 
)

Definition at line 396 of file api_weight.cc.

References TEST_EXCEPTION.

◆ DEFINE_TESTCASE() [15/37]

DEFINE_TESTCASE ( bb2weight3  ,
backend   
)

◆ DEFINE_TESTCASE() [16/37]

DEFINE_TESTCASE ( bb2weight4  ,
backend   
)

◆ DEFINE_TESTCASE() [17/37]

DEFINE_TESTCASE ( dlhweight1  ,
backend   
)

◆ DEFINE_TESTCASE() [18/37]

DEFINE_TESTCASE ( dlhweight3  ,
backend   
)

◆ DEFINE_TESTCASE() [19/37]

DEFINE_TESTCASE ( pl2weight2  ,
backend 
)

Definition at line 496 of file api_weight.cc.

References TEST_EXCEPTION.

◆ DEFINE_TESTCASE() [20/37]

DEFINE_TESTCASE ( pl2weight3  ,
backend   
)

◆ DEFINE_TESTCASE() [21/37]

DEFINE_TESTCASE ( pl2plusweight2  ,
backend 
)

Definition at line 520 of file api_weight.cc.

References TEST_EXCEPTION.

◆ DEFINE_TESTCASE() [22/37]

DEFINE_TESTCASE ( pl2plusweight4  ,
backend   
)

◆ DEFINE_TESTCASE() [23/37]

DEFINE_TESTCASE ( pl2plusweight5  ,
backend   
)

◆ DEFINE_TESTCASE() [24/37]

DEFINE_TESTCASE ( dphweight1  ,
backend   
)

◆ DEFINE_TESTCASE() [25/37]

DEFINE_TESTCASE ( dphweight3  ,
backend   
)

◆ DEFINE_TESTCASE() [26/37]

DEFINE_TESTCASE ( tfidfweight1  ,
backend 
)

Definition at line 597 of file api_weight.cc.

References TEST_EXCEPTION.

◆ DEFINE_TESTCASE() [27/37]

DEFINE_TESTCASE ( tfidfweight3  ,
backend   
)

◆ DEFINE_TESTCASE() [28/37]

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

DEFINE_TESTCASE ( checkstatsweight1  ,
backend &&!  remote 
)

◆ DEFINE_TESTCASE() [30/37]

DEFINE_TESTCASE ( checkstatsweight2  ,
backend &&!  remote 
)

◆ DEFINE_TESTCASE() [31/37]

DEFINE_TESTCASE ( checkstatsweight3  ,
backend &&!  remote 
)

◆ DEFINE_TESTCASE() [32/37]

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

◆ DEFINE_TESTCASE() [33/37]

DEFINE_TESTCASE ( unigramlmweight4  ,
backend   
)

◆ DEFINE_TESTCASE() [34/37]

DEFINE_TESTCASE ( unigramlmweight5  ,
backend   
)

◆ DEFINE_TESTCASE() [35/37]

DEFINE_TESTCASE ( unigramlmweight7  ,
backend   
)

◆ DEFINE_TESTCASE() [36/37]

DEFINE_TESTCASE ( unigramlmweight8  ,
backend   
)

◆ DEFINE_TESTCASE() [37/37]

DEFINE_TESTCASE ( coordweight1  ,
backend   
)

◆ 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 *  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 *  name)
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.