]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/log/test/run/attr_attribute_set_ticket11106.cpp
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / log / test / run / attr_attribute_set_ticket11106.cpp
1 /*
2 * Copyright Andrey Semashev 2007 - 2015.
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 attr_attribute_set_ticket11106.cpp
9 * \author Andrey Semashev
10 * \date 15.03.2015
11 *
12 * \brief This header contains a test for the fix for https://svn.boost.org/trac/boost/ticket/11106.
13 */
14
15 #define BOOST_TEST_MODULE attr_attribute_set_ticket11106
16
17 #include <string>
18 #include <sstream>
19 #include <utility>
20 #include <boost/test/unit_test.hpp>
21 #include <boost/log/attributes/constant.hpp>
22 #include <boost/log/attributes/attribute_set.hpp>
23
24 // The test checks that insertion does not invalidate existing elements in the container
25 BOOST_AUTO_TEST_CASE(ticket11106)
26 {
27 boost::log::attribute_set set;
28
29 unsigned int i = 0;
30 while (i < 100)
31 {
32 std::ostringstream strm;
33 strm << "Attr" << i;
34 boost::log::attribute_name name = strm.str();
35
36 std::pair< boost::log::attribute_set::iterator, bool > res = set.insert(name, boost::log::attributes::make_constant(5));
37 ++i;
38
39 BOOST_CHECK(res.second); // check that insertion succeeded
40 BOOST_CHECK(set.find(res.first->first) != set.end()); // check that lookup works
41
42 // Now check that all previously inserted elements are still findable
43 unsigned int j = 0;
44 for (boost::log::attribute_set::const_iterator it = set.begin(), end = set.end(); it != end; ++it, ++j)
45 {
46 boost::log::attribute_name key = it->first;
47 BOOST_CHECK(set.find(key) != set.end());
48 }
49 BOOST_CHECK_EQUAL(j, i);
50 }
51 }