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