46 using error::LUMIERA_ERROR_FATAL;
47 using error::LUMIERA_ERROR_STATE;
51 const Literal THE_END =
"all dead and hero got the girl";
54 #define Type(_EXPR_) lib::test::showType<decltype(_EXPR_)>() 80 auto happy =
Result{THE_END};
81 CHECK (happy == THE_END);
82 CHECK (happy.isValid());
87 CHECK (Type(happy) ==
"Result<Literal const&>"_expect);
91 CHECK (sequel.isValid());
92 CHECK (Type(sequel) ==
"Result<Literal>"_expect);
94 CHECK ( isSameObject (happy.get<
Literal const&>(), THE_END));
95 CHECK (not isSameObject (sequel.get<
Literal const&>(), THE_END));
99 CHECK (not facepalm.isValid());
105 CHECK (42.0 == facepalm.or_else([]{ return 42; }));
106 CHECK (42.0 == facepalm.value_or(210/5));
110 auto evil = [](
auto it)
119 auto seed =
Result{evil,
'*'};
120 CHECK (Type(seed) ==
"Result<char>"_expect);
123 auto breed =
Result{evil, 55ll};
125 CHECK (Type(breed) ==
"Result<long long>"_expect);
127 auto dead =
Result{[]{
throw 55; }};
128 auto deed =
Result{[]{ }};
130 CHECK (Type(dead) ==
"Result<void>"_expect);
131 CHECK (Type(deed) ==
"Result<void>"_expect);
133 CHECK (not dead.isValid());
134 CHECK ( deed.isValid());
136 try { dead.maybeThrow(); }
138 { CHECK (oo == 55); }
141 auto deaf =
Result{&Literal::empty, &THE_END};
142 CHECK (deaf.isValid());
143 CHECK (deaf ==
false);
145 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.
Simple 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, bypassing any custom comparison operators.