]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/ptr_container/test/ptr_map_adapter.cpp
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / ptr_container / test / ptr_map_adapter.cpp
1 //
2 // Boost.Pointer Container
3 //
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)
8 //
9 // For more information, see http://www.boost.org/libs/ptr_container/
10 //
11
12 #include "test_data.hpp"
13 #include <boost/ptr_container/ptr_map.hpp>
14 #include <string>
15
16 using namespace std;
17
18 void test_ptr_map_adapter()
19 {
20 //typedef_test< ptr_map<int, Base>, Derived >();
21 //typedef_test< ptr_map<int, Value>, Value >();
22
23 //associative_container_test< ptr_map<int, Base>, Base, Derived >();
24 //associative_container_test< ptr_map<int, Value>, Value, Value >();
25
26 //typedef_test< ptr_multimap<int, Base>, Derived >();
27 //typedef_test< ptr_multimap<int, Value>, Value >();
28
29 //associative_container_test< ptr_multimap<int, Base>, Base, Derived >();
30 //associative_container_test< ptr_multimap<int, Value>, Value, Value >();
31
32 string joe = "joe";
33 string brian = "brian";
34
35 ptr_map<string,int> m;
36 m.insert( joe, new int( 4 ) );
37 m.insert( brian, std::auto_ptr<int>( new int( 6 ) ) );
38 m[ joe ] += 56;
39 m[ brian ] += 10;
40
41 try
42 {
43 m[ "hans" ] = 4;
44 }
45 catch( const bad_ptr_container_operation& )
46 { }
47
48 ptr_map<string,int> m2;
49 m2.insert( m2.begin(), *m.begin() );
50 BOOST_CHECK( m != m2 );
51 BOOST_CHECK( m2 < m );
52 m2.insert( m2.begin(), joe, new int(5) );
53 BOOST_CHECK( m != m2 );
54 BOOST_CHECK( m2 > m );
55
56 ptr_multimap<string,int> m3;
57 m3.insert( m3.begin(), *m.begin() );
58 BOOST_CHECK( m3.size() == 1u );
59 m3.insert( m3.begin(), brian, new int(11 ) );
60 BOOST_CHECK( m3.size() == 2u );
61 }
62
63
64 #include <boost/test/included/unit_test.hpp>
65
66 using boost::unit_test::test_suite;
67
68 test_suite* init_unit_test_suite( int argc, char* argv[] )
69 {
70 test_suite* test = BOOST_TEST_SUITE( "Pointer Container Test Suite" );
71
72 test->add( BOOST_TEST_CASE( &test_ptr_map_adapter ) );
73
74 return test;
75 }
76
77
78
79
80