Synesis Software STLSoft - ... Robust, Lightweight, Cross-platform, Template Software ...

xtests/xtests.h File Reference


Detailed Description

[C, C++] Simple unit/component-testing library.

#include <stlsoft/stlsoft.h>
#include <platformstl/platformstl.h>
#include <stlsoft/meta/is_integral_type.hpp>
#include <stlsoft/meta/is_same_type.hpp>
#include <stlsoft/meta/select_first_type_if.hpp>
#include <stlsoft/shims/access/string.hpp>
#include <new>
#include <stdexcept>
#include <algorithm>
#include <stdio.h>

Go to the source code of this file.

Namespaces

namespace  xtests
namespace  xtests::c
namespace  xtests::c::cpp

Classes

struct  xTests_runner_results_t
 Summary of results for a single test case, or for all test cases in a test runner. More...
struct  xTests_Reporter_t
 Interface to a type whose instances may be used to report results. More...
class  xtest_floatingpoint_factor_scope
 Scoping class that sets the floating-point close factor for a controlled period. More...

Defines

#define _XTESTS_VER_MAJOR   0
 The Major version number of the xTests library.
#define _XTESTS_VER_MINOR   16
 Minor version number of the xTests library.
#define _XTESTS_VER_REVISION   4
 The revision number of the xTests library.
#define _XTESTS_VER   0x001004ff
 The composite version of the xTests library.
#define XTESTS_FP_APPROXIMATE_FACTOR   (1.000001)
 The factor within which floating point numbers are deemed to be approximately equal.
#define XTESTS_START_RUNNER(name, verbosity)
 Starts a test runner that will report to stdout.
#define XTESTS_START_RUNNER_WITH_SETUP_FNS(name, verbosity, setup, teardown, setupParam)
 Starts a test runner that will report to stdout.
#define XTESTS_START_RUNNER_WITH_STREAM(name, verbosity, stm)
 Starts a test runner.
#define XTESTS_START_RUNNER_WITH_REPORTER(name, verbosity, reporter, reporterParam)
 Starts a test runner with the given callback reporter.
#define XTESTS_START_RUNNER_WITH_REPORTER_AND_STREAM(name, verbosity, reporter, reporterParam, stm)
 Starts a test runner with the given callback reporter.
#define XTESTS_START_RUNNER_WITH_REPORTER_AND_STREAM_AND_FLAGS(name, verbosity, reporter, reporterParam, stm, flags)
 Starts a test runner with the given callback reporter.
#define XTESTS_START_RUNNER_WITH_REPORTER_AND_STREAM_AND_FLAGS_AND_SETUP_FNS(name, verbosity, reporter, reporterParam, stm, flags, setup, teardown, setupParam)
 Starts a test runner with the given callback reporter.
#define XTESTS_START_RUNNER_WITH_FLAGS(name, verbosity, flags)
 Starts a test runner that will report to stdout.
#define XTESTS_PRINT_RESULTS()
 Prints the test results of the currently executing test.
#define XTESTS_END_RUNNER()
 Ends a test runner.
#define XTESTS_ABEND(terminationMessage)
 Abnormal end of tests, and process termination.
#define XTESTS_END_RUNNER_UPDATE_EXITCODE(retCode)
 Ends a test runner, and modifies a caller-supplied exit code parameter.
#define XTESTS_CASE_BEGIN(name, desc)
 Begins a test case, of the given name and description.
#define XTESTS_CASE_END(name)
 Ends the current test case.
#define XTESTS_RUN_CASE_WITH_NAME_AND_DESC(name, desc, fn)
 Runs the given test case function, specifying a name and description.
#define XTESTS_RUN_CASE_WITH_DESC(fn, desc)
 Runs the given test case function, specifying a description.
#define XTESTS_RUN_CASE(fn)
 Runs the given test case function.
#define XTESTS_RUN_CASE_THAT_THROWS_WITH_NAME_AND_DESC(name, desc, fn, type)
 Runs the given test case function, specifying a name and description, and the type of an exception that is expected.
#define XTESTS_RUN_CASE_THAT_THROWS_WITH_DESC(fn, desc, type)
 Runs the given test case function, specifying a description, and the type of an exception that is expected.
#define XTESTS_RUN_CASE_THAT_THROWS(fn, type)
 Runs the given test case function, specifying the type of an exception that is expected.
#define XTESTS_TEST_FAIL_WITH_QUALIFIER(msg, qualifier)
 Causes a test failure to be expressed, passing an explanatory message and a message qualifier.
#define XTESTS_TEST_FAIL(msg)
 Causes a test failure to be expressed, passing an explanatory message.
