37 using error::LUMIERA_ERROR_FATAL;
38 using error::LUMIERA_ERROR_STATE;
42 const Literal THE_END =
"all dead and hero got the girl";
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); }
132 auto deaf =
Result{&Literal::empty, &THE_END};
133 CHECK (deaf.isValid());
134 CHECK (deaf ==
false);
136 CHECK (Type(deaf) ==
"Result<bool>"_expect);
Representation of the result of some operation, EITHER a value or a failure.
inline string literal This is a marker type to indicate that
#define VERIFY_ERROR(ERROR_ID, ERRONEOUS_STATEMENT)
Macro to verify that a statement indeed raises an exception.
Intermediary value object to represent »either« an operation result or a failure. ...
Implementation namespace for support and library code.
Derived specific exceptions within Lumiera's exception hierarchy.
Simplistic test class runner.
Tiny helper functions and shortcuts to be used everywhere Consider this header to be effectively incl...
A collection of frequently used helper functions to support unit testing.
bool isSameObject(A const &a, B const &b)
compare plain object identity, based directly on the referee's memory identities. ...