stdcpp/tsrc/Boost_test/ptr_container/src/ptr_set.cpp
changeset 31 ce057bb09d0b
child 45 4b03adbd26ca
equal deleted inserted replaced
30:e20de85af2ee 31:ce057bb09d0b
       
     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 <boost/test/unit_test.hpp>
       
    13 #include "associative_test_data.hpp"
       
    14 #include <boost/ptr_container/ptr_set.hpp>
       
    15 
       
    16 #ifdef __ARMCC__
       
    17 #pragma diag_suppress 3017
       
    18 #endif
       
    19 
       
    20 template< class SetDerived, class SetBase, class T >
       
    21 void test_transfer()
       
    22 {
       
    23     SetBase to;
       
    24     SetDerived from;
       
    25     from.insert( new T );
       
    26     from.insert( new T );
       
    27     transfer_test( from, to );
       
    28 }
       
    29 
       
    30 void test_set()
       
    31 {    
       
    32 
       
    33     ptr_set_test< ptr_set<Base>, Base, Derived_class >();
       
    34     ptr_set_test< ptr_set<Value>, Value, Value >();
       
    35 
       
    36     ptr_set_test< ptr_multiset<Base>, Base, Derived_class >();
       
    37     ptr_set_test< ptr_multiset<Value>, Value, Value >();
       
    38 
       
    39     test_transfer< ptr_set<Derived_class>, ptr_set<Base>, Derived_class>();
       
    40     test_transfer< ptr_multiset<Derived_class>, ptr_multiset<Base>, Derived_class>();
       
    41     
       
    42     ptr_set<int> set;
       
    43 
       
    44     BOOST_CHECK_THROW( set.insert( 0 ), bad_ptr_container_operation );
       
    45     set.insert( new int(0) );
       
    46  	//set.insert( std::auto_ptr<int>( new int(1) ) );
       
    47     BOOST_CHECK_THROW( (set.replace(set.begin(), 0 )), bad_ptr_container_operation );
       
    48     BOOST_CHECK_THROW( (set.replace(set.begin(), std::auto_ptr<int>(0) )), bad_ptr_container_operation );
       
    49 
       
    50 
       
    51 }
       
    52 
       
    53 #include <boost/test/included/test_exec_monitor.hpp>
       
    54 int test_main(int,char *[])
       
    55 {
       
    56   
       
    57 test_set();
       
    58   return 0;
       
    59 }
       
    60 
       
    61 
       
    62 
       
    63 
       
    64 
       
    65