5 // Copyright (c) 2003-2020 Christopher M. Kohlhoff (chris at kohlhoff dot com)
7 // Distributed under the Boost Software License, Version 1.0. (See accompanying
8 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
11 // Disable autolinking for unit tests.
12 #if !defined(BOOST_ALL_NO_LIB)
13 #define BOOST_ALL_NO_LIB 1
14 #endif // !defined(BOOST_ALL_NO_LIB)
16 // Test that header file is self-contained.
17 #include <boost/asio/windows/overlapped_ptr.hpp>
19 #include <boost/asio/executor.hpp>
20 #include <boost/asio/io_context.hpp>
21 #include "../unit_test.hpp"
23 //------------------------------------------------------------------------------
25 // windows_overlapped_ptr_compile test
26 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
27 // The following test checks that all public member functions on the class
28 // windows::overlapped_ptr compile and link correctly. Runtime failures are
31 namespace windows_overlapped_ptr_compile
{
33 void overlapped_handler_1(const boost::system::error_code
&, std::size_t)
37 struct overlapped_handler_2
39 void operator()(const boost::system::error_code
&, std::size_t)
46 #if defined(BOOST_ASIO_HAS_WINDOWS_OVERLAPPED_PTR)
47 using namespace boost::asio
;
48 namespace win
= boost::asio::windows
;
53 boost::asio::executor
ex(ioc
.get_executor());
55 // basic_overlapped_ptr constructors.
57 win::overlapped_ptr ptr1
;
59 win::overlapped_ptr
ptr2(ioc
, &overlapped_handler_1
);
60 win::overlapped_ptr
ptr3(ioc
, overlapped_handler_2());
62 win::overlapped_ptr
ptr4(ioc
.get_executor(), &overlapped_handler_1
);
63 win::overlapped_ptr
ptr5(ioc
.get_executor(), overlapped_handler_2());
64 win::overlapped_ptr
ptr6(ex
, &overlapped_handler_1
);
65 win::overlapped_ptr
ptr7(ex
, overlapped_handler_2());
67 // overlapped_ptr functions.
71 ptr2
.reset(ioc
, &overlapped_handler_1
);
72 ptr3
.reset(ioc
, overlapped_handler_2());
74 ptr2
.reset(ioc
.get_executor(), &overlapped_handler_1
);
75 ptr3
.reset(ioc
.get_executor(), overlapped_handler_2());
76 ptr2
.reset(ex
, &overlapped_handler_1
);
77 ptr3
.reset(ex
, overlapped_handler_2());
79 OVERLAPPED
* ov1
= ptr1
.get();
82 const win::overlapped_ptr
& ptr8(ptr1
);
83 const OVERLAPPED
* ov2
= ptr4
.get();
86 OVERLAPPED
* ov3
= ptr1
.release();
89 boost::system::error_code ec
;
90 std::size_t bytes_transferred
= 0;
91 ptr1
.complete(ec
, bytes_transferred
);
93 catch (std::exception
&)
96 #endif // defined(BOOST_ASIO_HAS_WINDOWS_OVERLAPPED_PTR)
99 } // namespace windows_overlapped_ptr_compile
101 //------------------------------------------------------------------------------
103 BOOST_ASIO_TEST_SUITE
105 "windows/overlapped_ptr",
106 BOOST_ASIO_TEST_CASE(windows_overlapped_ptr_compile::test
)