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 <cfloat>
#include "testmacros.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 DEFINE_TESTCASE(S, COND)   bool test_##S()

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 DEFINE_TESTCASE ( S,
COND   )     bool test_##S()

Definition at line 279 of file testsuite.h.

#define FAIL_TEST (  ) 

#define SKIP_TEST (  ) 

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

#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 240 of file testsuite.h.

Referenced by DEFINE_TESTCASE(), 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_EQUAL ( a,
 ) 

#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 265 of file testsuite.h.

Referenced by dbcheck(), and 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 275 of file testsuite.h.

Referenced by check_vals(), DEFINE_TESTCASE(), and closedb1_iterators::perform().

#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 270 of file testsuite.h.

Referenced by DEFINE_TESTCASE().

#define TEST_STRINGS_EQUAL ( a,
 ) 

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

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

Definition at line 234 of file testsuite.h.


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 784 of file testsuite.cc.

Referenced by mset_range_is_same(), and mset_range_is_same_weights().


Variable Documentation

const char* expected_exception

The exception type we were expecting in TEST_EXCEPTION.

Definition at line 90 of file testsuite.cc.

Referenced by test_driver::runtest().

std::ostringstream tout

bool verbose

The global verbose flag.

Definition at line 70 of file testsuite.cc.


Documentation for Xapian (version 1.2.8).
Generated on 14 Dec 2011 by Doxygen 1.5.9.