#define XTESTS_TEST_PASSED()
 Causes a test success to be expressed.
#define XTESTS_TEST_WITH_MESSAGE(expr, msg)
 Causes a test to be exercised, passing an explanatory message to be used in the case of failure.
#define XTESTS_TEST(expr)
 Causes a test to be exercised.
#define XTESTS_TEST_ENUM_EQUAL(expected, actual)   XTESTS_TEST_INTEGER_EQUAL_EXACT(stlsoft_static_cast(int, (expected)), stlsoft_static_cast(int, (actual)))
 Tests that two enumerator values are exactly equal.
#define XTESTS_TEST_ENUM_NOT_EQUAL(expected, actual)   XTESTS_TEST_INTEGER_NOT_EQUAL(stlsoft_static_cast(int, (expected)), stlsoft_static_cast(int, (actual)))
 Tests that two enumerator values are not equal.
#define XTESTS_TEST_INTEGER_EQUAL_EXACT(expected, actual)
 Tests that two integer values are exactly equal.
#define XTESTS_TEST_INTEGER_NOT_EQUAL(expected, actual)
 Tests that two integer values are not equal.
#define XTESTS_TEST_INTEGER_GREATER(expected, actual)
 Tests that the actual integer value is greater than the expected value.
#define XTESTS_TEST_INTEGER_LESS(expected, actual)
 Tests that the actual integer value is less than the expected value.
#define XTESTS_TEST_INTEGER_GREATER_OR_EQUAL(expected, actual)
 Tests that the actual integer value is greater than or equal to the expected value.
#define XTESTS_TEST_INTEGER_LESS_OR_EQUAL(expected, actual)
 Tests that the actual integer value is less than or equal to the expected value.
#define XTESTS_TEST_INTEGER_EQUAL_ANY_IN_RANGE(begin, end, actual)
 Tests that a given integer value matches any of the elements in a given range.
#define XTESTS_TEST_INTEGER_EQUAL_ANY_NOT_IN_RANGE(begin, end, actual)
 Tests that a given integer value matches none of the elements in a given range.
#define XTESTS_TEST_BOOLEAN_EQUAL(expected, actual)
 Tests that two boolean values are exactly equal.
#define XTESTS_TEST_BOOLEAN_NOT_EQUAL(expected, actual)
 Tests that two boolean values are not equal.
#define XTESTS_TEST_BOOLEAN_TRUE(actual)
 Tests that an expression is true.
#define XTESTS_TEST_BOOLEAN_FALSE(actual)
 Tests that an expression is false.
#define XTESTS_TEST_CHARACTER_EQUAL_EXACT(expected, actual)
 Tests that two character values are exactly equal.
#define XTESTS_TEST_CHARACTER_NOT_EQUAL(expected, actual)
 Tests that two character values are not equal.
#define XTESTS_TEST_CHARACTER_GREATER(expected, actual)
 Tests that the actual character value is greater than the expected value.
#define XTESTS_TEST_CHARACTER_LESS(expected, actual)
 Tests that the actual character value is less than the expected value.
#define XTESTS_TEST_CHARACTER_GREATER_OR_EQUAL(expected, actual)
 Tests that the actual character value is greater than or equal to the expected value.
#define XTESTS_TEST_CHARACTER_LESS_OR_EQUAL(expected, actual)
 Tests that the actual character value is less than or equal to the expected value.
#define XTESTS_TEST_FLOATINGPOINT_EQUAL_EXACT(expected, actual)
 Tests that two floating point values are exactly equal.
#define XTESTS_TEST_FLOATINGPOINT_NOT_EQUAL_EXACT(expected, actual)
 Tests that two floating point values are not exactly equal.
#define XTESTS_TEST_FLOATINGPOINT_EQUAL_APPROX(expected, actual)
 Tests that two floating point values are approximately equal (as defined by xtests_setFloatingPointCloseFactor()).
#define XTESTS_TEST_FLOATINGPOINT_NOT_EQUAL_APPROX(expected, actual)
 Tests that two floating point values are not approximately equal (as defined by xtests_setFloatingPointCloseFactor()).
#define XTESTS_REQUIRE(test)   XTESTS_NS_CPP_QUAL(xtests_require)(!(!(test)))
 Causes the current test case to exit immediately if the given test fails, without considering any other tests.
#define XTESTS_ARRAY_END_POST(ar)   (&0[(ar)] + STLSOFT_NUM_ELEMENTS(ar))
 Evaluates the end-point of an array, based on its static array size.
