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

tests snippets More...

#include <config.h>
#include "api_snippets.h"
#include <fstream>
#include <string>
#include <xapian.h>
#include "apitest.h"
#include "testsuite.h"
#include "testutils.h"
+ Include dependency graph for api_snippets.cc:

Go to the source code of this file.

Classes

struct  snippet_testcase
 

Macros

#define SHY   "\xc2\xad"
 
#define ZWSP   "\xe2\x80\x8b"
 
#define DO_TEST(CODE, RESULT)
 

Functions

 DEFINE_TESTCASE (snippet1, backend)
 Test snippets without stemming. More...
 
 DEFINE_TESTCASE (snippetstem1, backend)
 Test snippets with stemming. More...
 
 DEFINE_TESTCASE (snippetphrase1, backend)
 Test snippets with phrases. More...
 
static void make_tg_db (Xapian::WritableDatabase &db, const string &source)
 Index file to a DB with TermGenerator. More...
 
 DEFINE_TESTCASE (snippetmisc1, backend)
 Test snippets in various ways. More...
 
 DEFINE_TESTCASE (snippet_termcover1, backend)
 Test snippet term diversity. More...
 
 DEFINE_TESTCASE (snippet_termcover2, backend)
 Test snippet term diversity cases with BoolWeight. More...
 
 DEFINE_TESTCASE (snippet_empty, backend)
 Test snippet EMPTY_WITHOUT_MATCH flag. More...
 
 DEFINE_TESTCASE (snippet_start_nonspace, backend)
 Check snippets include certain preceding punctuation. More...
 
 DEFINE_TESTCASE (snippet_small_zerolength, backend)
 Test snippets with small and zero length. More...
 
 DEFINE_TESTCASE (snippet_ngrams, backend)
 Test ngrams. More...
 
 DEFINE_TESTCASE (snippet_wordbreaks, backend)
 Test word break finding. More...
 
 DEFINE_TESTCASE (snippet_empty_mset, backend)
 
 DEFINE_TESTCASE (snippet_empty_mset2, !backend)
 

Detailed Description

tests snippets

Definition in file api_snippets.cc.

Macro Definition Documentation

◆ DO_TEST

#define DO_TEST (   CODE,
  RESULT 
)
Value:
try { \
CODE; \
FAIL_TEST("No exception thrown, expected FeatureUnavailableError"); \
} catch (const Xapian::FeatureUnavailableError& e) { \
TEST_STRINGS_EQUAL( \
e.get_msg(), \
"SNIPPET_WORD_BREAKS requires building Xapian to use ICU"); \
}
const std::string & get_msg() const noexcept
Message giving details of the error, intended for human consumption.
Definition: error.h:111
Indicates an attempt to use a feature which is unavailable.
Definition: error.h:707

◆ SHY

#define SHY   "\xc2\xad"

◆ ZWSP

#define ZWSP   "\xe2\x80\x8b"

Function Documentation

◆ DEFINE_TESTCASE() [1/13]

DEFINE_TESTCASE ( snippet1  ,
backend   
)

◆ DEFINE_TESTCASE() [2/13]

DEFINE_TESTCASE ( snippet_empty  ,
backend   
)

◆ DEFINE_TESTCASE() [3/13]

DEFINE_TESTCASE ( snippet_empty_mset  ,
backend   
)

◆ DEFINE_TESTCASE() [4/13]

DEFINE_TESTCASE ( snippet_empty_mset2  ,
backend 
)

Definition at line 571 of file api_snippets.cc.

References Xapian::MSet::snippet(), and TEST_STRINGS_EQUAL.

◆ DEFINE_TESTCASE() [5/13]

DEFINE_TESTCASE ( snippet_ngrams  ,
backend   
)

◆ DEFINE_TESTCASE() [6/13]

DEFINE_TESTCASE ( snippet_small_zerolength  ,
backend   
)

◆ DEFINE_TESTCASE() [7/13]

DEFINE_TESTCASE ( snippet_start_nonspace  ,
backend   
)

Check snippets include certain preceding punctuation.

Definition at line 310 of file api_snippets.cc.

References get_database(), Xapian::Enquire::get_mset(), Xapian::Enquire::set_query(), Xapian::MSet::snippet(), and TEST_STRINGS_EQUAL.

◆ DEFINE_TESTCASE() [8/13]

DEFINE_TESTCASE ( snippet_termcover1  ,
backend   
)

◆ DEFINE_TESTCASE() [9/13]

DEFINE_TESTCASE ( snippet_termcover2  ,
backend   
)

◆ DEFINE_TESTCASE() [10/13]

DEFINE_TESTCASE ( snippet_wordbreaks  ,
backend   
)

◆ DEFINE_TESTCASE() [11/13]

DEFINE_TESTCASE ( snippetmisc1  ,
backend   
)

◆ DEFINE_TESTCASE() [12/13]

DEFINE_TESTCASE ( snippetphrase1  ,
backend   
)

◆ DEFINE_TESTCASE() [13/13]

DEFINE_TESTCASE ( snippetstem1  ,
backend   
)

◆ make_tg_db()

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