////////////////////////////////////////////////////////////////////////////// // // (C) Copyright Howard Hinnant 2009 // (C) Copyright Ion Gaztanaga 2014-2014. // // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) // // See http://www.boost.org/libs/move for documentation. // ////////////////////////////////////////////////////////////////////////////// #include #include #include #include #include ////////////////////////////////////////////// // // The initial implementation of these tests // was written by Howard Hinnant. // // These test were later refactored grouping // and porting them to Boost.Move. // // Many thanks to Howard for releasing his C++03 // unique_ptr implementation with such detailed // test cases. // ////////////////////////////////////////////// #include "unique_ptr_test_utils_beg.hpp" namespace bml = ::boost::movelib; namespace bmupmu = ::boost::move_upmu; //////////////////////////////// // unique_ptr_pointer_type //////////////////////////////// namespace unique_ptr_pointer_type { struct Deleter { struct pointer {}; }; // Test unique_ptr::pointer type void test() { //Single unique_ptr { typedef bml::unique_ptr P; BOOST_STATIC_ASSERT((bmupmu::is_same::value)); } { typedef bml::unique_ptr P; BOOST_STATIC_ASSERT((bmupmu::is_same::value)); } //Unbounded array unique_ptr { typedef bml::unique_ptr P; BOOST_STATIC_ASSERT((bmupmu::is_same::value)); } { typedef bml::unique_ptr P; BOOST_STATIC_ASSERT((bmupmu::is_same::value)); } //Bounded array unique_ptr { typedef bml::unique_ptr P; BOOST_STATIC_ASSERT((bmupmu::is_same::value)); } { typedef bml::unique_ptr P; BOOST_STATIC_ASSERT((bmupmu::is_same::value)); } //Unbounded array of bounded array unique_ptr { typedef int int_5_t [5]; typedef bml::unique_ptr P; BOOST_STATIC_ASSERT((bmupmu::is_same::value)); } { typedef int int_5_t [5]; typedef bml::unique_ptr P; BOOST_STATIC_ASSERT((bmupmu::is_same::value)); } } } //namespace unique_ptr_pointer_type { //////////////////////////////// // unique_ptr_deleter_type //////////////////////////////// namespace unique_ptr_deleter_type { struct Deleter {}; // Test unique_ptr::deleter type void test() { //Single unique_ptr { typedef bml::unique_ptr P; BOOST_STATIC_ASSERT((bmupmu::is_same >::value)); } { typedef bml::unique_ptr P; BOOST_STATIC_ASSERT((bmupmu::is_same::value)); } //Unbounded array unique_ptr { typedef bml::unique_ptr P; BOOST_STATIC_ASSERT((bmupmu::is_same >::value)); } { typedef bml::unique_ptr P; BOOST_STATIC_ASSERT((bmupmu::is_same::value)); } //Bounded array unique_ptr { typedef bml::unique_ptr P; BOOST_STATIC_ASSERT((bmupmu::is_same >::value)); } { typedef bml::unique_ptr P; BOOST_STATIC_ASSERT((bmupmu::is_same::value)); } } } //namespace unique_ptr_deleter_type { //////////////////////////////// // unique_ptr_element_type //////////////////////////////// namespace unique_ptr_element_type { // Test unique_ptr::deleter type void test() { //Single unique_ptr { typedef bml::unique_ptr P; BOOST_STATIC_ASSERT((bmupmu::is_same::value)); } //Unbounded array unique_ptr { typedef bml::unique_ptr P; BOOST_STATIC_ASSERT((bmupmu::is_same::value)); } //Bounded array unique_ptr { typedef bml::unique_ptr P; BOOST_STATIC_ASSERT((bmupmu::is_same::value)); } } } //namespace unique_ptr_element_type { //////////////////////////////// // unique_ptr_construct_assign_traits //////////////////////////////// namespace unique_ptr_construct_assign_traits { void test() { typedef bml::unique_ptr unique_ptr_t; //Even if BOOST_MOVE_TT_CXX11_IS_COPY_CONSTRUCTIBLE is not defined //boost::unique_ptr shall work with boost::movelib traits BOOST_STATIC_ASSERT(!(boost::move_detail::is_copy_constructible::value)); //Even if BOOST_MOVE_TT_CXX11_IS_COPY_ASSIGNABLE is not defined //boost::unique_ptr shall work with boost::movelib traits BOOST_STATIC_ASSERT(!(boost::move_detail::is_copy_assignable::value)); //Important traits for containers like boost::vector BOOST_STATIC_ASSERT(!(boost::move_detail::is_trivially_copy_constructible::value)); BOOST_STATIC_ASSERT(!(boost::move_detail::is_trivially_copy_assignable::value)); } } //namespace unique_ptr_construct_assign_traits { //////////////////////////////// // main //////////////////////////////// int main() { //General unique_ptr_pointer_type::test(); unique_ptr_deleter_type::test(); unique_ptr_element_type::test(); unique_ptr_construct_assign_traits::test(); //Test results return boost::report_errors(); } #include "unique_ptr_test_utils_end.hpp"