]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/assign/test/ptr_map_inserter.cpp
1 // Boost.Assign library
3 // Copyright Thorsten Ottosen 2003-2004. Use, modification and
4 // distribution is subject to the Boost Software License, Version
5 // 1.0. (See accompanying file LICENSE_1_0.txt or copy at
6 // http://www.boost.org/LICENSE_1_0.txt)
8 // For more information, see http://www.boost.org/libs/assign/
11 #include <boost/detail/workaround.hpp>
13 #if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
14 # pragma warn -8091 // suppress warning in Boost.Test
15 # pragma warn -8057 // unused argument argc/argv in Boost.Test
19 #include <boost/assign/ptr_map_inserter.hpp>
20 #include <boost/test/test_tools.hpp>
21 #include <boost/ptr_container/ptr_map.hpp>
26 // abstract base class definition
30 virtual ~abstract_base() {}
31 virtual void foo() = 0;
32 virtual abstract_base
* clone() const = 0;
35 struct implementation
: abstract_base
40 implementation( const implementation
& )
46 implementation( int, int )
49 implementation( int, std::string
, int, std::string
)
53 virtual abstract_base
* clone() const
55 return new implementation( *this );
60 void check_ptr_map_inserter()
63 #ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
65 boost::ptr_map
<std::string
, abstract_base
> m
;
66 boost::assign::ptr_map_insert
<implementation
>( m
)
67 ( "foo", 1, "two", 3, "four" )
68 ( "bar", 41, "42", 43, "44" );
69 BOOST_CHECK_EQUAL( m
.size(), 2u );
70 BOOST_CHECK( typeid(m
.at("foo")) == typeid(implementation
) );
74 boost::ptr_map
<std::string
,implementation
> m2
;
75 boost::assign::ptr_map_insert( m2
)
76 ( "foobar", 1, "two", 3, "four" )
77 ( "key1" )( "key2" )( "key3" )( "key4" )
78 ( "key5", 42 )( "key6", 42, 42 );
80 BOOST_CHECK_EQUAL( m2
.size(), 7u );
81 boost::assign::ptr_map_insert( m2
)( "key1" );
82 BOOST_CHECK_EQUAL( m2
.size(), 7u ); // duplicates not inserted
88 #include <boost/test/unit_test.hpp>
89 using boost::unit_test::test_suite
;
91 test_suite
* init_unit_test_suite( int argc
, char* argv
[] )
93 test_suite
* test
= BOOST_TEST_SUITE( "List Test Suite" );
95 test
->add( BOOST_TEST_CASE( &check_ptr_map_inserter
) );