]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/log/test/run/src_channel_logger_copy.cpp
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / boost / libs / log / test / run / src_channel_logger_copy.cpp
CommitLineData
1e59de90
TL
1/*
2 * Copyright Andrey Semashev 2021.
3 * Distributed under the Boost Software License, Version 1.0.
4 * (See accompanying file LICENSE_1_0.txt or copy at
5 * http://www.boost.org/LICENSE_1_0.txt)
6 */
7/*!
8 * \file src_channel_logger_copy.cpp
9 * \author Andrey Semashev
10 * \date 10.02.2021
11 *
12 * \brief This header contains tests for the channel logger copy constructor and assignment.
13 */
14
15#define BOOST_TEST_MODULE src_channel_logger_copy
16
17#include <string>
18#include <boost/test/unit_test.hpp>
19#include <boost/log/sources/channel_logger.hpp>
20
21namespace src = boost::log::sources;
22
23// Test that copy constructor decouples the channel attribute
24BOOST_AUTO_TEST_CASE(copy_constructor)
25{
26 src::channel_logger< std::string > lg1("channel1");
27 src::channel_logger< std::string > lg2 = lg1;
28 BOOST_CHECK_EQUAL(lg1.channel(), lg2.channel());
29
30 lg2.channel("channel2");
31 BOOST_CHECK_NE(lg1.channel(), lg2.channel());
32}
33
34// Test that copy assignment decouples the channel attribute
35BOOST_AUTO_TEST_CASE(copy_assignment)
36{
37 src::channel_logger< std::string > lg1("channel1");
38 src::channel_logger< std::string > lg2("channel2");
39 BOOST_CHECK_NE(lg1.channel(), lg2.channel());
40
41 lg2 = lg1;
42 BOOST_CHECK_EQUAL(lg1.channel(), lg2.channel());
43
44 lg2.channel("channel3");
45 BOOST_CHECK_NE(lg1.channel(), lg2.channel());
46}