host_name.cpp 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. //
  2. // host_name.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/ip/host_name.hpp>
  16. #include "../unit_test.hpp"
  17. //------------------------------------------------------------------------------
  18. // ip_host_name_compile test
  19. // ~~~~~~~~~~~~~~~~~~~~~~~~~
  20. // The following test checks that all host_name functions compile and link
  21. // correctly. Runtime failures are ignored.
  22. namespace ip_host_name_compile {
  23. void test()
  24. {
  25. using namespace boost::asio;
  26. namespace ip = boost::asio::ip;
  27. try
  28. {
  29. boost::system::error_code ec;
  30. std::string host_name = ip::host_name();
  31. std::string host_name2 = ip::host_name(ec);
  32. }
  33. catch (std::exception&)
  34. {
  35. }
  36. }
  37. } // namespace ip_host_name_compile
  38. //------------------------------------------------------------------------------
  39. BOOST_ASIO_TEST_SUITE
  40. (
  41. "ip/host_name",
  42. BOOST_ASIO_TEST_CASE(ip_host_name_compile::test)
  43. )