Lumiera
0.pre.03
»edit your freedom«
|
Go to the source code of this file.
A collection of frequently used helper functions to support unit testing.
Some are test data generators, some are diagnostics helpers to produce readable output. Some of these support meta programming to figure out the actual reference kind (value, lvalue, rvalue) of a template parameter instantiation. For GNU compatible compilers, we expose also the interface to the internal ABI for demangling type names.
Definition in file test-helper.hpp.
#include "lib/symbol.hpp"
#include "lib/meta/trait.hpp"
#include "lib/time/timevalue.hpp"
#include "lib/test/transiently.hpp"
#include "lib/format-obj.hpp"
#include "lib/random.hpp"
#include <boost/lexical_cast.hpp>
#include <typeinfo>
#include <cstdlib>
#include <limits>
#include <string>
#include <cmath>
Classes | |
class | ExpectString |
Helper to produce better diagnostic messages when comparing to an expected result string. More... | |
struct | TypeDebugger< X > |
Helper to show types involved in metaprogramming. More... | |
struct | TypeDiagnostics< X > |
struct | TypeDiagnostics< const X * > |
struct | TypeDiagnostics< const X *const > |
struct | TypeDiagnostics< const X > |
struct | TypeDiagnostics< X & > |
struct | TypeDiagnostics< X && > |
struct | TypeDiagnostics< X * > |
struct | TypeDiagnostics< X *const * > |
struct | TypeDiagnostics< X *const > |
struct | TypeDiagnostics< X const & > |
struct | TypeDiagnostics< X const && > |
Macros | |
#define | MARK_TEST_FUN cout << "|" << endl << "| »"<<__FUNCTION__<<"«" <<endl; |
Macro to mark the current test function in STDOUT. More... | |
#define | VERIFY_ERROR(ERROR_ID, ERRONEOUS_STATEMENT) |
Macro to verify that a statement indeed raises an exception. More... | |
#define | VERIFY_FAIL(FAILURE_MSG, ERRONEOUS_STATEMENT) |
Macro to verify that a statement indeed raises a std::exception, which additionally contains some FAILURE_MSG in its description. More... | |
Functions | |
template<typename F , typename N > | |
constexpr meta::enable_if< std::is_floating_point< F >, bool > | epsEQ (F val, N target, uint ulps=EPSILON_ULP) |
lib::test::ExpectString | operator""_expect (const char *lit, size_t siz) |
string | randStr (size_t len) |
create garbage string of given length More... | |
lib::time::Time | randTime () |
create a random but not insane Time value between 1s ... More... | |
template<typename F , typename N > | |
constexpr meta::enable_if< std::is_floating_point< F >, bool > | roughEQ (F val, N target, F limit=ROUGH_PRECISION) |
template<typename R > | |
string | showRefKind () |
helper to discern the kind of reference of the argument type | |
string | showSizeof (size_t siz, string name) |
for printing sizeof(). More... | |
template<typename T > | |
string | showSizeof (T const *obj=0, const char *name=0) |
for printing sizeof(), possibly figuring out the type name automatically More... | |
template<typename T > | |
meta::disable_if< std::is_pointer< T >, string > | showSizeof (T const &obj, const char *name=0) |
template<typename T > | |
string | showSizeof (const char *name) |
template<typename X > | |
string | showType () |
diagnostic type output, including const and similar adornments More... | |
template<typename... TS> | |
string | showTypes () |
template<typename... EMPTY> | |
string | showVariadicTypes () |
helper for investigating a variadic argument pack More... | |
template<typename XX , typename... XS> | |
string | showVariadicTypes (XX &&x, XS &&... xs) |
template<typename X > | |
void | typeDebugger (X &&x) |
template<typename F > | |
constexpr meta::enable_if< std::is_floating_point< F >, F > | ulp (F val) |
Variables | |
constexpr auto | EPSILON_ULP = 5 |
constexpr auto | ROUGH_PRECISION = pow (10, -3) |
Namespaces | |
lib | |
Implementation namespace for support and library code. | |
#define VERIFY_ERROR | ( | ERROR_ID, | |
ERRONEOUS_STATEMENT | |||
) |
Macro to verify that a statement indeed raises an exception.
If no exception is thrown, the #NOTREACHED macro will trigger an assertion failure. In case of exception, the lumiera_error state is checked, cleared and verified.
Definition at line 387 of file test-helper.hpp.
Referenced by CustomSharedPtr_test::check_ordering(), ScopePath_test::check_RefcountProtection(), IterCoreAdapter_test::checked_and_protected(), EntryID_test::checkErasure(), TestHelper_test::checkThrowChecker(), TimeValue_test::checkTimeHash(), CreateAsset_test::createMedia(), DiffIgnoreChanges_test::fail_or_ignore(), DispatcherInterface_test::resolveModelPort(), IterZip_test::simpleUsage(), IterCoreAdapter_test::value_and_reference_yield(), LazyInit_test::verify_complexUsageWithCopy(), DiagnosticContext_test::verify_simpleAccess(), WLink_test::verify_standardUsage(), DependencyConfiguration_test::verify_SubclassSingleton(), and ItemWrapper_test::verifyFunctionResult().
#define VERIFY_FAIL | ( | FAILURE_MSG, | |
ERRONEOUS_STATEMENT | |||
) |
Macro to verify that a statement indeed raises a std::exception, which additionally contains some FAILURE_MSG in its description.
Definition at line 411 of file test-helper.hpp.
Referenced by DataCSV_test::demonnstrate_CSV_Notation().
#define MARK_TEST_FUN cout << "|" << endl << "| »"<<__FUNCTION__<<"«" <<endl; |
Macro to mark the current test function in STDOUT.
This can be helpful to digest a long test output dump
Definition at line 437 of file test-helper.hpp.
Referenced by BusTerm_test::attachNewBusTerm(), BusTerm_test::captureStateMark(), BusTerm_test::clearStates(), BusTerm_test::commandInvocation(), SchedulerCommutator_test::demonstrateSimpleUsage(), SchedulerCommutator_test::integratedWorkCycle(), SchedulerStress_test::investigateWorkProcessing(), AbstractTangible_test::markState(), AbstractTangible_test::mutate(), TreeMutatorBinding_test::mutateAttribute(), TreeMutatorBinding_test::mutateCollection(), TreeMutatorBinding_test::mutateDummy(), TreeMutatorBinding_test::mutateGenNode(), AbstractTangible_test::notify(), SchedulerService_test::processSchedule(), BusTerm_test::pushDiff(), BusTerm_test::replayStateMark(), AbstractTangible_test::revealer(), SchedulerStress_test::search_breaking_point(), SchedulerStress_test::setup_systematicSchedule(), SchedulerStress_test::smokeTest(), SchedulerCommutator_test::torture_GroomingToken(), SchedulerCommutator_test::verify_dispatch(), SchedulerCommutator_test::verify_findWork(), SchedulerCommutator_test::verify_GroomingGuard(), SchedulerCommutator_test::verify_GroomingToken(), SchedulerStress_test::verify_instrumentation(), AbstractTangible_test::verify_mockManipulation(), SchedulerCommutator_test::verify_postChain(), SchedulerCommutator_test::verify_Significance(), BusTerm_test::verifyNotifications(), and SchedulerStress_test::watch_expenseFunction().
string showSizeof | ( | size_t | siz, |
string | name | ||
) |
for printing sizeof().
prints the given size and name literally, without any further magic
Definition at line 49 of file test-helper.cpp.
References lib::test::showSizeof().
Referenced by TestHelper_test::checkTypeDisplay(), and lib::test::showSizeof().
|
inline |
for printing sizeof(), possibly figuring out the type name automatically
name | when given, this name will be used for display, instead of auto detecting the type |
Definition at line 107 of file test-helper.hpp.
|
inline |
diagnostic type output, including const and similar adornments
Definition at line 256 of file test-helper.hpp.
References lib::test::showType().
Referenced by lib::test::showType(), IterCoreAdapter_test::value_and_reference_yield(), HeteroData_test::verify_ChainBlock(), and HeteroData_test::verify_FrontBlock().
|
inline |
helper for investigating a variadic argument pack
std::forward<ARGS>(args)...
when forwarding universal references received from a variadic argument pack ARG. Definition at line 284 of file test-helper.hpp.
Referenced by TestHelperVariadic_test::forwardFunction().
|
inline |
create a random but not insane Time value between 1s ...
10min + 500ms
Definition at line 308 of file test-helper.hpp.
References lib::test::randTime().
Referenced by lib::test::randTime().
string randStr | ( | size_t | len | ) |
create garbage string of given length
Anyone...?
Definition at line 61 of file test-helper.cpp.
References lib::test::randStr().
Referenced by TestHelper_test::checkTypeDisplay(), TestSource::nextResult(), and lib::test::randStr().