5 // Copyright (c) 2003-2018 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/io_context.hpp>
20 #include "../unit_test.hpp"
22 //------------------------------------------------------------------------------
24 // windows_overlapped_ptr_compile test
25 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
26 // The following test checks that all public member functions on the class
27 // windows::overlapped_ptr compile and link correctly. Runtime failures are
30 namespace windows_overlapped_ptr_compile
{
32 void overlapped_handler_1(const boost::system::error_code
&, std::size_t)
36 struct overlapped_handler_2
38 void operator()(const boost::system::error_code
&, std::size_t)
45 #if defined(BOOST_ASIO_HAS_WINDOWS_OVERLAPPED_PTR)
46 using namespace boost::asio
;
47 namespace win
= boost::asio::windows
;
53 // basic_overlapped_ptr constructors.
55 win::overlapped_ptr ptr1
;
57 win::overlapped_ptr
ptr2(ioc
, &overlapped_handler_1
);
58 win::overlapped_ptr
ptr3(ioc
, overlapped_handler_2());
60 // overlapped_ptr functions.
64 ptr2
.reset(ioc
, &overlapped_handler_1
);
65 ptr3
.reset(ioc
, overlapped_handler_2());
67 OVERLAPPED
* ov1
= ptr1
.get();
70 const win::overlapped_ptr
& ptr4(ptr1
);
71 const OVERLAPPED
* ov2
= ptr4
.get();
74 OVERLAPPED
* ov3
= ptr1
.release();
77 boost::system::error_code ec
;
78 std::size_t bytes_transferred
= 0;
79 ptr1
.complete(ec
, bytes_transferred
);
81 catch (std::exception
&)
84 #endif // defined(BOOST_ASIO_HAS_WINDOWS_OVERLAPPED_PTR)
87 } // namespace windows_overlapped_ptr_compile
89 //------------------------------------------------------------------------------
93 "windows/overlapped_ptr",
94 BOOST_ASIO_TEST_CASE(windows_overlapped_ptr_compile::test
)