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 #define PTR_LIST_TEST 1
13 #define PTR_CONTAINER_DEBUG 0
14
15 #include <boost/test/unit_test.hpp>
16 #include "sequence_test_data.hpp"
17 #include <boost/ptr_container/ptr_list.hpp>
18 #include <boost/ptr_container/detail/ptr_container_disable_deprecated.hpp>
19
20 #if defined(BOOST_PTR_CONTAINER_DISABLE_DEPRECATED)
21 #pragma GCC diagnostic push
22 #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
23 #endif
24
test_list()25 void test_list()
26 {
27
28 reversible_container_test< ptr_list<Base>, Base, Derived_class >();
29 reversible_container_test< ptr_list<Value>, Value, Value >();
30 reversible_container_test< ptr_list< nullable<Base> >, Base, Derived_class >();
31 reversible_container_test< ptr_list< nullable<Value> >, Value, Value >();
32
33 container_assignment_test< ptr_list<Base>, ptr_list<Derived_class>,
34 Derived_class>();
35 container_assignment_test< ptr_list< nullable<Base> >,
36 ptr_list< nullable<Derived_class> >,
37 Derived_class>();
38 container_assignment_test< ptr_list< nullable<Base> >,
39 ptr_list<Derived_class>,
40 Derived_class>();
41 container_assignment_test< ptr_list<Base>,
42 ptr_list< nullable<Derived_class> >,
43 Derived_class>();
44
45 test_transfer< ptr_list<Derived_class>, ptr_list<Base>, Derived_class>();
46
47 random_access_algorithms_test< ptr_list<int> >();
48 ptr_list<int> list;
49 list.push_back( new int(0) );
50 list.push_back( new int(2) );
51 list.push_back( new int(1) );
52 list.push_front( new int(3) );
53 #ifndef BOOST_NO_AUTO_PTR
54 list.push_front( std::auto_ptr<int>( new int(42) ) );
55 #endif
56 #ifndef BOOST_NO_CXX11_SMART_PTR
57 list.push_front( std::unique_ptr<int>( new int(43) ) );
58 #endif
59 list.reverse();
60 ptr_list<int>::const_iterator it = list.begin();
61 BOOST_CHECK(1 == *it++);
62 BOOST_CHECK(2 == *it++);
63 BOOST_CHECK(0 == *it++);
64 BOOST_CHECK(3 == *it++);
65 #ifndef BOOST_NO_AUTO_PTR
66 BOOST_CHECK(42 == *it++);
67 #endif
68 #ifndef BOOST_NO_CXX11_SMART_PTR
69 BOOST_CHECK(43 == *it++);
70 #endif
71 BOOST_CHECK(list.end() == it);
72 }
73
74 #if defined(BOOST_PTR_CONTAINER_DISABLE_DEPRECATED)
75 #pragma GCC diagnostic pop
76 #endif
77
78 using boost::unit_test::test_suite;
79
init_unit_test_suite(int argc,char * argv[])80 test_suite* init_unit_test_suite( int argc, char* argv[] )
81 {
82 test_suite* test = BOOST_TEST_SUITE( "Pointer Container Test Suite" );
83
84 test->add( BOOST_TEST_CASE( &test_list ) );
85
86 return test;
87 }
88