diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 18:45:59 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 18:45:59 +0000 |
commit | 19fcec84d8d7d21e796c7624e521b60d28ee21ed (patch) | |
tree | 42d26aa27d1e3f7c0b8bd3fd14e7d7082f5008dc /src/spawn/test/test_async_result.cc | |
parent | Initial commit. (diff) | |
download | ceph-upstream.tar.xz ceph-upstream.zip |
Adding upstream version 16.2.11+ds.upstream/16.2.11+dsupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-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>)"); |