mirror of
https://github.com/Naios/continuable.git
synced 2026-02-17 07:39:49 +08:00
Await unit test
This commit is contained in:
parent
434db0fc24
commit
d774371769
@ -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
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user