5 // Copyright (c) 2003-2017 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/object_handle.hpp>
19 #include <boost/asio/io_context.hpp>
20 #include "../archetypes/async_result.hpp"
21 #include "../unit_test.hpp"
23 //------------------------------------------------------------------------------
25 // windows_object_handle_compile test
26 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
27 // The following test checks that all public member functions on the class
28 // windows::object_handle compile and link correctly. Runtime failures are
31 namespace windows_object_handle_compile
{
33 void wait_handler(const boost::system::error_code
&)
39 #if defined(BOOST_ASIO_HAS_WINDOWS_OBJECT_HANDLE)
40 using namespace boost::asio
;
41 namespace win
= boost::asio::windows
;
46 archetypes::lazy_handler lazy
;
47 boost::system::error_code ec
;
49 // basic_object_handle constructors.
51 win::object_handle
handle1(ioc
);
52 HANDLE native_handle1
= INVALID_HANDLE_VALUE
;
53 win::object_handle
handle2(ioc
, native_handle1
);
55 #if defined(BOOST_ASIO_HAS_MOVE)
56 win::object_handle
handle3(std::move(handle2
));
57 #endif // defined(BOOST_ASIO_HAS_MOVE)
59 // basic_object_handle operators.
61 #if defined(BOOST_ASIO_HAS_MOVE)
62 handle1
= win::object_handle(ioc
);
63 handle1
= std::move(handle2
);
64 #endif // defined(BOOST_ASIO_HAS_MOVE)
66 // basic_io_object functions.
68 #if !defined(BOOST_ASIO_NO_DEPRECATED)
69 io_context
& ioc_ref
= handle1
.get_io_context();
71 #endif // !defined(BOOST_ASIO_NO_DEPRECATED)
73 io_context::executor_type ex
= handle1
.get_executor();
76 // basic_handle functions.
78 win::object_handle::lowest_layer_type
& lowest_layer
79 = handle1
.lowest_layer();
82 const win::object_handle
& handle4
= handle1
;
83 const win::object_handle::lowest_layer_type
& lowest_layer2
84 = handle4
.lowest_layer();
87 HANDLE native_handle2
= INVALID_HANDLE_VALUE
;
88 handle1
.assign(native_handle2
);
90 bool is_open
= handle1
.is_open();
96 win::object_handle::native_handle_type native_handle3
97 = handle1
.native_handle();
103 // basic_object_handle functions.
108 handle1
.async_wait(&wait_handler
);
109 int i1
= handle1
.async_wait(lazy
);
112 catch (std::exception
&)
115 #endif // defined(BOOST_ASIO_HAS_WINDOWS_OBJECT_HANDLE)
118 } // namespace windows_object_handle_compile
120 //------------------------------------------------------------------------------
122 BOOST_ASIO_TEST_SUITE
124 "windows/object_handle",
125 BOOST_ASIO_TEST_CASE(windows_object_handle_compile::test
)