Add get_pointer_test.

This commit is contained in:
Peter Dimov
2014-06-03 21:08:55 +03:00
parent 7ebcee675a
commit 5883ec1f1a
2 changed files with 52 additions and 0 deletions

View File

@@ -47,4 +47,6 @@ test-suite "core"
[ run sp_typeinfo_test.cpp : : : <rtti>off : sp_typeinfo_test_no_rtti ] [ run sp_typeinfo_test.cpp : : : <rtti>off : sp_typeinfo_test_no_rtti ]
[ run visit_each_test.cpp ] [ run visit_each_test.cpp ]
[ run get_pointer_test.cpp ]
; ;

50
test/get_pointer_test.cpp Normal file
View File

@@ -0,0 +1,50 @@
//
// get_pointer_test.cpp
//
// Copyright 2014 Peter Dimov
//
// 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
//
#include <boost/get_pointer.hpp>
#include <boost/core/lightweight_test.hpp>
#include <memory>
struct X
{
};
int main()
{
using boost::get_pointer;
{
X * p = new X;
BOOST_TEST( get_pointer( p ) == p );
delete p;
}
{
std::auto_ptr< X > p( new X );
BOOST_TEST( get_pointer( p ) == p.get() );
}
#if !defined( BOOST_NO_CXX11_SMART_PTR )
{
std::unique_ptr< X > p( new X );
BOOST_TEST( get_pointer( p ) == p.get() );
}
{
std::shared_ptr< X > p( new X );
BOOST_TEST( get_pointer( p ) == p.get() );
}
#endif
return boost::report_errors();
}