5 // Copyright (c) 2003-2016 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_service.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(ios
);
52 HANDLE native_handle1
= INVALID_HANDLE_VALUE
;
53 win::object_handle
handle2(ios
, 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(ios
);
63 handle1
= std::move(handle2
);
64 #endif // defined(BOOST_ASIO_HAS_MOVE)
66 // basic_io_object functions.
68 io_service
& ios_ref
= handle1
.get_io_service();
71 // basic_handle functions.
73 win::object_handle::lowest_layer_type
& lowest_layer
74 = handle1
.lowest_layer();
77 const win::object_handle
& handle4
= handle1
;
78 const win::object_handle::lowest_layer_type
& lowest_layer2
79 = handle4
.lowest_layer();
82 HANDLE native_handle2
= INVALID_HANDLE_VALUE
;
83 handle1
.assign(native_handle2
);
85 bool is_open
= handle1
.is_open();
91 win::object_handle::native_handle_type native_handle3
92 = handle1
.native_handle();
98 // basic_object_handle functions.
103 handle1
.async_wait(&wait_handler
);
104 int i1
= handle1
.async_wait(lazy
);
107 catch (std::exception
&)
110 #endif // defined(BOOST_ASIO_HAS_WINDOWS_OBJECT_HANDLE)
113 } // namespace windows_object_handle_compile
115 //------------------------------------------------------------------------------
117 BOOST_ASIO_TEST_SUITE
119 "windows/object_handle",
120 BOOST_ASIO_TEST_CASE(windows_object_handle_compile::test
)