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 | template< class SetDerived, class SetBase, class T > |
---|
17 | void test_transfer() |
---|
18 | { |
---|
19 | SetBase to; |
---|
20 | SetDerived from; |
---|
21 | from.insert( new T ); |
---|
22 | from.insert( new T ); |
---|
23 | transfer_test( from, to ); |
---|
24 | } |
---|
25 | |
---|
26 | void test_set() |
---|
27 | { |
---|
28 | |
---|
29 | ptr_set_test< ptr_set<Base>, Base, Derived_class >(); |
---|
30 | ptr_set_test< ptr_set<Value>, Value, Value >(); |
---|
31 | |
---|
32 | ptr_set_test< ptr_multiset<Base>, Base, Derived_class >(); |
---|
33 | ptr_set_test< ptr_multiset<Value>, Value, Value >(); |
---|
34 | |
---|
35 | test_transfer< ptr_set<Derived_class>, ptr_set<Base>, Derived_class>(); |
---|
36 | test_transfer< ptr_multiset<Derived_class>, ptr_multiset<Base>, Derived_class>(); |
---|
37 | |
---|
38 | ptr_set<int> set; |
---|
39 | |
---|
40 | BOOST_CHECK_THROW( set.insert( 0 ), bad_ptr_container_operation ); |
---|
41 | set.insert( new int(0) ); |
---|
42 | set.insert( std::auto_ptr<int>( new int(1) ) ); |
---|
43 | BOOST_CHECK_THROW( (set.replace(set.begin(), 0 )), bad_ptr_container_operation ); |
---|
44 | BOOST_CHECK_THROW( (set.replace(set.begin(), std::auto_ptr<int>(0) )), bad_ptr_container_operation ); |
---|
45 | |
---|
46 | |
---|
47 | } |
---|
48 | |
---|
49 | using boost::unit_test::test_suite; |
---|
50 | |
---|
51 | test_suite* init_unit_test_suite( int argc, char* argv[] ) |
---|
52 | { |
---|
53 | test_suite* test = BOOST_TEST_SUITE( "Pointer Container Test Suite" ); |
---|
54 | |
---|
55 | test->add( BOOST_TEST_CASE( &test_set ) ); |
---|
56 | |
---|
57 | return test; |
---|
58 | } |
---|
59 | |
---|
60 | |
---|
61 | |
---|
62 | |
---|
63 | |
---|
64 | |
---|