diff --git a/test/unit-test/test-continuable-await.cpp b/test/unit-test/test-continuable-await.cpp index aed1e78..8b1e1fd 100644 --- a/test/unit-test/test-continuable-await.cpp +++ b/test/unit-test/test-continuable-await.cpp @@ -27,6 +27,8 @@ #include #endif // CONTINUABLE_WITH_NO_EXCEPTIONS +#include + #include "test-continuable.hpp" namespace std { @@ -58,18 +60,25 @@ struct coroutine_traits { /// Resolves the given promise asynchonously template void resolve_async(S&& supplier, T&& promise) { + // 0 args co_await supplier(); - co_await supplier(); + // 1 args + int a1 = co_await supplier(1); + EXPECT_EQ(a1, 1); + + // 2-n args + std::tuple a2 = co_await supplier(1, 2); + EXPECT_EQ(a2, std::make_tuple(1, 2)); promise.set_value(); co_return; } TYPED_TEST(single_dimension_tests, are_awaitable) { - auto const& supply = [&] { + auto const& supply = [&](auto&&... args) { // Supplies the current tested continuable - return this->supply(); + return this->supply(std::forward(args)...); }; EXPECT_ASYNC_RESULT( @@ -94,8 +103,17 @@ struct await_exception : std::exception { /// Resolves the given promise asynchonously through an exception template void resolve_async_exceptional(S&& supplier, T&& promise) { + // 0 args co_await supplier(); + // 1 args + int a1 = co_await supplier(1); + EXPECT_EQ(a1, 1); + + // 2-n args + std::tuple a2 = co_await supplier(1, 2); + EXPECT_EQ(a2, std::make_tuple(1, 2)); + ASSERT_THROW(co_await supplier().then([] { throw await_exception{}; }), await_exception); @@ -104,9 +122,9 @@ void resolve_async_exceptional(S&& supplier, T&& promise) { } TYPED_TEST(single_dimension_tests, are_awaitable_with_exceptions) { - auto const& supply = [&] { + auto const& supply = [&](auto&&... args) { // Supplies the current tested continuable - return this->supply(); + return this->supply(std::forward(args)...); }; ASSERT_ASYNC_COMPLETION(