diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-21 11:54:28 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-21 11:54:28 +0000 |
commit | e6918187568dbd01842d8d1d2c808ce16a894239 (patch) | |
tree | 64f88b554b444a49f656b6c656111a145cbbaa28 /src/spawn/test/test_async_result.cc | |
parent | Initial commit. (diff) | |
download | ceph-upstream/18.2.2.tar.xz ceph-upstream/18.2.2.zip |
Adding upstream version 18.2.2.upstream/18.2.2
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/spawn/test/test_async_result.cc')
-rw-r--r-- | src/spawn/test/test_async_result.cc | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/src/spawn/test/test_async_result.cc b/src/spawn/test/test_async_result.cc new file mode 100644 index 000000000..dac734d49 --- /dev/null +++ b/src/spawn/test/test_async_result.cc @@ -0,0 +1,48 @@ +// Copyright (c) 2020 Casey Bodley (cbodley at redhat dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#include <spawn/spawn.hpp> + +// make assertions about async_result::return_type with different signatures +// this is a compilation test only + +template <typename Sig> +struct yield_result : boost::asio::async_result<spawn::yield_context, Sig> {}; + +template <typename T, typename Sig> +struct yield_returns : std::is_same<T, typename yield_result<Sig>::return_type> {}; + +// no return value +static_assert(yield_returns<void, void()>::value, + "wrong return value for void()"); +static_assert(yield_returns<void, void(boost::system::error_code)>::value, + "wrong return value for void(error_code)"); +// single-parameter return value +static_assert(yield_returns<int, void(int)>::value, + "wrong return value for void(int)"); +static_assert(yield_returns<int, void(boost::system::error_code, int)>::value, + "wrong return value for void(error_code, int)"); +// multiple-parameter return value +static_assert(yield_returns<std::tuple<int, std::string>, + void(int, std::string)>::value, + "wrong return value for void(int, string)"); +static_assert(yield_returns<std::tuple<int, std::string>, + void(boost::system::error_code, int, std::string)>::value, + "wrong return value for void(error_code, int, string)"); +// single-tuple-parameter return value +static_assert(yield_returns<std::tuple<int, std::string>, + void(std::tuple<int, std::string>)>::value, + "wrong return value for void(std::tuple<int>)"); +static_assert(yield_returns<std::tuple<int, std::string>, + void(boost::system::error_code, std::tuple<int, std::string>)>::value, + "wrong return value for void(error_code, std::tuple<int>)"); +// single-pair-parameter return value +static_assert(yield_returns<std::pair<int, std::string>, + void(std::pair<int, std::string>)>::value, + "wrong return value for void(std::tuple<int>)"); +static_assert(yield_returns<std::pair<int, std::string>, + void(boost::system::error_code, std::pair<int, std::string>)>::value, + "wrong return value for void(error_code, std::tuple<int>)"); |