diff --git a/include/async_promise.hpp b/include/async_promise.hpp index b00532f..592679f 100644 --- a/include/async_promise.hpp +++ b/include/async_promise.hpp @@ -2086,10 +2086,25 @@ class promise /** - * @brief Make promise with an function to be called. - * Return promise object with a result or an error. - * @param func - Function. - * @param args - Function arguments. + * @brief Make a promise object with an initial class method. + * @param method - Method for call. + * @param obj - Object containing the required method. + * @param args - Optional arguments. + * @return Promise object. + */ +template::type, + typename = typename std::enable_if::value>::type> +static promise make_promise(Method&& method, Class* obj, Args&&... args) +{ + return promise{std::forward(method), obj, std::forward(args)...}; +} + + +/** + * @brief Make a promise object with an initial function. + * @param func - Function or class method for call. + * @param args - Optional arguments. * @return Promise object. */ template -** -** This file is part of the async_promise project - which can be found at -** https://github.com/IvanPinezhaninov/async_promise/. -** -** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -** IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -** FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, -** DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR -** OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR -** THE USE OR OTHER DEALINGS IN THE SOFTWARE. -** -******************************************************************************/ - -// async_promise -#include - -// catch2 -#include -#include - -// local -#include "test_funcs.h" - -static constexpr auto str = "Hello World!"; - - -TEST_CASE("Func initial void void", "[initial]") -{ - auto future = async::promise{void_void}.run(); - - REQUIRE_NOTHROW(future.get()); -} - - -TEST_CASE("Func initial error void void", "[initial]") -{ - auto future = async::promise{error_void_void}.run(); - - REQUIRE_THROWS_MATCHES(future.get(), std::runtime_error, Catch::Matchers::Message(str)); -} - - -TEST_CASE("Func initial void string", "[initial]") -{ - auto future = async::promise{void_string, str}.run(); - - REQUIRE_NOTHROW(future.get()); -} - - -TEST_CASE("Func initial error void string", "[initial]") -{ - auto future = async::promise{error_void_string, str}.run(); - - REQUIRE_THROWS_MATCHES(future.get(), std::runtime_error, Catch::Matchers::Message(str)); -} - - -TEST_CASE("Func initial string void", "[initial]") -{ - auto future = async::promise{string_void}.run(); - - std::string res; - REQUIRE_NOTHROW(res = future.get()); - REQUIRE(res == str); -} - - -TEST_CASE("Func initial error string void", "[initial]") -{ - auto future = async::promise{error_string_void}.run(); - - REQUIRE_THROWS_MATCHES(future.get(), std::runtime_error, Catch::Matchers::Message(str)); -} - - -TEST_CASE("Func initial string string", "[initial]") -{ - auto future = async::promise{string_string, str}.run(); - - std::string res; - REQUIRE_NOTHROW(res = future.get()); - REQUIRE(res == str); -} - - -TEST_CASE("Func initial error string string", "[initial]") -{ - auto future = async::promise{error_string_string, str}.run(); - - REQUIRE_THROWS_MATCHES(future.get(), std::runtime_error, Catch::Matchers::Message(str)); -} diff --git a/tests/src/func_then.cpp b/tests/src/func_then.cpp deleted file mode 100644 index dd26b16..0000000 --- a/tests/src/func_then.cpp +++ /dev/null @@ -1,130 +0,0 @@ -/****************************************************************************** -** -** Copyright (C) 2023 Ivan Pinezhaninov -** -** This file is part of the async_promise project - which can be found at -** https://github.com/IvanPinezhaninov/async_promise/. -** -** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -** IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -** FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, -** DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR -** OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR -** THE USE OR OTHER DEALINGS IN THE SOFTWARE. -** -******************************************************************************/ - -// async_promise -#include - -// catch2 -#include -#include - -// local -#include "test_funcs.h" - -static constexpr auto str = "Hello World!"; - - -TEST_CASE("Func then void void", "[then]") -{ - auto future = async::make_resolved_promise().then(void_void).run(); - - REQUIRE_NOTHROW(future.get()); -} - - -TEST_CASE("Func then error void void", "[then]") -{ - auto future = async::make_resolved_promise().then(error_void_void).run(); - - REQUIRE_THROWS_MATCHES(future.get(), std::runtime_error, Catch::Matchers::Message(str)); -} - - -TEST_CASE("Func then void void ignore arg", "[then]") -{ - auto future = async::make_resolved_promise(str).then(void_void).run(); - - REQUIRE_NOTHROW(future.get()); -} - - -TEST_CASE("Func then error void void ignore arg", "[then]") -{ - auto future = async::make_resolved_promise(str).then(error_void_void).run(); - - REQUIRE_THROWS_MATCHES(future.get(), std::runtime_error, Catch::Matchers::Message(str)); -} - - -TEST_CASE("Func then void string", "[then]") -{ - auto future = async::make_resolved_promise(str).then(void_string).run(); - - REQUIRE_NOTHROW(future.get()); -} - - -TEST_CASE("Func then error void string", "[then]") -{ - auto future = async::make_resolved_promise(str).then(error_void_string).run(); - - REQUIRE_THROWS_MATCHES(future.get(), std::runtime_error, Catch::Matchers::Message(str)); -} - - -TEST_CASE("Func then string void", "[then]") -{ - auto future = async::make_resolved_promise().then(string_void).run(); - - std::string res; - REQUIRE_NOTHROW(res = future.get()); - REQUIRE(res == str); -} - - -TEST_CASE("Func then error string void", "[then]") -{ - auto future = async::make_resolved_promise().then(error_string_void).run(); - - REQUIRE_THROWS_MATCHES(future.get(), std::runtime_error, Catch::Matchers::Message(str)); -} - - -TEST_CASE("Func then string void ignore arg", "[then]") -{ - auto future = async::make_resolved_promise(str).then(string_void).run(); - - std::string res; - REQUIRE_NOTHROW(res = future.get()); - REQUIRE(res == str); -} - - -TEST_CASE("Func then error string void ignore arg", "[then]") -{ - auto future = async::make_resolved_promise(str).then(error_string_void).run(); - - REQUIRE_THROWS_MATCHES(future.get(), std::runtime_error, Catch::Matchers::Message(str)); -} - - -TEST_CASE("Func then string string", "[then]") -{ - auto future = async::make_resolved_promise(str).then(string_string).run(); - - std::string res; - REQUIRE_NOTHROW(res = future.get()); - REQUIRE(res == str); -} - - -TEST_CASE("Func then error string string", "[then]") -{ - auto future = async::make_resolved_promise(str).then(error_string_string).run(); - - REQUIRE_THROWS_MATCHES(future.get(), std::runtime_error, Catch::Matchers::Message(str)); -} diff --git a/tests/src/class_initial.cpp b/tests/src/initial.cpp similarity index 55% rename from tests/src/class_initial.cpp rename to tests/src/initial.cpp index 4ff3e00..1ea5eb8 100644 --- a/tests/src/class_initial.cpp +++ b/tests/src/initial.cpp @@ -23,12 +23,13 @@ #include // local +#include "test_funcs.h" #include "test_struct.h" static constexpr auto str = "Hello World!"; -TEST_CASE("Class initial void void", "[initial]") +TEST_CASE("Initial class void void", "[initial]") { test_struct test; auto future = async::promise{&test_struct::void_void, &test}.run(); @@ -37,7 +38,7 @@ TEST_CASE("Class initial void void", "[initial]") } -TEST_CASE("Class initial error void void", "[initial]") +TEST_CASE("Initial class error void void", "[initial]") { test_struct test; auto future = async::promise{&test_struct::error_void_void, &test}.run(); @@ -46,7 +47,7 @@ TEST_CASE("Class initial error void void", "[initial]") } -TEST_CASE("Class initial void string", "[initial]") +TEST_CASE("Initial class void string", "[initial]") { test_struct test; auto future = async::promise{&test_struct::void_string, &test, str}.run(); @@ -55,7 +56,7 @@ TEST_CASE("Class initial void string", "[initial]") } -TEST_CASE("Class initial error void string", "[initial]") +TEST_CASE("Initial class error void string", "[initial]") { test_struct test; auto future = async::promise{&test_struct::error_void_string, &test, str}.run(); @@ -64,7 +65,7 @@ TEST_CASE("Class initial error void string", "[initial]") } -TEST_CASE("Class initial string void", "[initial]") +TEST_CASE("Initial class string void", "[initial]") { test_struct test; auto future = async::promise{&test_struct::string_void, &test}.run(); @@ -75,7 +76,7 @@ TEST_CASE("Class initial string void", "[initial]") } -TEST_CASE("Class initial error string void", "[initial]") +TEST_CASE("Initial class error string void", "[initial]") { test_struct test; auto future = async::promise{&test_struct::error_string_void, &test}.run(); @@ -84,7 +85,7 @@ TEST_CASE("Class initial error string void", "[initial]") } -TEST_CASE("Class initial string string", "[initial]") +TEST_CASE("Initial class string string", "[initial]") { test_struct test; auto future = async::promise{&test_struct::string_string, &test, str}.run(); @@ -95,10 +96,79 @@ TEST_CASE("Class initial string string", "[initial]") } -TEST_CASE("Class initial error string string", "[initial]") +TEST_CASE("Initial class error string string", "[initial]") { test_struct test; auto future = async::promise{&test_struct::error_string_string, &test, str}.run(); REQUIRE_THROWS_MATCHES(future.get(), std::runtime_error, Catch::Matchers::Message(str)); } + + +TEST_CASE("Initial func void void", "[initial]") +{ + auto future = async::promise{void_void}.run(); + + REQUIRE_NOTHROW(future.get()); +} + + +TEST_CASE("Initial func error void void", "[initial]") +{ + auto future = async::promise{error_void_void}.run(); + + REQUIRE_THROWS_MATCHES(future.get(), std::runtime_error, Catch::Matchers::Message(str)); +} + + +TEST_CASE("Initial func void string", "[initial]") +{ + auto future = async::promise{void_string, str}.run(); + + REQUIRE_NOTHROW(future.get()); +} + + +TEST_CASE("Initial func error void string", "[initial]") +{ + auto future = async::promise{error_void_string, str}.run(); + + REQUIRE_THROWS_MATCHES(future.get(), std::runtime_error, Catch::Matchers::Message(str)); +} + + +TEST_CASE("Initial func string void", "[initial]") +{ + auto future = async::promise{string_void}.run(); + + std::string res; + REQUIRE_NOTHROW(res = future.get()); + REQUIRE(res == str); +} + + +TEST_CASE("Initial func error string void", "[initial]") +{ + auto future = async::promise{error_string_void}.run(); + + REQUIRE_THROWS_MATCHES(future.get(), std::runtime_error, Catch::Matchers::Message(str)); +} + + +TEST_CASE("Initial func string string", "[initial]") +{ + auto future = async::promise{string_string, str}.run(); + + std::string res; + REQUIRE_NOTHROW(res = future.get()); + REQUIRE(res == str); +} + + +TEST_CASE("Initial func error string string", "[initial]") +{ + auto future = async::promise{error_string_string, str}.run(); + + REQUIRE_THROWS_MATCHES(future.get(), std::runtime_error, Catch::Matchers::Message(str)); +} + diff --git a/tests/src/make_promise.cpp b/tests/src/make_promise.cpp new file mode 100644 index 0000000..722e503 --- /dev/null +++ b/tests/src/make_promise.cpp @@ -0,0 +1,173 @@ +/****************************************************************************** +** +** Copyright (C) 2023 Ivan Pinezhaninov +** +** This file is part of the async_promise project - which can be found at +** https://github.com/IvanPinezhaninov/async_promise/. +** +** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +** IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +** FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +** DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +** OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR +** THE USE OR OTHER DEALINGS IN THE SOFTWARE. +** +******************************************************************************/ + +// async_promise +#include + +// catch2 +#include +#include + +// local +#include "test_funcs.h" +#include "test_struct.h" + +static constexpr auto str = "Hello World!"; + + +TEST_CASE("Make promise class void void", "[initial]") +{ + test_struct test; + auto future = async::make_promise(&test_struct::void_void, &test).run(); + + REQUIRE_NOTHROW(future.get()); +} + + +TEST_CASE("Make promise class error void void", "[initial]") +{ + test_struct test; + auto future = async::make_promise(&test_struct::error_void_void, &test).run(); + + REQUIRE_THROWS_MATCHES(future.get(), std::runtime_error, Catch::Matchers::Message(str)); +} + + +TEST_CASE("Make promise class void string", "[initial]") +{ + test_struct test; + auto future = async::make_promise(&test_struct::void_string, &test, str).run(); + + REQUIRE_NOTHROW(future.get()); +} + + +TEST_CASE("Make promise class error void string", "[initial]") +{ + test_struct test; + auto future = async::make_promise(&test_struct::error_void_string, &test, str).run(); + + REQUIRE_THROWS_MATCHES(future.get(), std::runtime_error, Catch::Matchers::Message(str)); +} + + +TEST_CASE("Make promise class string void", "[initial]") +{ + test_struct test; + auto future = async::make_promise(&test_struct::string_void, &test).run(); + + std::string res; + REQUIRE_NOTHROW(res = future.get()); + REQUIRE(res == str); +} + + +TEST_CASE("Make promise class error string void", "[initial]") +{ + test_struct test; + auto future = async::make_promise(&test_struct::error_string_void, &test).run(); + + REQUIRE_THROWS_MATCHES(future.get(), std::runtime_error, Catch::Matchers::Message(str)); +} + + +TEST_CASE("Make promise class string string", "[initial]") +{ + test_struct test; + auto future = async::make_promise(&test_struct::string_string, &test, str).run(); + + std::string res; + REQUIRE_NOTHROW(res = future.get()); + REQUIRE(res == str); +} + + +TEST_CASE("Make promise class error string string", "[initial]") +{ + test_struct test; + auto future = async::make_promise(&test_struct::error_string_string, &test, str).run(); + + REQUIRE_THROWS_MATCHES(future.get(), std::runtime_error, Catch::Matchers::Message(str)); +} + + +TEST_CASE("Make promise func void void", "[initial]") +{ + auto future = async::make_promise(void_void).run(); + + REQUIRE_NOTHROW(future.get()); +} + + +TEST_CASE("Make promise func error void void", "[initial]") +{ + auto future = async::make_promise(error_void_void).run(); + + REQUIRE_THROWS_MATCHES(future.get(), std::runtime_error, Catch::Matchers::Message(str)); +} + + +TEST_CASE("Make promise func void string", "[initial]") +{ + auto future = async::make_promise(void_string, str).run(); + + REQUIRE_NOTHROW(future.get()); +} + + +TEST_CASE("Make promise func error void string", "[initial]") +{ + auto future = async::make_promise(error_void_string, str).run(); + + REQUIRE_THROWS_MATCHES(future.get(), std::runtime_error, Catch::Matchers::Message(str)); +} + + +TEST_CASE("Make promise func string void", "[initial]") +{ + auto future = async::make_promise(string_void).run(); + + std::string res; + REQUIRE_NOTHROW(res = future.get()); + REQUIRE(res == str); +} + + +TEST_CASE("Make promise func error string void", "[initial]") +{ + auto future = async::make_promise(error_string_void).run(); + + REQUIRE_THROWS_MATCHES(future.get(), std::runtime_error, Catch::Matchers::Message(str)); +} + + +TEST_CASE("Make promise func string string", "[initial]") +{ + auto future = async::make_promise(string_string, str).run(); + + std::string res; + REQUIRE_NOTHROW(res = future.get()); + REQUIRE(res == str); +} + + +TEST_CASE("Make promise func error string string", "[initial]") +{ + auto future = async::make_promise(error_string_string, str).run(); + + REQUIRE_THROWS_MATCHES(future.get(), std::runtime_error, Catch::Matchers::Message(str)); +} diff --git a/tests/src/make_all.cpp b/tests/src/make_promise_all.cpp similarity index 100% rename from tests/src/make_all.cpp rename to tests/src/make_promise_all.cpp diff --git a/tests/src/make_all_settled.cpp b/tests/src/make_promise_all_settled.cpp similarity index 100% rename from tests/src/make_all_settled.cpp rename to tests/src/make_promise_all_settled.cpp diff --git a/tests/src/make_any.cpp b/tests/src/make_promise_any.cpp similarity index 100% rename from tests/src/make_any.cpp rename to tests/src/make_promise_any.cpp diff --git a/tests/src/make_race.cpp b/tests/src/make_promise_race.cpp similarity index 100% rename from tests/src/make_race.cpp rename to tests/src/make_promise_race.cpp diff --git a/tests/src/make_rejected.cpp b/tests/src/make_rejected_promise.cpp similarity index 100% rename from tests/src/make_rejected.cpp rename to tests/src/make_rejected_promise.cpp diff --git a/tests/src/make_resolved.cpp b/tests/src/make_resolved_promise.cpp similarity index 100% rename from tests/src/make_resolved.cpp rename to tests/src/make_resolved_promise.cpp diff --git a/tests/src/class_then.cpp b/tests/src/then.cpp similarity index 52% rename from tests/src/class_then.cpp rename to tests/src/then.cpp index 37da3bc..8bb75a2 100644 --- a/tests/src/class_then.cpp +++ b/tests/src/then.cpp @@ -23,12 +23,13 @@ #include // local +#include "test_funcs.h" #include "test_struct.h" static constexpr auto str = "Hello World!"; -TEST_CASE("Class then void void", "[then]") +TEST_CASE("Then class void void", "[then]") { test_struct test; auto future = async::make_resolved_promise().then(&test_struct::void_void, &test).run(); @@ -37,7 +38,7 @@ TEST_CASE("Class then void void", "[then]") } -TEST_CASE("Class then error void void", "[then]") +TEST_CASE("Then class error void void", "[then]") { test_struct test; auto future = async::make_resolved_promise().then(&test_struct::error_void_void, &test).run(); @@ -46,7 +47,7 @@ TEST_CASE("Class then error void void", "[then]") } -TEST_CASE("Class then void void ignore arg", "[then]") +TEST_CASE("Then class void void ignore arg", "[then]") { test_struct test; auto future = async::make_resolved_promise(str).then(&test_struct::void_void, &test).run(); @@ -55,7 +56,7 @@ TEST_CASE("Class then void void ignore arg", "[then]") } -TEST_CASE("Class then error void void ignore arg", "[then]") +TEST_CASE("Then class error void void ignore arg", "[then]") { test_struct test; auto future = async::make_resolved_promise(str).then(&test_struct::error_void_void, &test).run(); @@ -64,7 +65,7 @@ TEST_CASE("Class then error void void ignore arg", "[then]") } -TEST_CASE("Class then void string", "[then]") +TEST_CASE("Then class void string", "[then]") { test_struct test; auto future = async::make_resolved_promise(str).then(&test_struct::void_string, &test).run(); @@ -73,7 +74,7 @@ TEST_CASE("Class then void string", "[then]") } -TEST_CASE("Class then error void string", "[then]") +TEST_CASE("Then class error void string", "[then]") { test_struct test; auto future = async::make_resolved_promise(str).then(&test_struct::error_void_string, &test).run(); @@ -82,7 +83,7 @@ TEST_CASE("Class then error void string", "[then]") } -TEST_CASE("Class then string void", "[then]") +TEST_CASE("Then class string void", "[then]") { test_struct test; auto future = async::make_resolved_promise().then(&test_struct::string_void, &test).run(); @@ -93,7 +94,7 @@ TEST_CASE("Class then string void", "[then]") } -TEST_CASE("Class then error string void", "[then]") +TEST_CASE("Then class error string void", "[then]") { test_struct test; auto future = async::make_resolved_promise().then(&test_struct::error_string_void, &test).run(); @@ -102,7 +103,7 @@ TEST_CASE("Class then error string void", "[then]") } -TEST_CASE("Class then string void ignore arg", "[then]") +TEST_CASE("Then class string void ignore arg", "[then]") { test_struct test; auto future = async::make_resolved_promise(str).then(&test_struct::string_void, &test).run(); @@ -113,7 +114,7 @@ TEST_CASE("Class then string void ignore arg", "[then]") } -TEST_CASE("Class then error string void ignore arg", "[then]") +TEST_CASE("Then class error string void ignore arg", "[then]") { test_struct test; auto future = async::make_resolved_promise(str).then(&test_struct::error_string_void, &test).run(); @@ -122,7 +123,7 @@ TEST_CASE("Class then error string void ignore arg", "[then]") } -TEST_CASE("Class then string string", "[then]") +TEST_CASE("Then class string string", "[then]") { test_struct test; auto future = async::make_resolved_promise(str).then(&test_struct::string_string, &test).run(); @@ -133,10 +134,112 @@ TEST_CASE("Class then string string", "[then]") } -TEST_CASE("Class then error string string", "[then]") +TEST_CASE("Then class error string string", "[then]") { test_struct test; auto future = async::make_resolved_promise(str).then(&test_struct::error_string_string, &test).run(); REQUIRE_THROWS_MATCHES(future.get(), std::runtime_error, Catch::Matchers::Message(str)); } + + +TEST_CASE("Then func void void", "[then]") +{ + auto future = async::make_resolved_promise().then(void_void).run(); + + REQUIRE_NOTHROW(future.get()); +} + + +TEST_CASE("Then func error void void", "[then]") +{ + auto future = async::make_resolved_promise().then(error_void_void).run(); + + REQUIRE_THROWS_MATCHES(future.get(), std::runtime_error, Catch::Matchers::Message(str)); +} + + +TEST_CASE("Then func void void ignore arg", "[then]") +{ + auto future = async::make_resolved_promise(str).then(void_void).run(); + + REQUIRE_NOTHROW(future.get()); +} + + +TEST_CASE("Then func error void void ignore arg", "[then]") +{ + auto future = async::make_resolved_promise(str).then(error_void_void).run(); + + REQUIRE_THROWS_MATCHES(future.get(), std::runtime_error, Catch::Matchers::Message(str)); +} + + +TEST_CASE("Then func void string", "[then]") +{ + auto future = async::make_resolved_promise(str).then(void_string).run(); + + REQUIRE_NOTHROW(future.get()); +} + + +TEST_CASE("Then func error void string", "[then]") +{ + auto future = async::make_resolved_promise(str).then(error_void_string).run(); + + REQUIRE_THROWS_MATCHES(future.get(), std::runtime_error, Catch::Matchers::Message(str)); +} + + +TEST_CASE("Then func string void", "[then]") +{ + auto future = async::make_resolved_promise().then(string_void).run(); + + std::string res; + REQUIRE_NOTHROW(res = future.get()); + REQUIRE(res == str); +} + + +TEST_CASE("Then func error string void", "[then]") +{ + auto future = async::make_resolved_promise().then(error_string_void).run(); + + REQUIRE_THROWS_MATCHES(future.get(), std::runtime_error, Catch::Matchers::Message(str)); +} + + +TEST_CASE("Then func string void ignore arg", "[then]") +{ + auto future = async::make_resolved_promise(str).then(string_void).run(); + + std::string res; + REQUIRE_NOTHROW(res = future.get()); + REQUIRE(res == str); +} + + +TEST_CASE("Then func error string void ignore arg", "[then]") +{ + auto future = async::make_resolved_promise(str).then(error_string_void).run(); + + REQUIRE_THROWS_MATCHES(future.get(), std::runtime_error, Catch::Matchers::Message(str)); +} + + +TEST_CASE("Then func string string", "[then]") +{ + auto future = async::make_resolved_promise(str).then(string_string).run(); + + std::string res; + REQUIRE_NOTHROW(res = future.get()); + REQUIRE(res == str); +} + + +TEST_CASE("Then func error string string", "[then]") +{ + auto future = async::make_resolved_promise(str).then(error_string_string).run(); + + REQUIRE_THROWS_MATCHES(future.get(), std::runtime_error, Catch::Matchers::Message(str)); +}