tests/harness/testsuite.h File Reference

#include "noreturn.h"
#include "output.h"
#include "stringutils.h"
#include <iomanip>
#include <map>
#include <sstream>
#include <string>
#include <vector>
#include <float.h>

Include dependency graph for testsuite.h:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  TestFail
 Class which is thrown when a test case fails. More...
class  TestSkip
 Class which is thrown when a test case is to be skipped. More...
struct  test_desc
 Structure holding a description of a test. More...
class  test_driver
 The test driver. This class takes care of running the tests. More...
struct  test_driver::result
 A structure used to report the summary of tests passed and failed. More...

Defines

#define FAIL_TEST(a)
 Macro used to build a TestFail object and throw it.
#define SKIP_TEST(a)
 Macro used to build a TestSkip object and throw it.
#define TESTCASE_LOCN(a)   __FILE__":"STRINGIZE(__LINE__)": "STRINGIZE(a)
 Display the location at which a testcase occurred, with an explanation.
#define TEST_AND_EXPLAIN(a, b)
 Test a condition, and display the test with an extra explanation if the condition fails.
#define TEST(a)   TEST_AND_EXPLAIN(a, "")
 Test a condition, without an additional explanation for failure.
#define TEST_EQUAL(a, b)
 Test for equality of two things.
#define TEST_STRINGS_EQUAL(a, b)
 Test for equality of two strings.
#define TEST_EQUAL_DOUBLE(a, b)
 Test two doubles for near equality.
#define TEST_NOT_EQUAL_DOUBLE(a, b)
 Test two doubles for non-near-equality.
#define TEST_NOT_EQUAL(a, b)
 Test for non-equality of two things.
#define TEST_GREATER_OR_EQUAL(a, b)
 Test for one thing being >= another.
#define TEST_GREATER(a, b)
 Test for one thing being > another.
#define TEST_LESSER_OR_EQUAL(a, b)
 Test for one thing being <= another.
#define TEST_LESSER(a, b)
 Test for one thing being < another.

Typedefs

typedef bool(*) test_func ()
 Type for a test function.

Functions

bool TEST_EQUAL_DOUBLE_ (double a, double b)
 Helper function for TEST_EQUAL_DOUBLE macro.

Variables

bool verbose
 The global verbose flag.
const char * expected_exception
 The exception type we were expecting in TEST_EXCEPTION.
std::ostringstream tout
 The output stream.


Define Documentation

#define FAIL_TEST (  ) 

Value:

do { TestFail testfail; \
                          if (verbose) { tout << a << '\n'; } \
                          throw testfail; } while (0)
Macro used to build a TestFail object and throw it.

Definition at line 53 of file testsuite.h.

Referenced by DEFINE_TESTCASE(), makedir(), NeverUseMeSorter::operator()(), removedir(), test_stemjunk(), test_stemrandom(), and test_termgen1().

#define SKIP_TEST (  ) 

Value:

do { TestSkip testskip; \
                          if (verbose) { tout << a << '\n'; } \
                          throw testskip; } while (0)
Macro used to build a TestSkip object and throw it.

Definition at line 60 of file testsuite.h.

Referenced by DEFINE_TESTCASE(), test_insertdelete1(), test_qp_stem_scale1(), test_sequent1(), test_stemdict(), test_stemjunk(), and test_stemrandom().

#define TESTCASE_LOCN (  )     __FILE__":"STRINGIZE(__LINE__)": "STRINGIZE(a)

Display the location at which a testcase occurred, with an explanation.

Definition at line 231 of file testsuite.h.

#define TEST_AND_EXPLAIN ( a,
 ) 

Value:

do {\
        if (!(a)) FAIL_TEST(TESTCASE_LOCN(a) << std::endl << b << std::endl);\
    } while (0)
Test a condition, and display the test with an extra explanation if the condition fails.

NB: wrapped in do { ... } while (0) so a trailing ';' works correctly.

Definition at line 237 of file testsuite.h.

Referenced by DEFINE_TESTCASE(), do_update(), mset_expect_order_(), mset_range_is_same(), mset_range_is_same_percents(), mset_range_is_same_weights(), test_mset_order_equal(), test_refcnt1(), test_refcnt2(), and test_value_range_serialise1().

