![]() |
Lumiera 0.pre.04
»edit your freedom«
|
A collection of frequently used helper functions to support unit testing. More...
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 <utility>#include <limits>#include <string>#include <cmath>Namespaces | |
| namespace | lib |
| Implementation namespace for support and library code. | |
| namespace | lib::test |
| Unit tests for the Lumiera support library. | |
| namespace | lib::test::anonymous_namespace{test-helper.hpp} |
Macros | |
| #define | VERIFY_ERROR(ERROR_ID, ERRONEOUS_STATEMENT) |
| Macro to verify that a statement indeed raises an exception. | |
| #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. | |
| #define | MARK_TEST_FUN cout << "|" << endl << "| »"<<__FUNCTION__<<"«" <<endl; |
| Macro to mark the current test function in STDOUT. | |
Classes | |
| struct | TypeDebugger< X > |
| Helper to show types involved in metaprogramming. More... | |
| struct | TypeDiagnostics< X > |
| struct | TypeDiagnostics< const X > |
| struct | TypeDiagnostics< X & > |
| struct | TypeDiagnostics< X && > |
| struct | TypeDiagnostics< X const & > |
| struct | TypeDiagnostics< X const && > |
| struct | TypeDiagnostics< X * > |
| struct | TypeDiagnostics< const X * > |
| struct | TypeDiagnostics< const X *const > |
| struct | TypeDiagnostics< X *const > |
| struct | TypeDiagnostics< X *const * > |
| class | ExpectString |
| Helper to produce better diagnostic messages when comparing to an expected result string. More... | |
Functions | |
| 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 F > | |
| constexpr meta::enable_if< std::is_floating_point< F >, F > | ulp (F val) |
| template<typename F , typename N > | |
| constexpr meta::enable_if< std::is_floating_point< F >, bool > | epsEQ (F val, N target, uint ulps=EPSILON_ULP) |
| string | showSizeof (size_t siz, string name) |
| for printing sizeof(). | |
| template<typename T > | |
| string | showSizeof (T const *obj=0, CStr name=0) |
| for printing sizeof(), possibly figuring out the type name automatically | |
| template<typename T > | |
| meta::disable_if< std::is_pointer< T >, string > | showSizeof (T const &obj, CStr name=nullptr) |
| template<typename T > | |
| string | showSizeof (CStr name) |
| template<typename R > | |
| string | showRefKind () |
| helper to discern the kind of reference of the argument type | |
| template<typename X > | |
| void | typeDebugger (X &&x) |
| template<typename X > | |
| string | showType () |
| diagnostic type output, including const and similar adornments | |
| template<typename... TS> | |
| string | showTypes () |
| template<typename... EMPTY> | |
| string | showVariadicTypes () |
| helper for investigating a variadic argument pack | |
| template<typename XX , typename... XS> | |
| string | showVariadicTypes (XX &&x, XS &&... xs) |
| lib::time::Time | randTime () |
| create a random but not insane Time value between 1s ... 10min + 500ms | |
| string | randStr (size_t len) |
| create garbage string of given length | |
| lib::test::ExpectString | operator""_expect (CStr lit, size_t siz) |
Variables | |
| constexpr auto | ROUGH_PRECISION = pow (10, -3) |
| constexpr auto | EPSILON_ULP = 5 |
| #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 393 of file test-helper.hpp.
| #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 417 of file test-helper.hpp.
| #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 443 of file test-helper.hpp.
| struct lib::test::TypeDebugger |
Collaboration diagram for TypeDebugger< X >:
|
inline |
Definition at line 378 of file test-helper.hpp.