1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111
|
//
// registered_buffer.cpp
// ~~~~~~~~~~~~~~~~~~~~~
//
// Copyright (c) 2003-2023 Christopher M. Kohlhoff (chris at kohlhoff dot com)
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
// Disable autolinking for unit tests.
#if !defined(BOOST_ALL_NO_LIB)
#define BOOST_ALL_NO_LIB 1
#endif // !defined(BOOST_ALL_NO_LIB)
// Test that header file is self-contained.
#include <boost/asio/registered_buffer.hpp>
#include "unit_test.hpp"
//------------------------------------------------------------------------------
// registered_buffer_compile test
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// The following test checks that all the mutable_registered_buffer and
// const_registered_buffer classes compile and link correctly. Runtime
// failures are ignored.
namespace registered_buffer_compile {
using namespace boost::asio;
void test()
{
try
{
// mutable_registered_buffer constructors.
mutable_registered_buffer mb1;
mutable_registered_buffer mb2(mb1);
(void)mb2;
// mutable_registered_buffer functions.
mutable_buffer b1 = mb1.buffer();
(void)b1;
void* ptr1 = mb1.data();
(void)ptr1;
std::size_t n1 = mb1.size();
(void)n1;
registered_buffer_id id1 = mb1.id();
(void)id1;
// mutable_registered_buffer operators.
mb1 += 128;
mb1 = mb2 + 128;
mb1 = 128 + mb2;
// const_registered_buffer constructors.
const_registered_buffer cb1;
const_registered_buffer cb2(cb1);
(void)cb2;
const_registered_buffer cb3(mb1);
(void)cb3;
// const_registered_buffer functions.
const_buffer b2 = cb1.buffer();
(void)b2;
const void* ptr2 = cb1.data();
(void)ptr2;
std::size_t n2 = cb1.size();
(void)n2;
registered_buffer_id id2 = cb1.id();
(void)id2;
// const_registered_buffer operators.
cb1 += 128;
cb1 = cb2 + 128;
cb1 = 128 + cb2;
// buffer function overloads.
mb1 = buffer(mb2);
mb1 = buffer(mb2, 128);
cb1 = buffer(cb2);
cb1 = buffer(cb2, 128);
}
catch (std::exception&)
{
}
}
} // namespace buffer_compile
//------------------------------------------------------------------------------
BOOST_ASIO_TEST_SUITE
(
"registered_buffer",
BOOST_ASIO_COMPILE_TEST_CASE(registered_buffer_compile::test)
)
|