• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //
2 // connect_pair.cpp
3 // ~~~~~~~~~~~~~~~~
4 //
5 // Copyright (c) 2003-2021 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/local/connect_pair.hpp>
18 
19 #include <boost/asio/io_context.hpp>
20 #include <boost/asio/local/datagram_protocol.hpp>
21 #include <boost/asio/local/stream_protocol.hpp>
22 #include "../unit_test.hpp"
23 
24 //------------------------------------------------------------------------------
25 
26 // local_connect_pair_compile test
27 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
28 // The following test checks that all host_name functions compile and link
29 // correctly. Runtime failures are ignored.
30 
31 namespace local_connect_pair_compile {
32 
test()33 void test()
34 {
35 #if defined(BOOST_ASIO_HAS_LOCAL_SOCKETS)
36   using namespace boost::asio;
37   namespace local = boost::asio::local;
38   typedef local::datagram_protocol dp;
39   typedef local::stream_protocol sp;
40 
41   try
42   {
43     boost::asio::io_context io_context;
44     boost::system::error_code ec1;
45 
46     dp::socket s1(io_context);
47     dp::socket s2(io_context);
48     local::connect_pair(s1, s2);
49 
50     dp::socket s3(io_context);
51     dp::socket s4(io_context);
52     local::connect_pair(s3, s4, ec1);
53 
54     sp::socket s5(io_context);
55     sp::socket s6(io_context);
56     local::connect_pair(s5, s6);
57 
58     sp::socket s7(io_context);
59     sp::socket s8(io_context);
60     local::connect_pair(s7, s8, ec1);
61   }
62   catch (std::exception&)
63   {
64   }
65 #endif // defined(BOOST_ASIO_HAS_LOCAL_SOCKETS)
66 }
67 
68 } // namespace local_connect_pair_compile
69 
70 //------------------------------------------------------------------------------
71 
72 BOOST_ASIO_TEST_SUITE
73 (
74   "local/connect_pair",
75   BOOST_ASIO_TEST_CASE(local_connect_pair_compile::test)
76 )
77