#define XTESTS_TEST_INTEGER_EQUAL(expected, actual)   XTESTS_TEST_INTEGER_EQUAL_EXACT(expected, actual)
 Tests that two integer values (of the same type) are equal.
#define XTESTS_TEST_FLOATINGPOINT_EQUAL(expected, actual)   XTESTS_TEST_FLOATINGPOINT_EQUAL_APPROX(expected, actual)
 Tests that two floating point values (of the same type) are equal.
#define XTESTS_TEST_FLOATINGPOINT_NOT_EQUAL(expected, actual)   XTESTS_TEST_FLOATINGPOINT_NOT_EQUAL_APPROX(expected, actual)
 Tests that two floating point values (of the same type) are not equal.
#define XTESTS_TEST_CHARACTER_EQUAL(expected, actual)   XTESTS_TEST_CHARACTER_EQUAL_EXACT(expected, actual)
 Tests that two character values (of the same type) are equal.
#define XTESTS_TEST_MULTIBYTE_STRING_EQUAL(expected, actual)
 Tests that two (multibyte) strings are equal.
#define XTESTS_TEST_MULTIBYTE_STRING_EQUAL_APPROX(expected, actual)
 Tests that two (multibyte) strings are approximately equal (by ignoring case).
#define XTESTS_TEST_MULTIBYTE_STRING_NOT_EQUAL(expected, actual)
 Tests that two (multibyte) strings are not equal.
#define XTESTS_TEST_MULTIBYTE_STRING_NOT_EQUAL_APPROX(expected, actual)
 Tests that two (multibyte) strings are not equal (when ignoring case).
#define XTESTS_TEST_MULTIBYTE_STRING_EQUAL_N(expected, actual, n)
 Tests that two (multibyte) strings are equal up to a given limit.
#define XTESTS_TEST_MULTIBYTE_STRING_EQUAL_N_APPROX(expected, actual, n)
 Tests that two (multibyte) strings are approximately equal (by ignoring case), up to a given limit.
#define XTESTS_TEST_MULTIBYTE_STRING_NOT_EQUAL_N(expected, actual, n)
 Tests that two (multibyte) strings are not equal.
#define XTESTS_TEST_MULTIBYTE_STRING_NOT_EQUAL_N_APPROX(expected, actual, n)
 Tests that two (multibyte) strings are not equal (when ignoring case).
#define XTESTS_TEST_WIDE_STRING_EQUAL(expected, actual)
 Tests that two (wide) strings are equal.
#define XTESTS_TEST_WIDE_STRING_EQUAL_APPROX(expected, actual)
 Tests that two (wide) strings are approximately equal (by ignoring case).
#define XTESTS_TEST_WIDE_STRING_NOT_EQUAL(expected, actual)
 Tests that two (wide) strings are not equal.
#define XTESTS_TEST_WIDE_STRING_NOT_EQUAL_APPROX(expected, actual)
 Tests that two (wide) strings are not equal (when ignoring case).
#define XTESTS_TEST_WIDE_STRING_EQUAL_N(expected, actual, n)
 Tests that two (wide) strings are equal up to a given limit.
#define XTESTS_TEST_WIDE_STRING_EQUAL_N_APPROX(expected, actual, n)
 Tests that two (wide) strings are approximately equal (by ignoring case), up to a given limit.
#define XTESTS_TEST_WIDE_STRING_NOT_EQUAL_N(expected, actual, n)
 Tests that two (wide) strings are not equal.
#define XTESTS_TEST_WIDE_STRING_NOT_EQUAL_N_APPROX(expected, actual, n)
 Tests that two (wide) strings are not equal (when ignoring case).
#define XTESTS_TEST_MULTIBYTE_STRING_CONTAIN(expected, actual)
 Tests that the string contains the expected sub-sequence.
#define XTESTS_TEST_MULTIBYTE_STRING_CONTAIN_APPROX(expected, actual)
 Tests that the string contains the expected sub-sequence (disregarding case).
#define XTESTS_TEST_MULTIBYTE_STRING_NOT_CONTAIN(expected, actual)
 Tests that the string does not contain the expected sub-sequence.
#define XTESTS_TEST_MULTIBYTE_STRING_NOT_CONTAIN_APPROX(expected, actual)
 Tests that the string does not contain the expected sub-sequence (disregarding case).
#define XTESTS_TEST_WIDE_STRING_CONTAIN(expected, actual)
 Tests that the string contains the expected sub-sequence.
#define XTESTS_TEST_WIDE_STRING_CONTAIN_APPROX(expected, actual)
 Tests that the string contains the expected sub-sequence (disregarding case).
