]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/asio/test/windows/object_handle.cpp
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / asio / test / windows / object_handle.cpp
1 //
2 // object_handle.cpp
3 // ~~~~~~~~~~~~~~~~~
4 //
5 // Copyright (c) 2003-2016 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_service.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_service ios;
46 archetypes::lazy_handler lazy;
47 boost::system::error_code ec;
48
49 // basic_object_handle constructors.
50
51 win::object_handle handle1(ios);
52 HANDLE native_handle1 = INVALID_HANDLE_VALUE;
53 win::object_handle handle2(ios, 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(ios);
63 handle1 = std::move(handle2);
64 #endif // defined(BOOST_ASIO_HAS_MOVE)
65
66 // basic_io_object functions.
67
68 io_service& ios_ref = handle1.get_io_service();
69 (void)ios_ref;
70
71 // basic_handle functions.
72
73 win::object_handle::lowest_layer_type& lowest_layer
74 = handle1.lowest_layer();
75 (void)lowest_layer;
76
77 const win::object_handle& handle4 = handle1;
78 const win::object_handle::lowest_layer_type& lowest_layer2
79 = handle4.lowest_layer();
80 (void)lowest_layer2;
81
82 HANDLE native_handle2 = INVALID_HANDLE_VALUE;
83 handle1.assign(native_handle2);
84
85 bool is_open = handle1.is_open();
86 (void)is_open;
87
88 handle1.close();
89 handle1.close(ec);
90
91 win::object_handle::native_handle_type native_handle3
92 = handle1.native_handle();
93 (void)native_handle3;
94
95 handle1.cancel();
96 handle1.cancel(ec);
97
98 // basic_object_handle functions.
99
100 handle1.wait();
101 handle1.wait(ec);
102
103 handle1.async_wait(&wait_handler);
104 int i1 = handle1.async_wait(lazy);
105 (void)i1;
106 }
107 catch (std::exception&)
108 {
109 }
110 #endif // defined(BOOST_ASIO_HAS_WINDOWS_OBJECT_HANDLE)
111 }
112
113 } // namespace windows_object_handle_compile
114
115 //------------------------------------------------------------------------------
116
117 BOOST_ASIO_TEST_SUITE
118 (
119 "windows/object_handle",
120 BOOST_ASIO_TEST_CASE(windows_object_handle_compile::test)
121 )