]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/functional/hash/test/hash_std_smart_ptr_test.cpp
2 // Copyright 2012 Daniel James.
3 // Distributed under the Boost Software License, Version 1.0. (See accompanying
4 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6 #include "./config.hpp"
8 #ifdef BOOST_HASH_TEST_STD_INCLUDES
11 # include <boost/functional/hash.hpp>
14 #include <boost/detail/lightweight_test.hpp>
15 #include "./compile_time.hpp"
17 #if defined(BOOST_HASH_TEST_EXTENSIONS) && !defined(BOOST_NO_CXX11_SMART_PTR)
18 #define TEST_SMART_PTRS
22 #ifdef TEST_SMART_PTRS
24 void shared_ptr_tests()
26 std::shared_ptr
<int> x
;
27 compile_time_tests(&x
);
29 BOOST_HASH_TEST_NAMESPACE::hash
<std::shared_ptr
<int> > x1
;
30 BOOST_HASH_TEST_NAMESPACE::hash
<std::shared_ptr
<int> > x2
;
32 std::shared_ptr
<int> ptr1(new int(10));
33 std::shared_ptr
<int> ptr2
;
35 BOOST_TEST(x1(x
) == x2(ptr2
));
36 BOOST_TEST(x1(x
) != x2(ptr1
));
37 ptr2
.reset(new int(10));
38 BOOST_TEST(x1(ptr1
) == x2(ptr1
));
39 BOOST_TEST(x1(ptr1
) != x2(ptr2
));
41 BOOST_TEST(x1(ptr1
) == x2(ptr2
));
42 #if defined(BOOST_HASH_TEST_EXTENSIONS)
43 BOOST_TEST(x1(x
) == BOOST_HASH_TEST_NAMESPACE::hash_value(x
));
44 BOOST_TEST(x1(ptr1
) == BOOST_HASH_TEST_NAMESPACE::hash_value(ptr2
));
48 void unique_ptr_tests()
50 std::unique_ptr
<int> x
;
51 compile_time_tests(&x
);
53 BOOST_HASH_TEST_NAMESPACE::hash
<std::unique_ptr
<int> > x1
;
54 BOOST_HASH_TEST_NAMESPACE::hash
<std::unique_ptr
<int> > x2
;
56 std::unique_ptr
<int> ptr1(new int(10));
57 std::unique_ptr
<int> ptr2
;
59 BOOST_TEST(x1(x
) == x2(ptr2
));
60 BOOST_TEST(x1(x
) != x2(ptr1
));
61 ptr2
.reset(new int(10));
62 BOOST_TEST(x1(ptr1
) == x2(ptr1
));
63 BOOST_TEST(x1(ptr1
) != x2(ptr2
));
65 #if defined(BOOST_HASH_TEST_EXTENSIONS)
66 BOOST_TEST(x1(x
) == BOOST_HASH_TEST_NAMESPACE::hash_value(x
));
74 #ifdef TEST_SMART_PTRS
79 return boost::report_errors();