Await unit test

This commit is contained in:
Denis Blank 2017-12-27 06:06:25 +01:00
parent 434db0fc24
commit d774371769

View File

@ -51,25 +51,28 @@ struct coroutine_traits<void, T...> {
} // namespace experimental } // namespace experimental
} // namespace std } // namespace std
auto mk() { /// Resolves the given promise asynchonously
return cti::make_continuable<void>([](auto&& promise) { template <typename S, typename T>
// ... void resolve_async(S&& supplier, T&& promise) {
promise.set_value(); co_await supplier();
});
}
void teststhh() { co_await supplier();
auto c = mk();
co_await std::move(c);
promise.set_value();
co_return; co_return;
} }
TYPED_TEST(single_dimension_tests, is_awaitable) { TYPED_TEST(single_dimension_tests, are_awaitable) {
auto const& supply = [&] {
// Supplies the current tested continuable
return this->supply();
};
teststhh(); EXPECT_ASYNC_RESULT(
this->supply().then(cti::make_continuable<void>([&](auto&& promise) {
// Resolve the cotinuable through a coroutine
resolve_async(supply, std::forward<decltype(promise)>(promise));
})));
} }
#endif // CONTINUABLE_HAS_EXPERIMENTAL_COROUTINE #endif // CONTINUABLE_HAS_EXPERIMENTAL_COROUTINE