2 // Boost.Pointer Container
4 // Copyright Thorsten Ottosen 2003-2005. Use, modification and
5 // distribution is subject to the Boost Software License, Version
6 // 1.0. (See accompanying file LICENSE_1_0.txt or copy at
7 // http://www.boost.org/LICENSE_1_0.txt)
9 // For more information, see http://www.boost.org/libs/ptr_container/
12 #include "test_data.hpp"
13 #include <boost/ptr_container/ptr_map.hpp>
14 #include <boost/ptr_container/detail/ptr_container_disable_deprecated.hpp>
15 #include <boost/test/unit_test.hpp>
20 #if defined(BOOST_PTR_CONTAINER_DISABLE_DEPRECATED)
21 #pragma GCC diagnostic push
22 #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
25 void test_ptr_map_adapter()
27 //typedef_test< ptr_map<int, Base>, Derived >();
28 //typedef_test< ptr_map<int, Value>, Value >();
30 //associative_container_test< ptr_map<int, Base>, Base, Derived >();
31 //associative_container_test< ptr_map<int, Value>, Value, Value >();
33 //typedef_test< ptr_multimap<int, Base>, Derived >();
34 //typedef_test< ptr_multimap<int, Value>, Value >();
36 //associative_container_test< ptr_multimap<int, Base>, Base, Derived >();
37 //associative_container_test< ptr_multimap<int, Value>, Value, Value >();
40 string brian
= "brian";
42 ptr_map
<string
,int> m
;
43 m
.insert( joe
, new int( 4 ) );
44 #ifndef BOOST_NO_AUTO_PTR
45 m
.insert( brian
, std::auto_ptr
<int>( new int( 6 ) ) );
47 #ifndef BOOST_NO_CXX11_SMART_PTR
48 m
.insert( brian
, std::unique_ptr
<int>( new int( 6 ) ) );
57 catch( const bad_ptr_container_operation
& )
60 ptr_map
<string
,int> m2
;
61 m2
.insert( m2
.begin(), *m
.begin() );
62 BOOST_CHECK( m
!= m2
);
63 BOOST_CHECK( m2
< m
);
64 m2
.insert( m2
.begin(), joe
, new int(5) );
65 BOOST_CHECK( m
!= m2
);
66 BOOST_CHECK( m2
> m
);
68 ptr_multimap
<string
,int> m3
;
69 m3
.insert( m3
.begin(), *m
.begin() );
70 BOOST_CHECK( m3
.size() == 1u );
71 m3
.insert( m3
.begin(), brian
, new int(11 ) );
72 BOOST_CHECK( m3
.size() == 2u );
75 #if defined(BOOST_PTR_CONTAINER_DISABLE_DEPRECATED)
76 #pragma GCC diagnostic pop
79 using boost::unit_test::test_suite
;
81 test_suite
* init_unit_test_suite( int argc
, char* argv
[] )
83 test_suite
* test
= BOOST_TEST_SUITE( "Pointer Container Test Suite" );
85 test
->add( BOOST_TEST_CASE( &test_ptr_map_adapter
) );