xapian-core  1.4.19
Macros | Functions
testutils.h File Reference

Xapian-specific test helper functions and macros. More...

#include "testsuite.h"
#include <xapian.h>
+ Include dependency graph for testutils.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define TEST_MSET_SIZE(M, S)
 Check MSet M has size S. More...
 
#define TEST_EXCEPTION_(TYPE, CODE, EXACT)
 Helper macro. More...
 
#define TEST_EXCEPTION_BASE_CLASS(TYPE, CODE)   TEST_EXCEPTION_(TYPE, CODE, false)
 Check that CODE throws Xapian exception derived from TYPE. More...
 
#define TEST_EXCEPTION(TYPE, CODE)   TEST_EXCEPTION_(TYPE, CODE, true)
 Check that CODE throws exactly Xapian exception TYPE. More...
 

Functions

std::ostream & operator<< (std::ostream &os, const std::vector< Xapian::docid > &ints)
 
bool mset_range_is_same (const Xapian::MSet &mset1, unsigned int first1, const Xapian::MSet &mset2, unsigned int first2, unsigned int count)
 
bool mset_range_is_same (const Xapian::MSet &mset, unsigned int first, const std::pair< Xapian::docid, double > to_compare[], unsigned int count)
 
bool mset_range_is_same_weights (const Xapian::MSet &mset1, unsigned int first1, const Xapian::MSet &mset2, unsigned int first2, unsigned int count)
 
bool operator== (const Xapian::MSet &first, const Xapian::MSet &second)
 
bool operator!= (const Xapian::MSet &first, const Xapian::MSet &second)
 
void mset_expect_order (const Xapian::MSet &A, Xapian::docid d1=0, Xapian::docid d2=0, Xapian::docid d3=0, Xapian::docid d4=0, Xapian::docid d5=0, Xapian::docid d6=0, Xapian::docid d7=0, Xapian::docid d8=0, Xapian::docid d9=0, Xapian::docid d10=0, Xapian::docid d11=0, Xapian::docid d12=0)
 
void test_mset_order_equal (const Xapian::MSet &mset1, const Xapian::MSet &mset2)
 

Detailed Description

Xapian-specific test helper functions and macros.

Definition in file testutils.h.

Macro Definition Documentation

◆ TEST_EXCEPTION

#define TEST_EXCEPTION (   TYPE,
  CODE 
)    TEST_EXCEPTION_(TYPE, CODE, true)

Check that CODE throws exactly Xapian exception TYPE.

Definition at line 109 of file testutils.h.

Referenced by DEFINE_TESTCASE(), replicate_with_brokenness(), test_emptyterm1_helper(), and test_emptyterm2_helper().

◆ TEST_EXCEPTION_

#define TEST_EXCEPTION_ (   TYPE,
  CODE,
  EXACT 
)
Value:
do { \
expected_exception = STRINGIZE(TYPE); \
if (strncmp(expected_exception, "Xapian::", \
CONST_STRLEN("Xapian::")) == 0) { \
expected_exception += CONST_STRLEN("Xapian::"); \
} \
try { \
CODE; \
FAIL_TEST("Expected " << expected_exception << " not thrown"); \
} catch (const TYPE& xap_ex_obj_) { \
if (EXACT) { \
if (strcmp(expected_exception, xap_ex_obj_.get_type()) != 0) { \
FAIL_TEST("Caught subclass " << xap_ex_obj_.get_type() << \
" of expected " << expected_exception); \
} \
} \
} \
expected_exception = NULL;\
} while (0)
#define STRINGIZE(X)
The STRINGIZE macro converts its parameter into a string constant.
Definition: stringutils.h:36
#define CONST_STRLEN(S)
Returns the length of a string constant.
Definition: stringutils.h:43
const char * expected_exception
The exception type we were expecting in TEST_EXCEPTION.
Definition: testsuite.cc:98

Helper macro.

Definition at line 84 of file testutils.h.

◆ TEST_EXCEPTION_BASE_CLASS

#define TEST_EXCEPTION_BASE_CLASS (   TYPE,
  CODE 
)    TEST_EXCEPTION_(TYPE, CODE, false)

Check that CODE throws Xapian exception derived from TYPE.

Definition at line 106 of file testutils.h.

Referenced by DEFINE_TESTCASE().

◆ TEST_MSET_SIZE

#define TEST_MSET_SIZE (   M,
 
)
Value:
TEST_AND_EXPLAIN(((M).size() == (S)), \
"MSet '" STRINGIZE(M) "' is not of expected size: was '" << \
(M).size() << "' expected '" << (S) << "':\n" << \
"Full mset was:\n" << (M))
#define TEST_AND_EXPLAIN(a, b)
Test a condition, and display the test with an extra explanation if the condition fails...
Definition: testsuite.h:267
#define STRINGIZE(X)
The STRINGIZE macro converts its parameter into a string constant.
Definition: stringutils.h:36

Check MSet M has size S.

Definition at line 78 of file testutils.h.

Referenced by DEFINE_TESTCASE().

Function Documentation

◆ mset_expect_order()

void mset_expect_order ( const Xapian::MSet A,
Xapian::docid  d1 = 0,
Xapian::docid  d2 = 0,
Xapian::docid  d3 = 0,
Xapian::docid  d4 = 0,
Xapian::docid  d5 = 0,
Xapian::docid  d6 = 0,
Xapian::docid  d7 = 0,
Xapian::docid  d8 = 0,
Xapian::docid  d9 = 0,
Xapian::docid  d10 = 0,
Xapian::docid  d11 = 0,
Xapian::docid  d12 = 0 
)

Definition at line 225 of file testutils.cc.

References mset_expect_order_().

Referenced by DEFINE_TESTCASE(), and operator!=().

◆ mset_range_is_same() [1/2]

bool mset_range_is_same ( const Xapian::MSet mset1,
unsigned int  first1,
const Xapian::MSet mset2,
unsigned int  first2,
unsigned int  count 
)

◆ mset_range_is_same() [2/2]

bool mset_range_is_same ( const Xapian::MSet mset,
unsigned int  first,
const std::pair< Xapian::docid, double >  to_compare[],
unsigned int  count 
)

◆ mset_range_is_same_weights()

bool mset_range_is_same_weights ( const Xapian::MSet mset1,
unsigned int  first1,
const Xapian::MSet mset2,
unsigned int  first2,
unsigned int  count 
)

◆ operator!=()

bool operator!= ( const Xapian::MSet first,
const Xapian::MSet second 
)
inline

Definition at line 58 of file testutils.h.

References mset_expect_order(), and test_mset_order_equal().

◆ operator<<()

std::ostream& operator<< ( std::ostream &  os,
const std::vector< Xapian::docid > &  ints 
)

Definition at line 35 of file testutils.cc.

◆ operator==()

bool operator== ( const Xapian::MSet first,
const Xapian::MSet second 
)

◆ test_mset_order_equal()

void test_mset_order_equal ( const Xapian::MSet mset1,
const Xapian::MSet mset2 
)