connect_pair.cpp 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. //
  2. // connect_pair.cpp
  3. // ~~~~~~~~~~~~~~~~
  4. //
  5. // Copyright (c) 2003-2019 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. // Disable autolinking for unit tests.
  11. #if !defined(BOOST_ALL_NO_LIB)
  12. #define BOOST_ALL_NO_LIB 1
  13. #endif // !defined(BOOST_ALL_NO_LIB)
  14. // Test that header file is self-contained.
  15. #include <boost/asio/local/connect_pair.hpp>
  16. #include <boost/asio/io_context.hpp>
  17. #include <boost/asio/local/datagram_protocol.hpp>
  18. #include <boost/asio/local/stream_protocol.hpp>
  19. #include "../unit_test.hpp"
  20. //------------------------------------------------------------------------------
  21. // local_connect_pair_compile test
  22. // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  23. // The following test checks that all host_name functions compile and link
  24. // correctly. Runtime failures are ignored.
  25. namespace local_connect_pair_compile {
  26. void test()
  27. {
  28. #if defined(BOOST_ASIO_HAS_LOCAL_SOCKETS)
  29. using namespace boost::asio;
  30. namespace local = boost::asio::local;
  31. typedef local::datagram_protocol dp;
  32. typedef local::stream_protocol sp;
  33. try
  34. {
  35. boost::asio::io_context io_context;
  36. boost::system::error_code ec1;
  37. dp::socket s1(io_context);
  38. dp::socket s2(io_context);
  39. local::connect_pair(s1, s2);
  40. dp::socket s3(io_context);
  41. dp::socket s4(io_context);
  42. local::connect_pair(s3, s4, ec1);
  43. sp::socket s5(io_context);
  44. sp::socket s6(io_context);
  45. local::connect_pair(s5, s6);
  46. sp::socket s7(io_context);
  47. sp::socket s8(io_context);
  48. local::connect_pair(s7, s8, ec1);
  49. }
  50. catch (std::exception&)
  51. {
  52. }
  53. #endif // defined(BOOST_ASIO_HAS_LOCAL_SOCKETS)
  54. }
  55. } // namespace local_connect_pair_compile
  56. //------------------------------------------------------------------------------
  57. BOOST_ASIO_TEST_SUITE
  58. (
  59. "local/connect_pair",
  60. BOOST_ASIO_TEST_CASE(local_connect_pair_compile::test)
  61. )