#define TEST (  )     TEST_AND_EXPLAIN(a, "")

Test a condition, without an additional explanation for failure.

Definition at line 242 of file testsuite.h.

Referenced by check_double_serialisation(), check_table_values_empty(), check_table_values_hello(), DEFINE_TESTCASE(), test_autoptr1(), test_cursor1(), test_cursor2(), test_cursor3(), test_overwrite1(), test_packint2(), test_packint3(), test_packstring1(), test_qp_stoplist1(), test_qp_unstem_boolean_prefix(), test_serialisedoc1(), test_serialiseerror1(), test_serialiselength2(), test_serialisequery1(), test_simple1(), test_table3(), test_table5(), test_table6(), and test_unpackint1().

#define TEST_EQUAL ( a,
 ) 

Value:

TEST_AND_EXPLAIN(((a) == (b)), \
        "Expected `"STRINGIZE(a)"' and `"STRINGIZE(b)"' to be equal:" \
        " were " << (a) << " and " << (b))
Test for equality of two things.

Definition at line 245 of file testsuite.h.

Referenced by check_double_serialisation(), check_table_values_empty(), check_table_values_hello(), DEFINE_TESTCASE(), test_adddoc1(), test_autoptr1(), test_consistency2(), test_create1(), test_cursor1(), test_cursor2(), test_cursor3(), test_emptykey1(), test_emptyterm1_helper(), test_emptyterm2_helper(), test_exception1(), test_insertdelete1(), test_overwrite1(), test_packint1(), test_packint2(), test_packint3(), test_qp_stoplist1(), test_qp_unstem_boolean_prefix(), test_qp_value_range3(), test_refcnt1(), test_sequent1(), test_serialiseerror1(), test_serialiselength1(), test_serialiselength2(), test_stemdict(), test_table1(), test_table2(), test_table3(), test_table4(), test_table5(), test_table6(), test_temporarydtor1(), test_tostring1(), test_unpackint1(), and test_value_range_serialise1().

#define TEST_STRINGS_EQUAL ( a,
 ) 

Value:

TEST_AND_EXPLAIN(((a) == (b)), \
        "Expected "STRINGIZE(a)" and "STRINGIZE(b)" to be equal, were:\n\"" \
        << (a) << "\"\n\"" << (b) << '"')
Test for equality of two strings.

If they aren't equal, show each on a separate line so the difference can be seen clearly.

Definition at line 254 of file testsuite.h.

Referenced by DEFINE_TESTCASE(), test_qp_default_op1(), test_qp_default_prefix1(), test_qp_default_prefix2(), test_qp_flag_bool_any_case1(), test_qp_flag_partial1(), test_qp_flag_pure_not1(), test_qp_flag_wildcard1(), test_qp_flag_wildcard2(), test_qp_odd_chars1(), test_qp_spell1(), test_qp_spell2(), test_qp_stem_all1(), test_qp_stopper1(), test_qp_synonym1(), test_qp_synonym2(), test_qp_synonym3(), test_qp_unstem_boolean_prefix(), test_qp_value_customrange1(), test_qp_value_daterange1(), test_qp_value_range1(), test_qp_value_range2(), test_queryparser1(), test_serialiseerror1(), test_termgen1(), and test_tg_spell1().

#define TEST_EQUAL_DOUBLE ( a,
 ) 

Value:

TEST_AND_EXPLAIN(TEST_EQUAL_DOUBLE_((a), (b)), \
        "Expected `"STRINGIZE(a)"' and `"STRINGIZE(b)"' to be (nearly) equal:" \
        " were " << setprecision(DBL_DIG) << (a) << " and " << (b) << ")" << setprecision(6))
Test two doubles for near equality.

Definition at line 262 of file testsuite.h.

Referenced by DEFINE_TESTCASE().

#define TEST_NOT_EQUAL_DOUBLE ( a,
 ) 

Value:

TEST_AND_EXPLAIN(!TEST_EQUAL_DOUBLE_((a), (b)), \
        "Expected `"STRINGIZE(a)"' and `"STRINGIZE(b)"' not to be (nearly) equal:" \
        " were " << setprecision(DBL_DIG) << (a) << " and " << (b) << ")" << setprecision(6))