#define XTESTS_TEST_WIDE_STRING_NOT_CONTAIN(expected, actual)
 Tests that the string does not contain the expected sub-sequence.
#define XTESTS_TEST_WIDE_STRING_NOT_CONTAIN_APPROX(expected, actual)
 Tests that the string does not contain the expected sub-sequence.
#define XTESTS_TEST_POINTER_EQUAL(expected, actual)
 Tests that two pointers are equal.
#define XTESTS_TEST_POINTER_NOT_EQUAL(expected, actual)
 Tests that two pointer values are not equal.
#define XTESTS_TEST_POINTER_GREATER(expected, actual)
 Tests that the actual pointer value is greater than the expected value.
#define XTESTS_TEST_POINTER_LESS(expected, actual)
 Tests that the actual pointer value is less than the expected value.
#define XTESTS_TEST_POINTER_GREATER_OR_EQUAL(expected, actual)
 Tests that the actual pointer value is greater than or equal to the expected value.
#define XTESTS_TEST_POINTER_LESS_OR_EQUAL(expected, actual)
 Tests that the actual pointer value is less than or equal to the expected value.
#define XTESTS_TEST_FUNCTION_POINTER_EQUAL(expected, actual)
 Tests that two pointers are equal.
#define XTESTS_TEST_FUNCTION_POINTER_NOT_EQUAL(expected, actual)
 Tests that two pointer values are not equal.
#define XTESTS_FLOATINGPOINT_FACTOR_SCOPE   XTESTS_NS_CPP_QUAL(xtest_floatingpoint_factor_scope)
 [C++ only] Macro used to declare an instance of the class xtests::c::cpp::xtest_floatingpoint_factor_scope, which causes the floating point factor to be set to a new value for the lifetime of the object, and then returned to its prior value
#define XTESTS_COMMANDLINE_PARSEVERBOSITY(argc, argv, pverbosity)
 Parses a verbosity from the command-line.

Typedefs

typedef int(* xTests_Setup_t )(void *param)
 Function that is used to setup the test environment for each test case.
typedef int(* xTests_Teardown_t )(void *param)
 Function that is used to teardown the test environment for each test case.

Enumerations

enum  xtests_runner_flags_t
 Flags to be passed to xtests_startRunner. More...
enum  xtests_verbosity_t {
  XTESTS_VERBOSITY_SILENT = -1,
  XTESTS_VERBOSITY_RUNNER_SUMMARY_ON_ERROR = 0,
  XTESTS_VERBOSITY_RUNNER_SUMMARY = 1,
  XTESTS_VERBOSITY_FIRST_CASE_SUMMARY_ON_ERROR = 2,
  XTESTS_VERBOSITY_CASE_SUMMARY_ON_ERROR = 3,
  XTESTS_VERBOSITY_CASE_SUMMARY = 4,
  XTESTS_VERBOSITY_VERBOSE = 9
}
 The verbosity level to be applied when executing a test runner. More...

Functions

 xtests_setFloatingPointCloseFactor (double factor, double *old)
 Sets the floating-point number closesness factor, used in XTESTS_TEST_FLOATINGPOINT_EQUAL_APPROX().
 xtests_require_C (int success)
 [INTERNAL] Worker function for XTESTS_REQUIRE() (in C compilation units)
 xTests_hasRequiredConditionFailed (void)
 [INTERNAL] Worker function


Define Documentation

#define _XTESTS_VER   0x001004ff

The composite version of the xTests library.

#define _XTESTS_VER_MAJOR   0

The Major version number of the xTests library.

#define _XTESTS_VER_MINOR   16

Minor version number of the xTests library.

#define _XTESTS_VER_REVISION   4

The revision number of the xTests library.

#define XTESTS_FLOATINGPOINT_FACTOR_SCOPE   XTESTS_NS_CPP_QUAL(xtest_floatingpoint_factor_scope)

[C++ only] Macro used to declare an instance of the class xtests::c::cpp::xtest_floatingpoint_factor_scope, which causes the floating point factor to be set to a new value for the lifetime of the object, and then returned to its prior value

  XTESTS_TEST_FLOATINGPOINT_NOT_EQUAL(5.05, 5.06);

  XTESTS_FLOATINGPOINT_FACTOR_SCOPE factor_scoper(1.1); // highly permissive factor

  XTESTS_TEST_FLOATINGPOINT_EQUAL(5.05, 5.06);

#define XTESTS_FP_APPROXIMATE_FACTOR   (1.000001)

The factor within which floating point numbers are deemed to be approximately equal.


b64 Library documentation © Synesis Software Pty Ltd, 2004-2012