]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/asio/test/ip/address.cpp
5 // Copyright (c) 2003-2016 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 string_value
= addr1
.to_string(ec
);
74 // address static functions.
76 addr1
= ip::address::from_string("127.0.0.1");
77 addr1
= ip::address::from_string("127.0.0.1", ec
);
78 addr1
= ip::address::from_string(string_value
);
79 addr1
= ip::address::from_string(string_value
, ec
);
81 // address comparisons.
103 std::ostringstream os
;
106 #if !defined(BOOST_NO_STD_WSTREAMBUF)
107 std::wostringstream wos
;
109 #endif // !defined(BOOST_NO_STD_WSTREAMBUF)
111 catch (std::exception
&)
116 } // namespace ip_address_compile
118 //------------------------------------------------------------------------------
120 BOOST_ASIO_TEST_SUITE
123 BOOST_ASIO_TEST_CASE(ip_address_compile::test
)