]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/lockfree/test/tagged_ptr_test.cpp
1 // Copyright (C) 2011 Tim Blechmann
3 // Distributed under the Boost Software License, Version 1.0. (See
4 // accompanying file LICENSE_1_0.txt or copy at
5 // http://www.boost.org/LICENSE_1_0.txt)
9 #include <boost/lockfree/detail/tagged_ptr.hpp>
11 #define BOOST_TEST_MAIN
12 #ifdef BOOST_LOCKFREE_INCLUDE_TESTS
13 #include <boost/test/included/unit_test.hpp>
15 #include <boost/test/unit_test.hpp>
18 BOOST_AUTO_TEST_CASE( tagged_ptr_test
)
20 using namespace boost::lockfree::detail
;
23 typedef tagged_ptr
<int>::tag_t tag_t
;
24 const tag_t max_tag
= (std::numeric_limits
<tag_t
>::max
)();
27 tagged_ptr
<int> i (&a
, 0);
28 tagged_ptr
<int> j (&b
, 1);
32 BOOST_REQUIRE_EQUAL(i
.get_ptr(), &b
);
33 BOOST_REQUIRE_EQUAL(i
.get_tag(), 1);
37 tagged_ptr
<int> i (&a
, 0);
38 tagged_ptr
<int> j (i
);
40 BOOST_REQUIRE_EQUAL(i
.get_ptr(), j
.get_ptr());
41 BOOST_REQUIRE_EQUAL(i
.get_tag(), j
.get_tag());
45 tagged_ptr
<int> i (&a
, 0);
46 BOOST_REQUIRE_EQUAL(i
.get_tag() + 1, i
.get_next_tag());
50 tagged_ptr
<int> j (&a
, max_tag
);
51 BOOST_REQUIRE_EQUAL(j
.get_next_tag(), 0);
55 tagged_ptr
<int> j (&a
, max_tag
- 1);
56 BOOST_REQUIRE_EQUAL(j
.get_next_tag(), max_tag
);