00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef OM_HGUARD_TESTUTILS_H
00023 #define OM_HGUARD_TESTUTILS_H
00024
00025 #include "testsuite.h"
00026 #include <xapian.h>
00027
00028
00029
00030
00031 std::ostream &operator<<(std::ostream &os,
00032 const std::vector<unsigned int> &ints);
00033
00034
00035
00036
00037
00038 bool
00039 mset_range_is_same(const Xapian::MSet &mset1, unsigned int first1,
00040 const Xapian::MSet &mset2, unsigned int first2,
00041 unsigned int count);
00042
00043
00044 bool
00045 mset_range_is_same_weights(const Xapian::MSet &mset1, unsigned int first1,
00046 const Xapian::MSet &mset2, unsigned int first2,
00047 unsigned int count);
00048
00049
00050 bool
00051 mset_range_is_same_percents(const Xapian::MSet &mset1, unsigned int first1,
00052 const Xapian::MSet &mset2, unsigned int first2,
00053 unsigned int count);
00054
00055 bool operator==(const Xapian::MSet &first, const Xapian::MSet &second);
00056
00057 inline bool operator!=(const Xapian::MSet &first, const Xapian::MSet &second)
00058 {
00059 return !(first == second);
00060 }
00061
00062
00063 void mset_expect_order(const Xapian::MSet &A,
00064 Xapian::docid d1 = 0, Xapian::docid d2 = 0,
00065 Xapian::docid d3 = 0, Xapian::docid d4 = 0,
00066 Xapian::docid d5 = 0, Xapian::docid d6 = 0,
00067 Xapian::docid d7 = 0, Xapian::docid d8 = 0,
00068 Xapian::docid d9 = 0, Xapian::docid d10 = 0,
00069 Xapian::docid d11 = 0, Xapian::docid d12 = 0);
00070
00071 void test_mset_order_equal(const Xapian::MSet &mset1,
00072 const Xapian::MSet &mset2);
00073
00074
00075
00076
00078 #define TEST_MSET_SIZE(M, S) TEST_AND_EXPLAIN(((M).size() == (S)), \
00079 "MSet `"STRINGIZE(M)"' is not of expected size: was `" << \
00080 (M).size() << "' expected `" << (S) << "':\n" << \
00081 "Full mset was:\n" << (M))
00082
00084 #define TEST_EXCEPTION(a,b) do {\
00085 expected_exception = STRINGIZE(a);\
00086 if (strncmp(expected_exception, "Xapian::", 8) == 0)\
00087 expected_exception += 8;\
00088 if (verbose)\
00089 tout << "Expecting exception " << expected_exception << endl;\
00090 try {b;FAIL_TEST(TESTCASE_LOCN(Expected #a));}\
00091 catch (const a &e) {\
00092 if (verbose)\
00093 tout << "Caught expected " << expected_exception\
00094 << " exception: " << e.get_description() << endl;\
00095 }\
00096 expected_exception = NULL;\
00097 } while (0)
00098
00099 #endif // OM_HGUARD_TESTUTILS_H