]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/asio/test/windows/object_handle.cpp
update sources to v12.2.3
[ceph.git] / ceph / src / boost / libs / asio / test / windows / object_handle.cpp
1 //
2 // object_handle.cpp
3 // ~~~~~~~~~~~~~~~~~
4 //
5 // Copyright (c) 2003-2017 Christopher M. Kohlhoff (chris at kohlhoff dot com)
6 //
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)
9 //
10
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)
15
16 // Test that header file is self-contained.
17 #include <boost/asio/windows/object_handle.hpp>
18
19 #include <boost/asio/io_context.hpp>
20 #include "../archetypes/async_result.hpp"
21 #include "../unit_test.hpp"
22
23 //------------------------------------------------------------------------------
24
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
29 // ignored.
30
31 namespace windows_object_handle_compile {
32
33 void wait_handler(const boost::system::error_code&)
34 {
35 }
36
37 void test()
38 {
39 #if defined(BOOST_ASIO_HAS_WINDOWS_OBJECT_HANDLE)
40 using namespace boost::asio;
41 namespace win = boost::asio::windows;
42
43 try
44 {
45 io_context ioc;
46 archetypes::lazy_handler lazy;
47 boost::system::error_code ec;
48
49 // basic_object_handle constructors.
50
51 win::object_handle handle1(ioc);
52 HANDLE native_handle1 = INVALID_HANDLE_VALUE;
53 win::object_handle handle2(ioc, native_handle1);
54
55 #if defined(BOOST_ASIO_HAS_MOVE)
56 win::object_handle handle3(std::move(handle2));
57 #endif // defined(BOOST_ASIO_HAS_MOVE)
58
59 // basic_object_handle operators.
60
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)
65
66 // basic_io_object functions.
67
68 #if !defined(BOOST_ASIO_NO_DEPRECATED)
69 io_context& ioc_ref = handle1.get_io_context();
70 (void)ioc_ref;
71 #endif // !defined(BOOST_ASIO_NO_DEPRECATED)
72
73 io_context::executor_type ex = handle1.get_executor();
74 (void)ex;
75
76 // basic_handle functions.
77
78 win::object_handle::lowest_layer_type& lowest_layer
79 = handle1.lowest_layer();
80 (void)lowest_layer;
81
82 const win::object_handle& handle4 = handle1;
83 const win::object_handle::lowest_layer_type& lowest_layer2
84 = handle4.lowest_layer();
85 (void)lowest_layer2;
86
87 HANDLE native_handle2 = INVALID_HANDLE_VALUE;
88 handle1.assign(native_handle2);
89
90 bool is_open = handle1.is_open();
91 (void)is_open;
92
93 handle1.close();
94 handle1.close(ec);
95
96 win::object_handle::native_handle_type native_handle3
97 = handle1.native_handle();
98 (void)native_handle3;
99
100 handle1.cancel();
101 handle1.cancel(ec);
102
103 // basic_object_handle functions.
104
105 handle1.wait();
106 handle1.wait(ec);
107
108 handle1.async_wait(&wait_handler);
109 int i1 = handle1.async_wait(lazy);
110 (void)i1;
111 }
112 catch (std::exception&)
113 {
114 }
115 #endif // defined(BOOST_ASIO_HAS_WINDOWS_OBJECT_HANDLE)
116 }
117
118 } // namespace windows_object_handle_compile
119
120 //------------------------------------------------------------------------------
121
122 BOOST_ASIO_TEST_SUITE
123 (
124 "windows/object_handle",
125 BOOST_ASIO_TEST_CASE(windows_object_handle_compile::test)
126 )