Test two doubles for non-near-equality.

Definition at line 267 of file testsuite.h.

Referenced by DEFINE_TESTCASE().

#define TEST_NOT_EQUAL ( a,
 ) 

Value:

TEST_AND_EXPLAIN(((a) != (b)), \
        "Expected `"STRINGIZE(a)"' and `"STRINGIZE(b)"' not to be equal:" \
        " were " << (a) << " and " << (b))
Test for non-equality of two things.

Definition at line 272 of file testsuite.h.

Referenced by DEFINE_TESTCASE(), and test_table1().

#define TEST_GREATER_OR_EQUAL ( a,
 ) 

Value:

TEST_AND_EXPLAIN(((a) >= (b)), \
        "Expected `"STRINGIZE(a)"' to be greater than or equal to `"STRINGIZE(b)"':" \
        " were " << (a) << " and " << (b))
Test for one thing being >= another.

Definition at line 277 of file testsuite.h.

Referenced by DEFINE_TESTCASE().

#define TEST_GREATER ( a,
 ) 

Value:

TEST_AND_EXPLAIN(((a) > (b)), \
        "Expected `"STRINGIZE(a)"' to be greater than `"STRINGIZE(b)"':" \
        " were " << (a) << " and " << (b))
Test for one thing being > another.

Definition at line 282 of file testsuite.h.

Referenced by DEFINE_TESTCASE().

#define TEST_LESSER_OR_EQUAL ( a,
 ) 

Value:

TEST_AND_EXPLAIN(((a) <= (b)), \
        "Expected `"STRINGIZE(a)"' to be less than or equal to `"STRINGIZE(b)"':" \
        " were " << (a) << " and " << (b))
Test for one thing being <= another.

Definition at line 287 of file testsuite.h.

Referenced by DEFINE_TESTCASE().

#define TEST_LESSER ( a,
 ) 

Value:

TEST_AND_EXPLAIN(((a) < (b)), \
        "Expected `"STRINGIZE(a)"' to be less than than `"STRINGIZE(b)"':" \
        " were " << (a) << " and " << (b))
Test for one thing being < another.

Definition at line 292 of file testsuite.h.

Referenced by DEFINE_TESTCASE(), and test_qp_stem_scale1().


Typedef Documentation

typedef bool(*) test_func()

Type for a test function.

Definition at line 65 of file testsuite.h.


Function Documentation

bool TEST_EQUAL_DOUBLE_ ( double  a,
double  b 
)

Helper function for TEST_EQUAL_DOUBLE macro.

Definition at line 719 of file testsuite.cc.


Variable Documentation

bool verbose

The global verbose flag.

Definition at line 75 of file testsuite.cc.

const char* expected_exception

The exception type we were expecting in TEST_EXCEPTION.

Definition at line 85 of file testsuite.cc.

Referenced by test_driver::runtest().

std::ostringstream tout

The output stream.

Data written to this stream will only appear when a test fails.

Definition at line 88 of file testsuite.cc.

Referenced by check_double_serialisation(), DEFINE_TESTCASE(), do_create(), do_update(), make_dir(), print_mset_percentages(), print_mset_weights(), test_driver::runtest(), test_autoptr::test_autoptr(), test_emptykey1(), test_packstring1(), test_qp_default_op1(), test_qp_flag_pure_not1(), test_qp_odd_chars1(), test_qp_spell1(), test_qp_spell2(), test_qp_stem_all1(), test_qp_stem_scale1(), test_qp_stopper1(), test_qp_synonym1(), test_qp_synonym2(), test_qp_synonym3(), test_qp_value_customrange1(), test_qp_value_daterange1(), test_qp_value_range1(), test_qp_value_range2(), test_qp_value_range3(), test_queryparser1(), test_refcnt::test_refcnt(), test_serialiselength1(), test_stemdict(), test_stemjunk(), test_stemrandom(), test_stringcomp1(), test_termgen1(), test_value_range_serialise1(), test_autoptr::~test_autoptr(), and test_refcnt::~test_refcnt().


Documentation for Xapian (version 1.0.10).
Generated on 24 Dec 2008 by Doxygen 1.5.2.