TEST(Promise, setWith) { { Promise<int> p; auto f = p.getFuture(); p.setWith([] { return 42; }); EXPECT_EQ(42, f.value()); } { Promise<int> p; auto f = p.getFuture(); p.setWith([]() -> int { throw eggs; }); EXPECT_THROW(f.value(), eggs_t); } }
TEST(Future, getFutureAfterSetException) { Promise<Unit> p; p.setWith([]() -> void { throw std::logic_error("foo"); }); EXPECT_THROW(p.getFuture().value(), std::logic_error); }
TEST(Poll, exception) { Promise<Unit> p; auto f = p.getFuture(); p.setWith([] { throw std::runtime_error("Runtime"); }); EXPECT_TRUE(f.poll().value().hasException()); }