diff --git a/test/mock/test-mock.cpp b/test/mock/test-mock.cpp index b8e89ad..b2950e8 100644 --- a/test/mock/test-mock.cpp +++ b/test/mock/test-mock.cpp @@ -25,20 +25,22 @@ #include #include -struct continuable_base { - template continuable_base& then(T&&) { return *this; } +template struct continuable { + template continuable(T&& = 0) {} - template continuable_base& dropped(T&&) { return *this; } + template continuable& then(T&&) { return *this; } - template continuable_base& thrown(T&&) { return *this; } + template continuable& dropped(T&&) { return *this; } - template continuable_base& failed(T&&) { return *this; } + template continuable& thrown(T&&) { return *this; } + + template continuable& failed(T&&) { return *this; } }; -template struct promise { - void set_value(T...) noexcept {} +template struct promise { + void set_value(A...) noexcept {} - void operator()(T...) && noexcept {} + void operator()(A...) && noexcept {} void set_exception(std::exception_ptr exception) noexcept { // ... @@ -63,10 +65,19 @@ template struct accumulator { template auto make_accumulator(Accumulator&& /*ac*/, Initial&&... /*initial*/) { - return std::make_tuple(continuable_base{}, accumulator{}); + return std::make_tuple(continuable<>{}, accumulator{}); } -continuable_base http_request(std::string) { return {}; } +continuable http_request(std::string url) { + return [url = std::move(url)](promise result) mutable { + // ... + result.set_value("..."); + // ... + result.set_exception(nullptr); + // ... + result.set_error(std::error_code{}); + }; +} int main(int, char**) { auto accumulator = make_accumulator(std::plus{}, 0);