]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/asio/test/readable_pipe.cpp
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / boost / libs / asio / test / readable_pipe.cpp
CommitLineData
1e59de90
TL
1//
2// readable_pipe.cpp
3// ~~~~~~~~~~~~~~~~~
4//
5// Copyright (c) 2003-2022 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 pipe is self-contained.
17#include <boost/asio/readable_pipe.hpp>
18
19#include "archetypes/async_result.hpp"
20#include <boost/asio/io_context.hpp>
21#include "unit_test.hpp"
22
23// readable_pipe_compile test
24// ~~~~~~~~~~~~~~~~~~~~~~~~~~
25// The following test checks that all public member functions on the class
26// readable_pipe compile and link correctly. Runtime failures are ignored.
27
28namespace readable_pipe_compile {
29
30struct write_some_handler
31{
32 write_some_handler() {}
33 void operator()(const boost::system::error_code&, std::size_t) {}
34#if defined(BOOST_ASIO_HAS_MOVE)
35 write_some_handler(write_some_handler&&) {}
36private:
37 write_some_handler(const write_some_handler&);
38#endif // defined(BOOST_ASIO_HAS_MOVE)
39};
40
41struct read_some_handler
42{
43 read_some_handler() {}
44 void operator()(const boost::system::error_code&, std::size_t) {}
45#if defined(BOOST_ASIO_HAS_MOVE)
46 read_some_handler(read_some_handler&&) {}
47private:
48 read_some_handler(const read_some_handler&);
49#endif // defined(BOOST_ASIO_HAS_MOVE)
50};
51
52void test()
53{
54#if defined(BOOST_ASIO_HAS_PIPE)
55 using namespace boost::asio;
56
57 try
58 {
59 io_context ioc;
60 const io_context::executor_type ioc_ex = ioc.get_executor();
61 char mutable_char_buffer[128] = "";
62 archetypes::lazy_handler lazy;
63 boost::system::error_code ec;
64 const std::string path;
65
66 // basic_readable_pipe constructors.
67
68 readable_pipe pipe1(ioc);
69 readable_pipe::native_handle_type native_pipe1 = pipe1.native_handle();
70 readable_pipe pipe2(ioc, native_pipe1);
71
72 readable_pipe pipe3(ioc_ex);
73 readable_pipe::native_handle_type native_pipe2 = pipe1.native_handle();
74 readable_pipe pipe4(ioc_ex, native_pipe2);
75
76#if defined(BOOST_ASIO_HAS_MOVE)
77 readable_pipe pipe5(std::move(pipe4));
78#endif // defined(BOOST_ASIO_HAS_MOVE)
79
80 // basic_readable_pipe operators.
81
82#if defined(BOOST_ASIO_HAS_MOVE)
83 pipe1 = readable_pipe(ioc);
84 pipe1 = std::move(pipe2);
85#endif // defined(BOOST_ASIO_HAS_MOVE)
86
87 // basic_io_object functions.
88
89 readable_pipe::executor_type ex = pipe1.get_executor();
90 (void)ex;
91
92 // basic_readable_pipe functions.
93
94 readable_pipe::native_handle_type native_pipe3 = pipe1.native_handle();
95 pipe1.assign(native_pipe3);
96 readable_pipe::native_handle_type native_pipe4 = pipe1.native_handle();
97 pipe1.assign(native_pipe4, ec);
98
99 bool is_open = pipe1.is_open();
100 (void)is_open;
101
102 pipe1.close();
103 pipe1.close(ec);
104
105 readable_pipe::native_handle_type native_pipe5 = pipe1.native_handle();
106 (void)native_pipe5;
107
108 pipe1.cancel();
109 pipe1.cancel(ec);
110
111 pipe1.read_some(buffer(mutable_char_buffer));
112 pipe1.read_some(buffer(mutable_char_buffer), ec);
113
114 pipe1.async_read_some(buffer(mutable_char_buffer), read_some_handler());
115 int i3 = pipe1.async_read_some(buffer(mutable_char_buffer), lazy);
116 (void)i3;
117 }
118 catch (std::exception&)
119 {
120 }
121#endif // defined(BOOST_ASIO_HAS_PIPE)
122}
123
124} // namespace readable_pipe_compile
125
126BOOST_ASIO_TEST_SUITE
127(
128 "readable_pipe",
129 BOOST_ASIO_TEST_CASE(readable_pipe_compile::test)
130)