#include #include int main () { cruft::TAP::logger tap; tap.expect_nothrow ( [] () { (void)cruft::expected { "foo" }; }, "value construction succeeds" ); tap.expect_nothrow ( [] () { (void)cruft::expected { EPERM }; }, "error construction succeeds" ); tap.expect_eq (cruft::expected { "foo" }.value (), "foo", "value matches"); tap.expect_eq (cruft::expected { EPERM }.error (), EPERM, "error matches"); tap.expect_throw ( [] () { cruft::expected val { EPERM }; val.value (); }, "value access fails when holding an error" ); tap.expect_throw ( [] () { cruft::expected val { "foo" }; val.error (); }, "error access fails when holding a value" ); return tap.status (); }