]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/asio/test/windows/overlapped_ptr.cpp
update source to Ceph Pacific 16.2.2
[ceph.git] / ceph / src / boost / libs / asio / test / windows / overlapped_ptr.cpp
1 //
2 // overlapped_ptr.cpp
3 // ~~~~~~~~~~~~~~~~~~
4 //
5 // Copyright (c) 2003-2020 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/overlapped_ptr.hpp>
18
19 #include <boost/asio/executor.hpp>
20 #include <boost/asio/io_context.hpp>
21 #include "../unit_test.hpp"
22
23 //------------------------------------------------------------------------------
24
25 // windows_overlapped_ptr_compile test
26 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
27 // The following test checks that all public member functions on the class
28 // windows::overlapped_ptr compile and link correctly. Runtime failures are
29 // ignored.
30
31 namespace windows_overlapped_ptr_compile {
32
33 void overlapped_handler_1(const boost::system::error_code&, std::size_t)
34 {
35 }
36
37 struct overlapped_handler_2
38 {
39 void operator()(const boost::system::error_code&, std::size_t)
40 {
41 }
42 };
43
44 void test()
45 {
46 #if defined(BOOST_ASIO_HAS_WINDOWS_OVERLAPPED_PTR)
47 using namespace boost::asio;
48 namespace win = boost::asio::windows;
49
50 try
51 {
52 io_context ioc;
53 boost::asio::executor ex(ioc.get_executor());
54
55 // basic_overlapped_ptr constructors.
56
57 win::overlapped_ptr ptr1;
58
59 win::overlapped_ptr ptr2(ioc, &overlapped_handler_1);
60 win::overlapped_ptr ptr3(ioc, overlapped_handler_2());
61
62 win::overlapped_ptr ptr4(ioc.get_executor(), &overlapped_handler_1);
63 win::overlapped_ptr ptr5(ioc.get_executor(), overlapped_handler_2());
64 win::overlapped_ptr ptr6(ex, &overlapped_handler_1);
65 win::overlapped_ptr ptr7(ex, overlapped_handler_2());
66
67 // overlapped_ptr functions.
68
69 ptr1.reset();
70
71 ptr2.reset(ioc, &overlapped_handler_1);
72 ptr3.reset(ioc, overlapped_handler_2());
73
74 ptr2.reset(ioc.get_executor(), &overlapped_handler_1);
75 ptr3.reset(ioc.get_executor(), overlapped_handler_2());
76 ptr2.reset(ex, &overlapped_handler_1);
77 ptr3.reset(ex, overlapped_handler_2());
78
79 OVERLAPPED* ov1 = ptr1.get();
80 (void)ov1;
81
82 const win::overlapped_ptr& ptr8(ptr1);
83 const OVERLAPPED* ov2 = ptr4.get();
84 (void)ov2;
85
86 OVERLAPPED* ov3 = ptr1.release();
87 (void)ov3;
88
89 boost::system::error_code ec;
90 std::size_t bytes_transferred = 0;
91 ptr1.complete(ec, bytes_transferred);
92 }
93 catch (std::exception&)
94 {
95 }
96 #endif // defined(BOOST_ASIO_HAS_WINDOWS_OVERLAPPED_PTR)
97 }
98
99 } // namespace windows_overlapped_ptr_compile
100
101 //------------------------------------------------------------------------------
102
103 BOOST_ASIO_TEST_SUITE
104 (
105 "windows/overlapped_ptr",
106 BOOST_ASIO_TEST_CASE(windows_overlapped_ptr_compile::test)
107 )