summaryrefslogtreecommitdiffstatshomepage
path: root/3rdparty/asio/src/tests/unit/use_future.cpp
diff options
context:
space:
mode:
Diffstat (limited to '3rdparty/asio/src/tests/unit/use_future.cpp')
-rw-r--r--3rdparty/asio/src/tests/unit/use_future.cpp684
1 files changed, 4 insertions, 680 deletions
diff --git a/3rdparty/asio/src/tests/unit/use_future.cpp b/3rdparty/asio/src/tests/unit/use_future.cpp
index bc6e3b859b6..ac12f7caa23 100644
--- a/3rdparty/asio/src/tests/unit/use_future.cpp
+++ b/3rdparty/asio/src/tests/unit/use_future.cpp
@@ -2,7 +2,7 @@
// use_future.cpp
// ~~~~~~~~~~~~~~
//
-// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com)
+// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff 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)
@@ -19,10 +19,9 @@
#include <string>
#include "unit_test.hpp"
-#if defined(ASIO_HAS_STD_FUTURE)
+#if defined(ASIO_HAS_STD_FUTURE_CLASS)
#include "archetypes/async_ops.hpp"
-#include "archetypes/deprecated_async_ops.hpp"
void use_future_0_test()
{
@@ -647,673 +646,6 @@ void use_future_package_3_test()
}
}
-void deprecated_use_future_0_test()
-{
-#if !defined(ASIO_NO_DEPRECATED)
- using asio::use_future;
- using namespace archetypes;
-
- std::future<void> f;
- asio::io_context ctx;
-
- f = deprecated_async_op_0(ctx, use_future);
- ctx.restart();
- ctx.run();
- try
- {
- f.get();
- }
- catch (...)
- {
- ASIO_CHECK(false);
- }
-
- f = deprecated_async_op_ec_0(ctx, true, use_future);
- ctx.restart();
- ctx.run();
- try
- {
- f.get();
- }
- catch (...)
- {
- ASIO_CHECK(false);
- }
-
- f = deprecated_async_op_ec_0(ctx, false, use_future);
- ctx.restart();
- ctx.run();
- try
- {
- f.get();
- ASIO_CHECK(false);
- }
- catch (asio::system_error& e)
- {
- ASIO_CHECK(e.code() == asio::error::operation_aborted);
- }
- catch (...)
- {
- ASIO_CHECK(false);
- }
-
- f = async_op_ex_0(true, use_future);
- ctx.restart();
- ctx.run();
- try
- {
- f.get();
- }
- catch (...)
- {
- ASIO_CHECK(false);
- }
-
- f = async_op_ex_0(false, use_future);
- ctx.restart();
- ctx.run();
- try
- {
- f.get();
- ASIO_CHECK(false);
- }
- catch (std::exception& e)
- {
- ASIO_CHECK(e.what() == std::string("blah"));
- }
- catch (...)
- {
- ASIO_CHECK(false);
- }
-#endif // !defined(ASIO_NO_DEPRECATED)
-}
-
-void deprecated_use_future_1_test()
-{
-#if !defined(ASIO_NO_DEPRECATED)
- using asio::use_future;
- using namespace archetypes;
-
- std::future<int> f;
- asio::io_context ctx;
-
- f = deprecated_async_op_1(ctx, use_future);
- ctx.restart();
- ctx.run();
- try
- {
- int i = f.get();
- ASIO_CHECK(i == 42);
- }
- catch (...)
- {
- ASIO_CHECK(false);
- }
-
- f = deprecated_async_op_ec_1(ctx, true, use_future);
- ctx.restart();
- ctx.run();
- try
- {
- int i = f.get();
- ASIO_CHECK(i == 42);
- }
- catch (...)
- {
- ASIO_CHECK(false);
- }
-
- f = deprecated_async_op_ec_1(ctx, false, use_future);
- ctx.restart();
- ctx.run();
- try
- {
- int i = f.get();
- ASIO_CHECK(false);
- (void)i;
- }
- catch (asio::system_error& e)
- {
- ASIO_CHECK(e.code() == asio::error::operation_aborted);
- }
- catch (...)
- {
- ASIO_CHECK(false);
- }
-
- f = deprecated_async_op_ex_1(ctx, true, use_future);
- ctx.restart();
- ctx.run();
- try
- {
- int i = f.get();
- ASIO_CHECK(i == 42);
- }
- catch (...)
- {
- ASIO_CHECK(false);
- }
-
- f = deprecated_async_op_ex_1(ctx, false, use_future);
- ctx.restart();
- ctx.run();
- try
- {
- int i = f.get();
- ASIO_CHECK(false);
- (void)i;
- }
- catch (std::exception& e)
- {
- ASIO_CHECK(e.what() == std::string("blah"));
- }
- catch (...)
- {
- ASIO_CHECK(false);
- }
-#endif // !defined(ASIO_NO_DEPRECATED)
-}
-
-void deprecated_use_future_2_test()
-{
-#if !defined(ASIO_NO_DEPRECATED)
- using asio::use_future;
- using namespace archetypes;
-
- std::future<std::tuple<int, double>> f;
- asio::io_context ctx;
-
- f = deprecated_async_op_2(ctx, use_future);
- ctx.restart();
- ctx.run();
- try
- {
- int i;
- double d;
- std::tie(i, d) = f.get();
- ASIO_CHECK(i == 42);
- ASIO_CHECK(d == 2.0);
- }
- catch (...)
- {
- ASIO_CHECK(false);
- }
-
- f = deprecated_async_op_ec_2(ctx, true, use_future);
- ctx.restart();
- ctx.run();
- try
- {
- int i;
- double d;
- std::tie(i, d) = f.get();
- ASIO_CHECK(i == 42);
- ASIO_CHECK(d == 2.0);
- }
- catch (...)
- {
- ASIO_CHECK(false);
- }
-
- f = deprecated_async_op_ec_2(ctx, false, use_future);
- ctx.restart();
- ctx.run();
- try
- {
- std::tuple<int, double> t = f.get();
- ASIO_CHECK(false);
- (void)t;
- }
- catch (asio::system_error& e)
- {
- ASIO_CHECK(e.code() == asio::error::operation_aborted);
- }
- catch (...)
- {
- ASIO_CHECK(false);
- }
-
- f = deprecated_async_op_ex_2(ctx, true, use_future);
- ctx.restart();
- ctx.run();
- try
- {
- int i;
- double d;
- std::tie(i, d) = f.get();
- ASIO_CHECK(i == 42);
- ASIO_CHECK(d == 2.0);
- }
- catch (...)
- {
- ASIO_CHECK(false);
- }
-
- f = deprecated_async_op_ex_2(ctx, false, use_future);
- ctx.restart();
- ctx.run();
- try
- {
- std::tuple<int, double> t = f.get();
- ASIO_CHECK(false);
- (void)t;
- }
- catch (std::exception& e)
- {
- ASIO_CHECK(e.what() == std::string("blah"));
- }
- catch (...)
- {
- ASIO_CHECK(false);
- }
-#endif // !defined(ASIO_NO_DEPRECATED)
-}
-
-void deprecated_use_future_3_test()
-{
-#if !defined(ASIO_NO_DEPRECATED)
- using asio::use_future;
- using namespace archetypes;
-
- std::future<std::tuple<int, double, char>> f;
- asio::io_context ctx;
-
- f = deprecated_async_op_3(ctx, use_future);
- ctx.restart();
- ctx.run();
- try
- {
- int i;
- double d;
- char c;
- std::tie(i, d, c) = f.get();
- ASIO_CHECK(i == 42);
- ASIO_CHECK(d == 2.0);
- ASIO_CHECK(c == 'a');
- }
- catch (...)
- {
- ASIO_CHECK(false);
- }
-
- f = deprecated_async_op_ec_3(ctx, true, use_future);
- ctx.restart();
- ctx.run();
- try
- {
- int i;
- double d;
- char c;
- std::tie(i, d, c) = f.get();
- ASIO_CHECK(i == 42);
- ASIO_CHECK(d == 2.0);
- ASIO_CHECK(c == 'a');
- }
- catch (...)
- {
- ASIO_CHECK(false);
- }
-
- f = deprecated_async_op_ec_3(ctx, false, use_future);
- ctx.restart();
- ctx.run();
- try
- {
- std::tuple<int, double, char> t = f.get();
- ASIO_CHECK(false);
- (void)t;
- }
- catch (asio::system_error& e)
- {
- ASIO_CHECK(e.code() == asio::error::operation_aborted);
- }
- catch (...)
- {
- ASIO_CHECK(false);
- }
-
- f = deprecated_async_op_ex_3(ctx, true, use_future);
- ctx.restart();
- ctx.run();
- try
- {
- int i;
- double d;
- char c;
- std::tie(i, d, c) = f.get();
- ASIO_CHECK(i == 42);
- ASIO_CHECK(d == 2.0);
- ASIO_CHECK(c == 'a');
- }
- catch (...)
- {
- ASIO_CHECK(false);
- }
-
- f = deprecated_async_op_ex_3(ctx, false, use_future);
- ctx.restart();
- ctx.run();
- try
- {
- std::tuple<int, double, char> t = f.get();
- ASIO_CHECK(false);
- (void)t;
- }
- catch (std::exception& e)
- {
- ASIO_CHECK(e.what() == std::string("blah"));
- }
- catch (...)
- {
- ASIO_CHECK(false);
- }
-#endif // !defined(ASIO_NO_DEPRECATED)
-}
-
-void deprecated_use_future_package_0_test()
-{
-#if !defined(ASIO_NO_DEPRECATED)
- using asio::use_future;
- using namespace archetypes;
-
- std::future<int> f;
- asio::io_context ctx;
-
- f = deprecated_async_op_0(ctx, use_future(package_0));
- ctx.restart();
- ctx.run();
- try
- {
- int i = f.get();
- ASIO_CHECK(i == 42);
- }
- catch (...)
- {
- ASIO_CHECK(false);
- }
-
- f = deprecated_async_op_ec_0(ctx, true, use_future(&package_ec_0));
- ctx.restart();
- ctx.run();
- try
- {
- int i = f.get();
- ASIO_CHECK(i == 42);
- }
- catch (...)
- {
- ASIO_CHECK(false);
- }
-
- f = deprecated_async_op_ec_0(ctx, false, use_future(package_ec_0));
- ctx.restart();
- ctx.run();
- try
- {
- int i = f.get();
- ASIO_CHECK(i == 0);
- }
- catch (...)
- {
- ASIO_CHECK(false);
- }
-
- f = deprecated_async_op_ex_0(ctx, true, use_future(package_ex_0));
- ctx.restart();
- ctx.run();
- try
- {
- int i = f.get();
- ASIO_CHECK(i == 42);
- }
- catch (...)
- {
- ASIO_CHECK(false);
- }
-
- f = deprecated_async_op_ex_0(ctx, false, use_future(package_ex_0));
- ctx.restart();
- ctx.run();
- try
- {
- int i = f.get();
- ASIO_CHECK(i == 0);
- }
- catch (...)
- {
- ASIO_CHECK(false);
- }
-#endif // !defined(ASIO_NO_DEPRECATED)
-}
-
-void deprecated_use_future_package_1_test()
-{
-#if !defined(ASIO_NO_DEPRECATED)
- using asio::use_future;
- using namespace archetypes;
-
- std::future<int> f;
- asio::io_context ctx;
-
- f = deprecated_async_op_1(ctx, use_future(package_1));
- ctx.restart();
- ctx.run();
- try
- {
- int i = f.get();
- ASIO_CHECK(i == 42);
- }
- catch (...)
- {
- ASIO_CHECK(false);
- }
-
- f = deprecated_async_op_ec_1(ctx, true, use_future(package_ec_1));
- ctx.restart();
- ctx.run();
- try
- {
- int i = f.get();
- ASIO_CHECK(i == 42);
- }
- catch (...)
- {
- ASIO_CHECK(false);
- }
-
- f = deprecated_async_op_ec_1(ctx, false, use_future(package_ec_1));
- ctx.restart();
- ctx.run();
- try
- {
- int i = f.get();
- ASIO_CHECK(i == 0);
- }
- catch (...)
- {
- ASIO_CHECK(false);
- }
-
- f = deprecated_async_op_ex_1(ctx, true, use_future(package_ex_1));
- ctx.restart();
- ctx.run();
- try
- {
- int i = f.get();
- ASIO_CHECK(i == 42);
- }
- catch (...)
- {
- ASIO_CHECK(false);
- }
-
- f = deprecated_async_op_ex_1(ctx, false, use_future(package_ex_1));
- ctx.restart();
- ctx.run();
- try
- {
- int i = f.get();
- ASIO_CHECK(i == 0);
- }
- catch (...)
- {
- ASIO_CHECK(false);
- }
-#endif // !defined(ASIO_NO_DEPRECATED)
-}
-
-void deprecated_use_future_package_2_test()
-{
-#if !defined(ASIO_NO_DEPRECATED)
- using asio::use_future;
- using namespace archetypes;
-
- std::future<int> f;
- asio::io_context ctx;
-
- f = deprecated_async_op_2(ctx, use_future(package_2));
- ctx.restart();
- ctx.run();
- try
- {
- int i = f.get();
- ASIO_CHECK(i == 42);
- }
- catch (...)
- {
- ASIO_CHECK(false);
- }
-
- f = deprecated_async_op_ec_2(ctx, true, use_future(package_ec_2));
- ctx.restart();
- ctx.run();
- try
- {
- int i = f.get();
- ASIO_CHECK(i == 42);
- }
- catch (...)
- {
- ASIO_CHECK(false);
- }
-
- f = deprecated_async_op_ec_2(ctx, false, use_future(package_ec_2));
- ctx.restart();
- ctx.run();
- try
- {
- int i = f.get();
- ASIO_CHECK(i == 0);
- }
- catch (...)
- {
- ASIO_CHECK(false);
- }
-
- f = deprecated_async_op_ex_2(ctx, true, use_future(package_ex_2));
- ctx.restart();
- ctx.run();
- try
- {
- int i = f.get();
- ASIO_CHECK(i == 42);
- }
- catch (...)
- {
- ASIO_CHECK(false);
- }
-
- f = deprecated_async_op_ex_2(ctx, false, use_future(package_ex_2));
- ctx.restart();
- ctx.run();
- try
- {
- int i = f.get();
- ASIO_CHECK(i == 0);
- }
- catch (...)
- {
- ASIO_CHECK(false);
- }
-#endif // !defined(ASIO_NO_DEPRECATED)
-}
-
-void deprecated_use_future_package_3_test()
-{
-#if !defined(ASIO_NO_DEPRECATED)
- using asio::use_future;
- using namespace archetypes;
-
- std::future<int> f;
- asio::io_context ctx;
-
- f = deprecated_async_op_3(ctx, use_future(package_3));
- ctx.restart();
- ctx.run();
- try
- {
- int i = f.get();
- ASIO_CHECK(i == 42);
- }
- catch (...)
- {
- ASIO_CHECK(false);
- }
-
- f = deprecated_async_op_ec_3(ctx, true, use_future(package_ec_3));
- ctx.restart();
- ctx.run();
- try
- {
- int i = f.get();
- ASIO_CHECK(i == 42);
- }
- catch (...)
- {
- ASIO_CHECK(false);
- }
-
- f = deprecated_async_op_ec_3(ctx, false, use_future(package_ec_3));
- ctx.restart();
- ctx.run();
- try
- {
- int i = f.get();
- ASIO_CHECK(i == 0);
- }
- catch (...)
- {
- ASIO_CHECK(false);
- }
-
- f = deprecated_async_op_ex_3(ctx, true, use_future(package_ex_3));
- ctx.restart();
- ctx.run();
- try
- {
- int i = f.get();
- ASIO_CHECK(i == 42);
- }
- catch (...)
- {
- ASIO_CHECK(false);
- }
-
- f = deprecated_async_op_ex_3(ctx, false, use_future(package_ex_3));
- ctx.restart();
- ctx.run();
- try
- {
- int i = f.get();
- ASIO_CHECK(i == 0);
- }
- catch (...)
- {
- ASIO_CHECK(false);
- }
-#endif // !defined(ASIO_NO_DEPRECATED)
-}
-
ASIO_TEST_SUITE
(
"use_future",
@@ -1325,17 +657,9 @@ ASIO_TEST_SUITE
ASIO_TEST_CASE(use_future_package_1_test)
ASIO_TEST_CASE(use_future_package_2_test)
ASIO_TEST_CASE(use_future_package_3_test)
- ASIO_TEST_CASE(deprecated_use_future_0_test)
- ASIO_TEST_CASE(deprecated_use_future_1_test)
- ASIO_TEST_CASE(deprecated_use_future_2_test)
- ASIO_TEST_CASE(deprecated_use_future_3_test)
- ASIO_TEST_CASE(deprecated_use_future_package_0_test)
- ASIO_TEST_CASE(deprecated_use_future_package_1_test)
- ASIO_TEST_CASE(deprecated_use_future_package_2_test)
- ASIO_TEST_CASE(deprecated_use_future_package_3_test)
)
-#else // defined(ASIO_HAS_STD_FUTURE)
+#else // defined(ASIO_HAS_STD_FUTURE_CLASS)
ASIO_TEST_SUITE
(
@@ -1343,4 +667,4 @@ ASIO_TEST_SUITE
ASIO_TEST_CASE(null_test)
)
-#endif // defined(ASIO_HAS_STD_FUTURE)
+#endif // defined(ASIO_HAS_STD_FUTURE_CLASS)