]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/asio/test/ip/address.cpp
5 // Copyright (c) 2003-2017 Christopher M. Kohlhoff (chris at kohlhoff dot com)
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)
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)
16 // Test that header file is self-contained.
17 #include <boost/asio/ip/address.hpp>
19 #include "../unit_test.hpp"
22 //------------------------------------------------------------------------------
24 // ip_address_compile test
25 // ~~~~~~~~~~~~~~~~~~~~~~~
26 // The following test checks that all public member functions on the class
27 // ip::address compile and link correctly. Runtime failures are ignored.
29 namespace ip_address_compile
{
33 using namespace boost::asio
;
34 namespace ip
= boost::asio::ip
;
38 boost::system::error_code ec
;
40 // address constructors.
43 const ip::address_v4 const_addr_v4
;
44 ip::address
addr2(const_addr_v4
);
45 const ip::address_v6 const_addr_v6
;
46 ip::address
addr3(const_addr_v6
);
50 bool b
= addr1
.is_v4();
56 b
= addr1
.is_loopback();
59 b
= addr1
.is_unspecified();
62 b
= addr1
.is_multicast();
65 ip::address_v4 addr_v4_value
= addr1
.to_v4();
68 ip::address_v6 addr_v6_value
= addr1
.to_v6();
71 std::string string_value
= addr1
.to_string();
72 #if !defined(BOOST_ASIO_NO_DEPRECATED)
73 string_value
= addr1
.to_string(ec
);
74 #endif // !defined(BOOST_ASIO_NO_DEPRECATED)
76 // address static functions.
78 #if !defined(BOOST_ASIO_NO_DEPRECATED)
79 addr1
= ip::address::from_string("127.0.0.1");
80 addr1
= ip::address::from_string("127.0.0.1", ec
);
81 addr1
= ip::address::from_string(string_value
);
82 addr1
= ip::address::from_string(string_value
, ec
);
83 #endif // !defined(BOOST_ASIO_NO_DEPRECATED)
85 // address comparisons.
102 b
= (addr1
>= addr2
);
105 // address creation functions.
107 addr1
= ip::make_address("127.0.0.1");
108 addr1
= ip::make_address("127.0.0.1", ec
);
109 addr1
= ip::make_address(string_value
);
110 addr1
= ip::make_address(string_value
, ec
);
111 #if defined(BOOST_ASIO_HAS_STD_STRING_VIEW)
112 # if defined(BOOST_ASIO_HAS_STD_EXPERIMENTAL_STRING_VIEW)
113 std::experimental::string_view
string_view_value("127.0.0.1");
114 # else // defined(BOOST_ASIO_HAS_STD_EXPERIMENTAL_STRING_VIEW)
115 std::string_view
string_view_value("127.0.0.1");
116 # endif // defined(BOOST_ASIO_HAS_STD_EXPERIMENTAL_STRING_VIEW)
117 addr1
= ip::make_address(string_view_value
);
118 addr1
= ip::make_address(string_view_value
, ec
);
119 #endif // defined(BOOST_ASIO_HAS_STD_STRING_VIEW)
123 std::ostringstream os
;
126 #if !defined(BOOST_NO_STD_WSTREAMBUF)
127 std::wostringstream wos
;
129 #endif // !defined(BOOST_NO_STD_WSTREAMBUF)
131 catch (std::exception
&)
136 } // namespace ip_address_compile
138 //------------------------------------------------------------------------------
140 BOOST_ASIO_TEST_SUITE
143 BOOST_ASIO_TEST_CASE(ip_address_compile::test
)