37 using error::LUMIERA_ERROR_FATAL;
38 using error::LUMIERA_ERROR_STATE;
45 #define Type(_EXPR_) lib::test::showType<decltype(_EXPR_)>()
71 auto happy =
Result{THE_END};
72 CHECK (happy == THE_END);
73 CHECK (happy.isValid());
78 CHECK (
Type(happy) ==
"Result<Literal const&>"_expect);
82 CHECK (sequel.isValid());
83 CHECK (
Type(sequel) ==
"Result<Literal>"_expect);
85 CHECK ( isSameObject (happy.get<
Literal const&>(), THE_END));
86 CHECK (not isSameObject (sequel.get<
Literal const&>(), THE_END));
90 CHECK (not facepalm.isValid());
96 CHECK (42.0 == facepalm.or_else([]{ return 42; }));
97 CHECK (42.0 == facepalm.value_or(210/5));
101 auto evil = [](
auto it)
110 auto seed =
Result{evil,
'*'};
111 CHECK (
Type(seed) ==
"Result<char>"_expect);
114 auto breed =
Result{evil, 55ll};
116 CHECK (
Type(breed) ==
"Result<llong>"_expect);
118 auto dead =
Result{[]{
throw 55; }};
119 auto deed =
Result{[]{ }};
121 CHECK (
Type(dead) ==
"Result<void>"_expect);
122 CHECK (
Type(deed) ==
"Result<void>"_expect);
124 CHECK (not dead.isValid());
125 CHECK ( deed.isValid());
127 try { dead.maybeThrow(); }
129 { CHECK (oo == 55); }
133 CHECK (deaf.isValid());
134 CHECK (deaf ==
false);
136 CHECK (
Type(deaf) ==
"Result<bool>"_expect);
constexpr bool empty() const
Representation of the result of some operation, EITHER a value or a failure.
Implementation namespace for support and library code.
LumieraError< LERR_(STATE)> State
LumieraError< LERR_(FATAL), Logic > Fatal
Test runner and basic definitions for tests.
bool isSameObject(A const &a, B const &b)
compare plain object identity, based directly on the referee's memory identities.
Intermediary value object to represent »either« an operation result or a failure.
Simplistic test class runner.
#define LAUNCHER(_TEST_CLASS_, _GROUPS_)
A collection of frequently used helper functions to support unit testing.
#define VERIFY_ERROR(ERROR_ID, ERRONEOUS_STATEMENT)
Macro to verify that a statement indeed raises an exception.
Tiny helper functions and shortcuts to be used everywhere Consider this header to be effectively incl...