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/time/timevalue.hpp"
#include "lib/format-obj.hpp"
#include <boost/lexical_cast.hpp>
#include <typeinfo>
#include <cstdlib>
#include <string>
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 a statement indeed raises an exception. More... | |
Functions | |
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 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... EMPTY> | |
string | showVariadicTypes () |
helper for investigating a variadic argument pack More... | |
template<typename X , typename... XS> | |
string | showVariadicTypes (X const &x, XS const &... xs) |
template<typename X > | |
void | typeDebugger (X &&x) |
Namespaces | |
lib | |
Implementation namespace for support and library code. | |
#define VERIFY_ERROR | ( | ERROR_ID, | |
ERRONEOUS_STATEMENT | |||
) |
Macro to verify a statement indeed raises an exception.
If no exception is thrown, the #NOTREACHED macro will trigger an assertion failure. In case of an exception, the lumiera_error state is checked, cleared and verified.
Definition at line 344 of file test-helper.hpp.
Referenced by CustomSharedPtr_test::check_ordering(), ScopePath_test::check_RefcountProtection(), EntryID_test::checkErasure(), TestHelper_test::checkThrowChecker(), TimeValue_test::checkTimeHash(), DiffIgnoreChanges_test::fail_or_ignore(), DispatcherInterface_test::resolveModelPort(), DiagnosticContext_test::verify_simpleAccess(), WLink_test::verify_standardUsage(), DependencyConfiguration_test::verify_SubclassSingleton(), and ItemWrapper_test::verifyFunctionResult().
#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 369 of file test-helper.hpp.
Referenced by BusTerm_test::attachNewBusTerm(), BusTerm_test::captureStateMark(), BusTerm_test::clearStates(), BusTerm_test::commandInvocation(), AbstractTangible_test::markState(), AbstractTangible_test::mutate(), TreeMutatorBinding_test::mutateAttribute(), TreeMutatorBinding_test::mutateCollection(), TreeMutatorBinding_test::mutateDummy(), TreeMutatorBinding_test::mutateGenNode(), AbstractTangible_test::notify(), BusTerm_test::pushDiff(), BusTerm_test::replayStateMark(), AbstractTangible_test::revealer(), AbstractTangible_test::verify_mockManipulation(), and BusTerm_test::verifyNotifications().
string showSizeof | ( | size_t | siz, |
string | name | ||
) |
for printing sizeof().
prints the given size and name literally, without any further magic
Definition at line 57 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 76 of file test-helper.hpp.
|
inline |
helper for investigating a variadic argument pack
showVariadicTypes<ARGS...>
(args...) otherwise the template argument matching for functions might mess up the kind of reference you'll see in the diagnostics. Definition at line 118 of file test-helper.hpp.
Referenced by TestHelperVariadic_test::forwardFunction().
|
inline |
diagnostic type output, including const and similar adornments
Definition at line 250 of file test-helper.hpp.
References lib::test::showType().
Referenced by lib::test::showType().
|
inline |
create a random but not insane Time value between 1s ...
10min + 500ms
Definition at line 265 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 69 of file test-helper.cpp.
References lib::test::randStr().
Referenced by TestHelper_test::checkTypeDisplay(), and lib::test::randStr().