mirror of
https://github.com/Naios/continuable.git
synced 2025-12-08 01:36:46 +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 std
|
||||
|
||||
auto mk() {
|
||||
return cti::make_continuable<void>([](auto&& promise) {
|
||||
// ...
|
||||
promise.set_value();
|
||||
});
|
||||
}
|
||||
/// Resolves the given promise asynchonously
|
||||
template <typename S, typename T>
|
||||
void resolve_async(S&& supplier, T&& promise) {
|
||||
co_await supplier();
|
||||
|
||||
void teststhh() {
|
||||
auto c = mk();
|
||||
|
||||
co_await std::move(c);
|
||||
co_await supplier();
|
||||
|
||||
promise.set_value();
|
||||
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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user