ptr_deque.cpp 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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. #include <boost/test/unit_test.hpp>
  12. #include "sequence_test_data.hpp"
  13. #include <boost/ptr_container/ptr_deque.hpp>
  14. #include <boost/ptr_container/detail/ptr_container_disable_deprecated.hpp>
  15. #if defined(BOOST_PTR_CONTAINER_DISABLE_DEPRECATED)
  16. #pragma GCC diagnostic push
  17. #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
  18. #endif
  19. void test_ptr_deque()
  20. {
  21. reversible_container_test< ptr_deque<Base>, Base, Derived_class >();
  22. reversible_container_test< ptr_deque<Value>, Value, Value >();
  23. reversible_container_test< ptr_deque< nullable<Base> >, Base, Derived_class >();
  24. reversible_container_test< ptr_deque< nullable<Value> >, Value, Value >();
  25. container_assignment_test< ptr_deque<Base>, ptr_deque<Derived_class>,
  26. Derived_class>();
  27. container_assignment_test< ptr_deque< nullable<Base> >,
  28. ptr_deque< nullable<Derived_class> >,
  29. Derived_class>();
  30. container_assignment_test< ptr_deque< nullable<Base> >,
  31. ptr_deque<Derived_class>,
  32. Derived_class>();
  33. container_assignment_test< ptr_deque<Base>,
  34. ptr_deque< nullable<Derived_class> >,
  35. Derived_class>();
  36. test_transfer< ptr_deque<Derived_class>, ptr_deque<Base>, Derived_class>();
  37. random_access_algorithms_test< ptr_deque<int> >();
  38. ptr_deque<int> di;
  39. di.push_front( new int(0) );
  40. std::size_t size = 1u;
  41. BOOST_CHECK_EQUAL( di.size(), size );
  42. #ifndef BOOST_NO_AUTO_PTR
  43. di.push_front( std::auto_ptr<int>( new int(1) ) );
  44. ++size;
  45. #endif
  46. #ifndef BOOST_NO_CXX11_SMART_PTR
  47. di.push_front( std::unique_ptr<int>( new int(2) ) );
  48. ++size;
  49. #endif
  50. BOOST_CHECK_EQUAL( di.size(), size );
  51. }
  52. #if defined(BOOST_PTR_CONTAINER_DISABLE_DEPRECATED)
  53. #pragma GCC diagnostic pop
  54. #endif
  55. using boost::unit_test::test_suite;
  56. test_suite* init_unit_test_suite( int argc, char* argv[] )
  57. {
  58. test_suite* test = BOOST_TEST_SUITE( "Pointer Container Test Suite" );
  59. test->add( BOOST_TEST_CASE( &test_ptr_deque ) );
  60. return test;
  61. }